Access Modifier Issues

Richard Warburton richard.warburton at
Fri Jan 9 14:11:28 UTC 2015

Hi gents,

Not sure if its a high priority to fix the access modifier problems at the
moment, but there still seems to be a bug with Peter Levart's default hack
which I didn't see reported in the other thread.

public class Default<any T> {

    private T value;

    private Default() {}

    public static <any T> T value() {
        return new Default<T>().value;

    public static void main(String[] args) {
        int i = Default.value();
        long l = Default.value();
        Object o = Default.value();


When running:

Specializing method Default$value${0=I}.value()Ljava/lang/Object; with
class=[] and method=[I]
Specializing Default${0=I}; searching for Default.class (not found)
Specializing Default${0=I}; searching for Default.class (found)
Exception in thread "main" java.lang.IllegalAccessError: tried to access
method Default${0=I}.<init>()V from class Default$value${0=I}/793589513
        at Default$value${0=I}/793589513.value(
        at Default.main(

Looks like its workaround-able by making both the constructor and value
field public.

I think this also exposes something I don't understand here. My impression
was that "Default${0=I}" was the specialisation of the class Default s.t.
its first type parameter is an int. So what is "Default$value${0=I}"?


  Richard Warburton
  @RichardWarburto <>

More information about the valhalla-dev mailing list