Skip to content

Instantly share code, notes, and snippets.

@dweiss
Created June 8, 2022 19:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dweiss/d77452c52daa178e041adce145c2e86a to your computer and use it in GitHub Desktop.
Save dweiss/d77452c52daa178e041adce145c2e86a to your computer and use it in GitHub Desktop.
javac and generic type information lost on jdk11
import java.util.Map;
import java.util.concurrent.Callable;
public class Oddball {
public static void main(String[] args) throws Exception {
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();
r =
new Callable<Void>() {
@Override
public Void call() throws Exception {
class Foo2 {
public Map<String, Integer> field;
}
System.out.println("Foo2.field type: " + Foo2.class.getField("field").getGenericType());
return null;
}
};
r.call();
class Foo3 {
public Map<String, Integer> field;
}
System.out.println("Foo3.field type: " + Foo3.class.getField("field").getGenericType());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment