Anonymous classes are not final according to reflection API
Maurizio Cimadamore
maurizio.cimadamore at oracle.com
Mon Jun 29 13:29:19 UTC 2015
I've closed it as 'not an issue' - this seems to be an outstanding issue
that was fixed for some time and then reverted because of compatibility
problems:
https://bugs.openjdk.java.net/browse/JDK-6520152
Maurizio
On 23/06/15 14:42, Georgiy Rakov wrote:
> I've filed the issue JDK-8129576.
> <https://bugs.openjdk.java.net/browse/JDK-8129576>
>
> There is following issue in JBS: JDK-4777101
> <https://bugs.openjdk.java.net/browse/JDK-4777101> which seems to
> relate to this one.
>
> Thank you,
> Georgiy.
>
> On 22.06.2015 18:56, Victor Rudometov wrote:
>> This seems to be a reflection bug, since ACC_FINAL is present in
>> Test12$1.class file:
>>
>> final class test.Test12$1 extends test.Test12$Foo<java.lang.Integer>
>> minor version: 0
>> major version: 52
>> flags: ACC_FINAL, ACC_SUPER
>>
>> Thanks.
>> Victor.
>>
>> On 22-Jun-15 18:35, Remi Forax wrote:
>>> I wonder if it's not a reflection bug,
>>> did you check with 'javap -c -verbose' the modifiers of the
>>> generated class (something like Test12$1.class) ?
>>>
>>> cheers,
>>> Rémi
>>>
>>> On 06/22/2015 05:17 PM, Georgiy Rakov wrote:
>>>> Hello,
>>>>
>>>> if I understand correctly according to following assertion from JLS
>>>> 15.9.5 anonymous classes are always final:
>>>>
>>>> An anonymous class is always implicitly final (§8.1.1.2).
>>>>
>>>> But reflection API reports that the class is not final. Namely
>>>> let's consider following code:
>>>>
>>>> import java.lang.reflect.Modifier;
>>>>
>>>> public class Test12 {
>>>> static class Foo<T> {}
>>>>
>>>> public static void main(String argv[]) {
>>>> Foo<Integer> foo = new Foo<>() {};
>>>> if ( (foo.getClass().getModifiers() & Modifier.FINAL)
>>>> != 0 ) {
>>>> System.out.println("final, modifiers: " +
>>>> foo.getClass().getModifiers());
>>>> } else {
>>>> System.out.println("not final, modifiers: " +
>>>> foo.getClass().getModifiers());
>>>> }
>>>> }
>>>> }
>>>>
>>>> On JDK9b69 it reports:
>>>>
>>>> not final, modifiers: 0
>>>>
>>>> Could you please tell if you consider this as a discrepancy between
>>>> spec and javac (VM?) which should be fixed.
>>>>
>>>> Thank you,
>>>> Georgiy.
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20150629/d7f4150e/attachment.html>
More information about the compiler-dev
mailing list