MethodParameters attributes in v51 classfiles
Liam Miller-Cushon
cushon at google.com
Wed Nov 9 01:22:36 UTC 2016
I'd be happy to have MethodParameters attributes in older class file
versions, but not wanting to special-case future attribute diagnostics
makes sense.
This came up because of a bad interaction between future attribute
diagnostics and rawtypes warnings. The same issue might affect other future
attribute warnings or other diagnostic kinds, so it's probably worth
tracking separately:
public class A<E, F extends B> { public A(F f) {} }
public class B { public void t(int i) {} }
public class Test {
public void f() {
new A(new B());
}
}
javac -parameters -source 7 -target 7 A.java B.java
javac -Xlint:all -sourcepath : Test.java
./A.class: warning: [classfile] MethodParameters attribute introduced in
version 52.0 class files is ignored in version 51.0 class files
./B.class: warning: [classfile] MethodParameters attribute introduced in
version 52.0 class files is ignored in version 51.0 class files
2 warnings
An exception has occurred in the compiler (9-ea). Please file a bug against
the Java compiler via the Java bug reporting page (http://bugreport.java.com)
after checking the Bug Database (http://bugs.java.com) for duplicates.
Include your program and the following diagnostic in your report. Thank you.
java.lang.AssertionError: Missing type variable in where clause: E
at com.sun.tools.javac.util.RichDiagnosticFormatter.unique(jdk.compiler at 9-ea
/RichDiagnosticFormatter.java:247)
at
com.sun.tools.javac.util.RichDiagnosticFormatter.access$100(jdk.compiler at 9-ea
/RichDiagnosticFormatter.java:71)
at
com.sun.tools.javac.util.RichDiagnosticFormatter$RichPrinter.visitTypeVar(jdk.compiler at 9-ea
/RichDiagnosticFormatter.java:398)
at
com.sun.tools.javac.util.RichDiagnosticFormatter$RichPrinter.visitTypeVar(jdk.compiler at 9-ea
/RichDiagnosticFormatter.java:340)
On Tue, Nov 8, 2016 at 4:40 PM, Jonathan Gibbons <
jonathan.gibbons at oracle.com> wrote:
>
>
> On 11/08/2016 04:31 PM, Liam Miller-Cushon wrote:
>
>> If -parameters is passed, javac will write MethodParameters attributes
>> when source/target < 8. It also reports -Xlint:classfile warnings about
>> MethodParameters attributes in < v52 classfiles:
>>
>> class X {
>> void f(int a) {}
>> }
>> class Y {
>> X x;
>> }
>>
>> $ javac -source 7 -target 7 -parameters X.java
>> $ javac -Xlint:classfile -sourcepath : Y.java
>> ./X.class: warning: [classfile] MethodParameters attribute introduced in
>> version 52.0 class files is ignored in version 51.0 class files
>>
>> Is that deliberate? I expected it to either not write the attribute for
>> old classfile versions, or not warn about it.
>>
>
> Since the code that generates the warning is a general warning for any
> future attribute, and not specific to MethodParameters, it would seem more
> appropriate to not generate the attribute for versions for which it is not
> appropriate.
>
> -- Jon
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20161108/b7487268/attachment-0001.html>
More information about the compiler-dev
mailing list