MethodParameters attributes in v51 classfiles

Liam Miller-Cushon cushon at google.com
Tue Jan 16 18:10:52 UTC 2018


This ended up getting filed as
https://bugs.openjdk.java.net/browse/JDK-8190452. I've seen a few other
reports of 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.

Since this didn't get fixed in time for 9, and there are now class files in
the wild that have this issue, would you consider relaxing the warning for
MethodParameters attributes?

I'm interested in contributing a fix (to relax the warning and/or only emit
the attributes for appropriate class file versions) if someone is
interested in sponsoring it.

Thanks,

On Tue, Nov 8, 2016 at 5:22 PM, Liam Miller-Cushon <cushon at google.com>
wrote:

> 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/20180116/57c0032e/attachment.html>


More information about the compiler-dev mailing list