AssertionError while trying to print a diagnostic
Raluca Sauciuc
ralucas at google.com
Tue May 14 10:51:52 PDT 2013
Hi compiler-dev,
Martin and I ran into an unexpected javac7 stacktrace, and I think the
following code exposes a bug:
abstract class Formatter<K> {
abstract String format(K value);
static <J> Formatter<Object> fromGetter(final Getter<J> g, final
Formatter<J> f) {
return new Formatter<J>() {
@Override
public String format(Object obj) {
return f.format(g.get(obj));
}
};
}
interface Getter<K> {
K get(Object obj);
}
}
The compiler is trying to print this error message:
error: incompatible types
return new Formatter<J>() {
^
required: Formatter<java.lang.Object>
found: <anonymous Formatter<J>>
but fails instead with the following stacktrace:
java.lang.AssertionError: Missing type variable in where clause J
at com.sun.tools.javac.util**.RichDiagnosticFormatter**.
unique(RichDiagnosticFormatte**r.java:234)
at com.sun.tools.javac.util**.RichDiagnosticFormatter**.
access$100(RichDiagnosticForm**atter.java:67)
at com.sun.tools.javac.util**.RichDiagnosticFormatter**$
RichPrinter.visitTypeVar**(RichDiagnosticFormatter.java**:384)
at com.sun.tools.javac.util**.RichDiagnosticFormatter**$
RichPrinter.visitTypeVar**(RichDiagnosticFormatter.java**:326)
at com.sun.tools.javac.code.Type**$TypeVar.accept(Type.java:1030**)
at com.sun.tools.javac.code**.Printer.visit(Printer.java**:131)
at com.sun.tools.javac.code**.Printer.visitTypes(Printer**.java:103)
at com.sun.tools.javac.code**.Printer.visitClassType**(
Printer.java:194)
at com.sun.tools.javac.util**.RichDiagnosticFormatter**$
RichPrinter.visitClassType**(RichDiagnosticFormatter.java**:366)
at com.sun.tools.javac.util**.RichDiagnosticFormatter**$
RichPrinter.visitClassType**(RichDiagnosticFormatter.java**:326)
at com.sun.tools.javac.code.Type**$ClassType.accept(Type.java**:583)
at com.sun.tools.javac.code**.Printer.visit(Printer.java**:131)
at com.sun.tools.javac.code**.Printer.className(Printer**.java:265)
at com.sun.tools.javac.util**.RichDiagnosticFormatter**$
RichPrinter.className(RichDia**gnosticFormatter.java:374)
at com.sun.tools.javac.code**.Printer.visitClassType**(
Printer.java:190)
at com.sun.tools.javac.util**.RichDiagnosticFormatter**$
RichPrinter.visitClassType**(RichDiagnosticFormatter.java**:366)
at com.sun.tools.javac.util**.RichDiagnosticFormatter**$
RichPrinter.visitClassType**(RichDiagnosticFormatter.java**:326)
at com.sun.tools.javac.code.Type**$ClassType.accept(Type.java**:583)
at com.sun.tools.javac.code**.Printer.visit(Printer.java**:131)
at com.sun.tools.javac.util**.AbstractDiagnosticFormatter**.
formatArgument(AbstractDiagno**sticFormatter.java:187)
at com.sun.tools.javac.util**.AbstractDiagnosticFormatter**.
formatArguments(AbstractDiagn**osticFormatter.java:158)
at com.sun.tools.javac.util**.BasicDiagnosticFormatter**.
formatMessage(BasicDiagnostic**Formatter.java:111)
at com.sun.tools.javac.util**.BasicDiagnosticFormatter**.
formatMeta(BasicDiagnosticFor**matter.java:184)
at com.sun.tools.javac.util**.BasicDiagnosticFormatter**.
formatDiagnostic(BasicDiagnos**ticFormatter.java:100)
at com.sun.tools.javac.util**.AbstractDiagnosticFormatter**.
format(AbstractDiagnosticForm**atter.java:114)
at com.sun.tools.javac.util**.RichDiagnosticFormatter**.
format(RichDiagnosticFormatte**r.java:112)
at com.sun.tools.javac.util**.RichDiagnosticFormatter**.
format(RichDiagnosticFormatte**r.java:67)
at com.sun.tools.javac.util.Log**.writeDiagnostic(Log.java:434)
at com.sun.tools.javac.util.Log**.report(Log.java:416)
at com.sun.tools.javac.util**.AbstractLog.error(AbstractLog**.
java:94)
at com.sun.tools.javac.comp.Check**.typeError(Check.java:269)
at com.sun.tools.javac.comp.Check**.checkType(Check.java:452)
at com.sun.tools.javac.comp.Attr**.check(Attr.java:203)
at com.sun.tools.javac.comp.Attr**.visitNewClass(Attr.java:1817)
at com.sun.tools.javac.tree**.JCTree$JCNewClass.accept**(
JCTree.java:1372)
at com.sun.tools.javac.comp.Attr**.attribTree(Attr.java:431)
at com.sun.tools.javac.comp.Attr**.attribTree(Attr.java:418)
at com.sun.tools.javac.comp.Attr**.attribExpr(Attr.java:449)
at com.sun.tools.javac.comp.Attr**.visitReturn(Attr.java:1384)
at com.sun.tools.javac.tree**.JCTree$JCReturn.accept(JCTree**.
java:1240)
at com.sun.tools.javac.comp.Attr**.attribTree(Attr.java:431)
at com.sun.tools.javac.comp.Attr**.attribTree(Attr.java:418)
at com.sun.tools.javac.comp.Attr**.attribStat(Attr.java:480)
at com.sun.tools.javac.comp.Attr**.attribStats(Attr.java:496)
at com.sun.tools.javac.comp.Attr**.visitBlock(Attr.java:911)
at com.sun.tools.javac.tree**.JCTree$JCBlock.accept(JCTree**.
java:781)
at com.sun.tools.javac.comp.Attr**.attribTree(Attr.java:431)
at com.sun.tools.javac.comp.Attr**.attribTree(Attr.java:418)
at com.sun.tools.javac.comp.Attr**.attribStat(Attr.java:480)
at com.sun.tools.javac.comp.Attr**.visitMethodDef(Attr.java:829)
at com.sun.tools.javac.tree**.JCTree$JCMethodDecl.accept**(
JCTree.java:669)
at com.sun.tools.javac.comp.Attr**.attribTree(Attr.java:431)
at com.sun.tools.javac.comp.Attr**.attribTree(Attr.java:418)
at com.sun.tools.javac.comp.Attr**.attribStat(Attr.java:480)
at com.sun.tools.javac.comp.Attr**.attribClassBody(Attr.java**:3254)
at com.sun.tools.javac.comp.Attr**.attribClass(Attr.java:3177)
at com.sun.tools.javac.comp.Attr**.attribClass(Attr.java:3133)
at com.sun.tools.javac.comp.Attr**.attribClass(Attr.java:3113)
at com.sun.tools.javac.comp.Attr**.visitClassDef(Attr.java:701)
at com.sun.tools.javac.tree**.JCTree$JCClassDecl.accept**(
JCTree.java:591)
at com.sun.tools.javac.comp.Attr**.attribTree(Attr.java:431)
at com.sun.tools.javac.comp.Attr**.attribTree(Attr.java:418)
at com.sun.tools.javac.comp.Attr**.attribStat(Attr.java:480)
at com.sun.tools.javac.comp.Attr**.visitNewClass(Attr.java:1781)
at com.sun.tools.javac.tree**.JCTree$JCNewClass.accept**(
JCTree.java:1372)
at com.sun.tools.javac.comp.Attr**.attribTree(Attr.java:431)
at com.sun.tools.javac.comp.Attr**.attribTree(Attr.java:418)
at com.sun.tools.javac.comp.Attr**.attribArgs(Attr.java:504)
at com.sun.tools.javac.comp.Attr**.visitNewClass(Attr.java:1647)
at com.sun.tools.javac.tree**.JCTree$JCNewClass.accept**(
JCTree.java:1372)
at com.sun.tools.javac.comp.Attr**.attribTree(Attr.java:431)
at com.sun.tools.javac.comp.Attr**.attribTree(Attr.java:418)
at com.sun.tools.javac.comp.Attr**.attribExpr(Attr.java:449)
at com.sun.tools.javac.comp.Attr**.visitVarDef(Attr.java:880)
at com.sun.tools.javac.tree**.JCTree$JCVariableDecl.accept**(
JCTree.java:725)
at com.sun.tools.javac.comp.Attr**.attribTree(Attr.java:431)
at com.sun.tools.javac.comp.Attr**.attribTree(Attr.java:418)
at com.sun.tools.javac.comp.Attr**.attribStat(Attr.java:480)
at com.sun.tools.javac.comp.Attr**.attribStats(Attr.java:496)
at com.sun.tools.javac.comp.Attr**.visitBlock(Attr.java:911)
at com.sun.tools.javac.tree**.JCTree$JCBlock.accept(JCTree**.
java:781)
at com.sun.tools.javac.comp.Attr**.attribTree(Attr.java:431)
at com.sun.tools.javac.comp.Attr**.attribTree(Attr.java:418)
at com.sun.tools.javac.comp.Attr**.attribStat(Attr.java:480)
at com.sun.tools.javac.comp.Attr**.visitMethodDef(Attr.java:829)
at com.sun.tools.javac.tree**.JCTree$JCMethodDecl.accept**(
JCTree.java:669)
at com.sun.tools.javac.comp.Attr**.attribTree(Attr.java:431)
at com.sun.tools.javac.comp.Attr**.attribTree(Attr.java:418)
at com.sun.tools.javac.comp.Attr**.attribStat(Attr.java:480)
at com.sun.tools.javac.comp.Attr**.attribClassBody(Attr.java**:3254)
at com.sun.tools.javac.comp.Attr**.attribClass(Attr.java:3177)
at com.sun.tools.javac.comp.Attr**.attribClass(Attr.java:3113)
at com.sun.tools.javac.comp.Attr**.attrib(Attr.java:3087)
at com.sun.tools.javac.main**.JavaCompiler.attribute**(
JavaCompiler.java:1184)
at com.sun.tools.javac.main**.JavaCompiler.compile2(JavaCom**p
iler.java:870)
at com.sun.tools.javac.main**.JavaCompiler.compile(JavaComp**i
ler.java:829)
at com.sun.tools.javac.main.Main**.compile(Main.java:439)
at com.sun.tools.javac.main.Main**.compile(Main.java:353)
at com.sun.tools.javac.main.Main**.compile(Main.java:342)
at com.sun.tools.javac.main.Main**.compile(Main.java:333)
at com.sun.tools.javac.Main**.compile(Main.java:76)
at com.sun.tools.javac.Main.main**(Main.java:61)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20130514/1d8b42e9/attachment-0001.html
More information about the compiler-dev
mailing list