more band aid coming - Object methods on 'any' tvars

Richard Warburton richard.warburton at gmail.com
Sat Jan 17 12:36:32 UTC 2015


Hi Maurizio,

I think I've found a bug here. You can't call the object methods on
anyified arrays. Here's a minimal test case and stack trace:

    public static <any T> void fail(T[] values) {
        values[0].toString();
    }

Workaround:

    public static <any T> void fail(T[] values) {
        T value = values[0];
        value.toString();
    }

Javac stacktrace:

java.lang.NullPointerException
        at com.sun.tools.javac.comp.Attr.selectSym(Attr.java:3433)
        at com.sun.tools.javac.comp.Attr.selectSym(Attr.java:3420)
        at com.sun.tools.javac.comp.Attr.visitSelect(Attr.java:3258)
        at
com.sun.tools.javac.tree.JCTree$JCFieldAccess.accept(JCTree.java:2082)
        at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:543)
        at com.sun.tools.javac.comp.Attr.visitApply(Attr.java:1800)
        at
com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1608)
        at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:543)
        at com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:589)
        at com.sun.tools.javac.comp.Attr.visitExec(Attr.java:1568)
        at
com.sun.tools.javac.tree.JCTree$JCExpressionStatement.accept(JCTree.java:1426)
        at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:543)
        at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:609)
        at com.sun.tools.javac.comp.Attr.attribStats(Attr.java:625)
        at com.sun.tools.javac.comp.Attr.visitBlock(Attr.java:1112)
        at com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:994)
        at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:543)
        at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:609)
        at com.sun.tools.javac.comp.Attr.visitMethodDef(Attr.java:997)
        at
com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:843)
        at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:543)
        at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:609)
        at com.sun.tools.javac.comp.Attr.attribClassBody(Attr.java:4404)
        at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4312)
        at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4234)
        at com.sun.tools.javac.comp.Attr.attrib(Attr.java:4209)
        at
com.sun.tools.javac.main.JavaCompiler.attribute(JavaCompiler.java:1230)
        at
com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:872)
        at com.sun.tools.javac.main.Main.compile(Main.java:249)
        at com.sun.tools.javac.main.Main.compile(Main.java:140)
        at com.sun.tools.javac.Main.compile(Main.java:56)
        at com.sun.tools.javac.Main.main(Main.java:42)

regards,

  Richard Warburton

  http://insightfullogic.com
  @RichardWarburto <http://twitter.com/richardwarburto>


More information about the valhalla-dev mailing list