Generic type information for classes within closures not emitted by javac 11.0.15

Dawid Weiss dawid.weiss at
Wed Jun 8 20:08:14 UTC 2022

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: " +
          return null;

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!

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the compiler-dev mailing list