[PATCH] 8036827: Incorrect printing of the generic method declaration
B. Blaser
bsrbnd at gmail.com
Fri Jan 27 22:05:46 UTC 2017
Thanks for your answer.
It seems reasonable to print it and compliant with the comments you
provided in JDK 7031005.
I think there's probably a slight inconsistency similar to JDK
7031005, but for classes.
With -verbose, we have:
1) Info from super_class:
$ more JDK_8036827.java
class JDK_8036827 {}
$ javap -v JDK_8036827.class
Compiled from "JDK_8036827.java"
class JDK_8036827
2) Info from class signature:
$ more JDK_8036827.java
class JDK_8036827<T> {}
$ javap -v JDK_8036827.class
Compiled from "JDK_8036827.java"
class JDK_8036827<T extends java.lang.Object> extends java.lang.Object
What's the correct expectation?
Should "extends java.lang.Object" be present in the first example as
this information is present in the class file?
This would be coherent with your first comment in JDK 7031005, but I
don't know if something has changed since you wrote it.
Bernard
2017-01-26 22:24 GMT+01:00 Jonathan Gibbons <jonathan.gibbons at oracle.com>:
> Bernard,
>
> I don't think this should be changed, and I will close out the JBS issue.
>
> Without the -verbose flag, the "extends java.lang.Object" is not printed.
>
> $ ./build/linux-x86_64-normal-server-release/images/jdk/bin/javap
> play/src/JDK_8036827.class
> Compiled from "JDK_8036827.java"
> class JDK_8036827 {
> JDK_8036827();
> public <T> T m1(T);
> }
>
> When the -verbose flag is used, it does not seem unreasonable to print out
> information which is explicitly present in the class file.
>
> -- Jon
>
>
>
> On 01/26/2017 02:39 AM, B. Blaser wrote:
>>
>> Hi,
>>
>> 2017-01-25 21:23 GMT+01:00 B. Blaser <bsrbnd at gmail.com>:
>>>
>>> Next is a suggestion to remove javap's redundant printing of "extends
>>> java.lang.Object" in the following example (according to JDK 8036827
>>> description):
>>>
>>> class JDK_8036827 {
>>> public <T> T m1(T a) {
>>> return null;
>>> }
>>> }
>>>
>> I've also updated the existing related tests, below.
>>
>> Bernard
>>
>> diff --git
>> a/src/jdk.jdeps/share/classes/com/sun/tools/javap/ClassWriter.java
>> b/src/jdk.jdeps/share/classes/com/sun/tools/javap/ClassWriter.java
>> --- a/src/jdk.jdeps/share/classes/com/sun/tools/javap/ClassWriter.java
>> +++ b/src/jdk.jdeps/share/classes/com/sun/tools/javap/ClassWriter.java
>> @@ -344,8 +344,7 @@
>> public StringBuilder visitTypeParamType(TypeParamType
>> type, StringBuilder sb) {
>> sb.append(type.name);
>> String sep = " extends ";
>> - if (type.classBound != null
>> - && (options.verbose ||
>> !type.classBound.isObject())) {
>> + if (type.classBound != null &&
>> !type.classBound.isObject()) {
>> sb.append(sep);
>> append(sb, type.classBound);
>> sep = " & ";
>> diff --git a/test/tools/javap/4870651/T4870651.java
>> b/test/tools/javap/4870651/T4870651.java
>> --- a/test/tools/javap/4870651/T4870651.java
>> +++ b/test/tools/javap/4870651/T4870651.java
>> @@ -40,7 +40,7 @@
>>
>> public void run() throws IOException {
>> verify("Test",
>> - "class Test<T extends java.lang.Object, " +
>> + "class Test<T, " +
>> "E extends java.lang.Exception &
>> java.lang.Comparable<T>, " +
>> "U extends java.lang.Comparable>",
>> "v1(java.lang.String...)");
>> diff --git a/test/tools/javap/BoundsTypeVariableTest.java
>> b/test/tools/javap/BoundsTypeVariableTest.java
>> --- a/test/tools/javap/BoundsTypeVariableTest.java
>> +++ b/test/tools/javap/BoundsTypeVariableTest.java
>> @@ -49,7 +49,7 @@
>> srcDir.mkdirs();
>> File classesDir = new File("classes");
>> classesDir.mkdirs();
>> - final String expect = "public abstract <U extends
>> java.lang.Object> U doit();";
>> + final String expect = "public abstract <U> U doit();";
>> List<String> contents = new ArrayList<>();
>> contents.add("abstract class X {");
>> contents.add(expect);
>
>
More information about the compiler-dev
mailing list