changeset 7357:c07a49b27b89

added Signature.getString() to get a signature string in JVMS format
author Doug Simon <doug.simon@oracle.com>
date Sat, 12 Jan 2013 21:53:22 +0100
parents fe9f252f0d05
children f965b7a96f16
files graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/MetaUtil.java graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Signature.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedObjectType.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotSignature.java
diffstat 4 files changed, 19 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/MetaUtil.java	Sat Jan 12 21:43:12 2013 +0100
+++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/MetaUtil.java	Sat Jan 12 21:53:22 2013 +0100
@@ -494,23 +494,6 @@
     }
 
     /**
-     * Converts a {@link Signature} to internal representation, i.e., the signature
-     * <pre>(int, String, double)void</pre> is converted to <pre>(ILjava/lang/String;D)V</pre>.
-     *
-     * @param sig the {@link Signature} to be converted.
-     *
-     * @return the signature's internal representation as a string.
-     */
-    public static String signatureToInternal(Signature sig) {
-        StringBuilder sb = new StringBuilder("(");
-        for (int i = 0; i < sig.getParameterCount(false); ++i) {
-            sb.append(sig.getParameterType(i, null).getName());
-        }
-        sb.append(')').append(sig.getReturnType(null).getName());
-        return sb.toString();
-    }
-
-    /**
      * Formats some profiling information associated as a string.
      *
      * @param info the profiling info to format
--- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Signature.java	Sat Jan 12 21:43:12 2013 +0100
+++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Signature.java	Sat Jan 12 21:53:22 2013 +0100
@@ -24,14 +24,14 @@
 
 /**
  * Represents a method signature provided by the runtime.
- * 
+ *
  * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/ClassFile.doc.html#7035">Method Descriptors</a>
  */
 public interface Signature {
 
     /**
      * Returns the number of parameters in this signature, adding 1 for a receiver if requested.
-     * 
+     *
      * @param receiver true if 1 is to be added to the result for a receiver
      * @return the number of parameters; + 1 iff {@code receiver == true}
      */
@@ -40,7 +40,7 @@
     /**
      * Gets the parameter type at the specified position. This method returns a {@linkplain ResolvedJavaType resolved}
      * type if possible but without triggering any class loading or resolution.
-     * 
+     *
      * @param index the index into the parameters, with {@code 0} indicating the first parameter
      * @param accessingClass the context of the type lookup. If accessing class is provided, its class loader is used to
      *            retrieve an existing resolved type. This value can be {@code null} if the caller does not care for a
@@ -52,7 +52,7 @@
     /**
      * Gets the parameter kind at the specified position. This is the same as calling {@link #getParameterType}.
      * {@link JavaType#getKind getKind}.
-     * 
+     *
      * @param index the index into the parameters, with {@code 0} indicating the first parameter
      * @return the kind of the parameter at the specified position
      */
@@ -61,7 +61,7 @@
     /**
      * Gets the return type of this signature. This method will return a {@linkplain ResolvedJavaType resolved} type if
      * possible but without triggering any class loading or resolution.
-     * 
+     *
      * @param accessingClass the context of the type lookup. If accessing class is provided, its class loader is used to
      *            retrieve an existing resolved type. This value can be {@code null} if the caller does not care for a
      *            resolved type.
@@ -77,10 +77,20 @@
 
     /**
      * Gets the size, in Java slots, of the parameters to this signature.
-     * 
+     *
      * @param withReceiver {@code true} if to add a slot for a receiver object; {@code false} not to include the
      *            receiver
      * @return the size of the parameters in slots
      */
     int getParameterSlots(boolean withReceiver);
+
+    /**
+     * Gets this string representation of this signature in the format specified in the JVMS.
+     * For example:
+     *
+     * <pre>(ILjava/lang/String;D)V</pre>.
+     *
+     * @return the signature as a string
+     */
+    String getString();
 }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedObjectType.java	Sat Jan 12 21:43:12 2013 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedObjectType.java	Sat Jan 12 21:53:22 2013 +0100
@@ -330,7 +330,7 @@
     @Override
     public ResolvedJavaMethod resolveMethod(ResolvedJavaMethod method) {
         assert method instanceof HotSpotMethod;
-        return (ResolvedJavaMethod) HotSpotGraalRuntime.getInstance().getCompilerToVM().resolveMethod(this, method.getName(), ((HotSpotSignature) method.getSignature()).asString());
+        return (ResolvedJavaMethod) HotSpotGraalRuntime.getInstance().getCompilerToVM().resolveMethod(this, method.getName(), ((HotSpotSignature) method.getSignature()).getString());
     }
 
     @Override
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotSignature.java	Sat Jan 12 21:43:12 2013 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotSignature.java	Sat Jan 12 21:53:22 2013 +0100
@@ -123,7 +123,8 @@
         return type;
     }
 
-    public String asString() {
+    @Override
+    public String getString() {
         return originalString;
     }