< prev index next >

src/jdk.jdi/share/classes/com/sun/tools/jdi/JNITypeParser.java

Print this page
rev 58565 : 8238358: Implementation of JEP 371: Hidden Classes
Reviewed-by: duke
Contributed-by: mandy.chung@oracle.com, lois.foltan@oracle.com, david.holmes@oracle.com, harold.seigel@oracle.com, serguei.spitsyn@oracle.com, alex.buckley@oracle.com, jamsheed.c.m@oracle.com

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2020, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.  Oracle designates this

@@ -41,42 +41,49 @@
 
     JNITypeParser(String signature) {
         this.signature = signature;
     }
 
-    static String typeNameToSignature(String signature) {
+    static String typeNameToSignature(String typeName) {
         StringBuilder sb = new StringBuilder();
-        int firstIndex = signature.indexOf('[');
+        int firstIndex = typeName.indexOf('[');
         int index = firstIndex;
         while (index != -1) {
             sb.append('[');
-            index = signature.indexOf('[', index + 1);
+            index = typeName.indexOf('[', index + 1);
         }
 
         if (firstIndex != -1) {
-            signature = signature.substring(0, firstIndex);
+            typeName = typeName.substring(0, firstIndex);
         }
 
-        if (signature.equals("boolean")) {
+        if (typeName.equals("boolean")) {
             sb.append('Z');
-        } else if (signature.equals("byte")) {
+        } else if (typeName.equals("byte")) {
             sb.append('B');
-        } else if (signature.equals("char")) {
+        } else if (typeName.equals("char")) {
             sb.append('C');
-        } else if (signature.equals("short")) {
+        } else if (typeName.equals("short")) {
             sb.append('S');
-        } else if (signature.equals("int")) {
+        } else if (typeName.equals("int")) {
             sb.append('I');
-        } else if (signature.equals("long")) {
+        } else if (typeName.equals("long")) {
             sb.append('J');
-        } else if (signature.equals("float")) {
+        } else if (typeName.equals("float")) {
             sb.append('F');
-        } else if (signature.equals("double")) {
+        } else if (typeName.equals("double")) {
             sb.append('D');
         } else {
             sb.append('L');
-            sb.append(signature.replace('.', '/'));
+            index = typeName.indexOf("/");   // check if it's a hidden class
+            if (index < 0) {
+                sb.append(typeName.replace('.', '/'));
+            } else {
+                sb.append(typeName.substring(0, index).replace('.', '/'));
+                sb.append(".");
+                sb.append(typeName.substring(index+1, typeName.length()));
+            }
             sb.append(';');
         }
 
         return sb.toString();
     }

@@ -201,11 +208,17 @@
             case (JDWP.Tag.OBJECT):
                 int endClass = signature.indexOf(SIGNATURE_ENDCLASS,
                                                  currentIndex);
                 String retVal = signature.substring(currentIndex,
                                                     endClass);
-                retVal = retVal.replace('/','.');
+                int index = retVal.indexOf(".");
+                if (index < 0) {
+                    retVal = retVal.replace('/', '.');
+                } else {
+                    retVal = retVal.substring(0, index).replace('/', '.') + "/" +
+                             retVal.substring(index + 1, retVal.length());
+                }
                 currentIndex = endClass + 1;
                 return retVal;
 
             case (JDWP.Tag.FLOAT):
                 return "float";
< prev index next >