# HG changeset patch # User Thomas Wuerthinger # Date 1404222114 -7200 # Node ID 9670aff0388b3093a6429ac86b2c2d64dc6b8aa8 # Parent 00460aab5c96a4ff62af387d1e9ba3d38d5329f3 Add utility for getting the unqualified type name of a Java type. diff -r 00460aab5c96 -r 9670aff0388b graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/JavaType.java --- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/JavaType.java Tue Jul 01 19:06:06 2014 +0200 +++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/JavaType.java Tue Jul 01 15:41:54 2014 +0200 @@ -41,6 +41,25 @@ String getName(); /** + * Returns an unqualified name of this type. + * + *
+     *     "Object"
+     *     "Integer"
+     * 
+ */ + default String getUnqualifiedName() { + String name = getName(); + if (name.indexOf('/') != -1) { + name = name.substring(name.lastIndexOf('/') + 1); + } + if (name.endsWith(";")) { + name = name.substring(0, name.length() - 1); + } + return name; + } + + /** * For array types, gets the type of the components, or {@code null} if this is not an array * type. This method is analogous to {@link Class#getComponentType()}. */