Mercurial > hg > graal-jvmci-8
changeset 23790:224f43824e2b
incomplete API to MethodParameters attribute (JDK-8169331)
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Mon, 07 Nov 2016 17:15:18 +0100 |
parents | 0cb263db490f |
children | ece41fdd7334 |
files | jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaMethodImpl.java jvmci/jdk.vm.ci.meta/src/jdk/vm/ci/meta/ResolvedJavaMethod.java jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaMethod.java |
diffstat | 3 files changed, 29 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaMethodImpl.java Fri Nov 04 14:22:47 2016 +0100 +++ b/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaMethodImpl.java Mon Nov 07 17:15:18 2016 +0100 @@ -474,7 +474,8 @@ Parameter[] res = new Parameter[javaParameters.length]; for (int i = 0; i < res.length; i++) { java.lang.reflect.Parameter src = javaParameters[i]; - res[i] = new Parameter(src.getName(), src.getModifiers(), this, i); + String paramName = src.isNamePresent() ? src.getName() : null; + res[i] = new Parameter(paramName, src.getModifiers(), this, i); } return res; }
--- a/jvmci/jdk.vm.ci.meta/src/jdk/vm/ci/meta/ResolvedJavaMethod.java Fri Nov 04 14:22:47 2016 +0100 +++ b/jvmci/jdk.vm.ci.meta/src/jdk/vm/ci/meta/ResolvedJavaMethod.java Mon Nov 07 17:15:18 2016 +0100 @@ -186,7 +186,9 @@ /** * Constructor for {@code Parameter}. * - * @param name the name of the parameter + * @param name the name of the parameter or {@code null} if there is no + * {@literal MethodParameters} class file attribute providing a non-empty name + * for the parameter * @param modifiers the modifier flags for the parameter * @param method the method which defines this parameter * @param index the index of the parameter @@ -195,6 +197,7 @@ int modifiers, ResolvedJavaMethod method, int index) { + assert name == null || !name.isEmpty(); this.name = name; this.modifiers = modifiers; this.method = method; @@ -202,10 +205,20 @@ } /** - * Gets the name of the parameter. + * Gets the name of the parameter. If the parameter's name is {@linkplain #isNamePresent() + * present}, then this method returns the name provided by the class file. Otherwise, this + * method synthesizes a name of the form argN, where N is the index of the parameter in the + * descriptor of the method which declares the parameter. + * + * @return the name of the parameter, either provided by the class file or synthesized if + * the class file does not provide a name */ public String getName() { - return name; + if (name == null) { + return "arg" + index; + } else { + return name; + } } /** @@ -244,6 +257,16 @@ } /** + * Determines if the parameter has a name according to a {@literal MethodParameters} class + * file attribute. + * + * @return true if and only if the parameter has a name according to the class file. + */ + public boolean isNamePresent() { + return name != null; + } + + /** * Determines if the parameter represents a variable argument list. */ public boolean isVarArgs() {
--- a/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaMethod.java Fri Nov 04 14:22:47 2016 +0100 +++ b/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaMethod.java Mon Nov 07 17:15:18 2016 +0100 @@ -273,9 +273,8 @@ for (int i = 0; i < actual.length; i++) { java.lang.reflect.Parameter exp = expected[i]; Parameter act = actual[i]; - System.out.println(exp + " " + act); assertEquals(exp.getName(), act.getName()); - assertEquals(exp.getModifiers(), act.getModifiers()); + assertEquals(exp.isNamePresent(), act.isNamePresent()); assertEquals(exp.getModifiers(), act.getModifiers()); assertArrayEquals(exp.getAnnotations(), act.getAnnotations()); assertEquals(exp.getType().getName(), act.getType().toClassName());