Generic type information for classes within closures not emitted by javac 11.0.15
Vicente Romero
vicente.romero at oracle.com
Wed Jun 15 14:36:26 UTC 2022
Hi Dawid,
Thanks for the additional information, but from your findings it seems
like the issue has been fixed in recent releases. Fixing it in previous
releases seems to me like a sustaining / support job,
Thanks,
Vicente
On 6/10/22 08:48, Dawid Weiss wrote:
>
> Just FYI - I did a little bisecting archeology and it's this issue:
> https://bugs.openjdk.org/browse/JDK-8215470
>
> The signatures from the nested class are fine after that commit and
> erased/ missing before. So the bug is present in anything up to jdk-13-ga.
>
> Dawid
>
> On Wed, Jun 8, 2022 at 10:08 PM Dawid Weiss <dawid.weiss at gmail.com> wrote:
>
>
> Good evening,
>
> I've spent an interesting day debugging a very awkward error in
> Google Guice: a binding would work in JDK17 but would result in an
> odd (and misleading) error information under JDK11. This turns out
> to be a problem with generic signatures emitted by the
> corresponding compilers.
>
> I narrowed it down to essentially something like this [full source
> at 1]:
>
> Callable<Void> r =
> () -> {
> class Foo1 {
> public Map<String, Integer> field;
> }
>
> System.out.println("Foo1.field type: " +
> Foo1.class.getField("field").getGenericType());
> return null;
> };
> r.call();
>
> When I compile and run this snippet under java 11.0.15, I get only
> the following signatures for generic types:
>
> Foo1.field type: interface java.util.Map
>
> if you move the inner class declaration outside of the closure,
> proper generic info is stored and then loaded/ printed:
>
> Foo2.field type: java.util.Map<java.lang.String, java.lang.Integer>
>
> In Java 17.0.3, this compiles and works fine and I can't find any
> issue where this was fixed. Is this a class bytecode constraint
> somewhere? My reading of the JLS [2] would suggest the signature
> is mandatory, even if emitted from within that nested class Foo1?
>
> Any pointers would be appreciated!
> Dawid
>
> [1] https://gist.github.com/dweiss/d77452c52daa178e041adce145c2e86a
> [2]
> https://docs.oracle.com/javase/specs/jvms/se11/html/jvms-4.html#jvms-4.7.9.1
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/compiler-dev/attachments/20220615/9aace31c/attachment.htm>
More information about the compiler-dev
mailing list