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

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Sat Jan 17 21:34:13 UTC 2015


Thanks for the report; I will fix this.

Maurizio

On 17/01/15 13:00, Richard Warburton wrote:
> Hi,
>
> Actually it appears to be that you can't call the object method on any 
> expression that's more complex that referencing a variable. Eg:
>
>     public static <any T> void fail(T[] values) {
>         get(values).toString();
>     }
>
>     public static <any T> T get(T[] values) {
>         return values[0];
>     }
>
> Also NPEs.
>
>
> On Sat, Jan 17, 2015 at 12:36 PM, Richard Warburton 
> <richard.warburton at gmail.com <mailto:richard.warburton at gmail.com>> wrote:
>
>     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>
>
>
>
>
> -- 
> regards,
>
>   Richard Warburton
>
> http://insightfullogic.com
> @RichardWarburto <http://twitter.com/richardwarburto>



More information about the valhalla-dev mailing list