/*
This file contains a typo, the static qualifier for the block
that initializes foo has been commented out. This causes
a compiler error:
mushmouth% javac StaticTryCatchBug.java
sun.tools.java.CompilerError: copyInline
at sun.tools.tree.TryStatement.copyInline(TryStatement.java)
at sun.tools.tree.CompoundStatement.copyInline(CompoundStatement.java)
at sun.tools.tree.InlineMethodExpression.copyInline(InlineMethodExpression.java)
at sun.tools.tree.MethodExpression.makeVarInits(MethodExpression.java)
at sun.tools.tree.MethodExpression.checkValue(MethodExpression.java)
at sun.tools.tree.MethodExpression.check(MethodExpression.java)
at sun.tools.tree.ExpressionStatement.check(ExpressionStatement.java)
at sun.tools.tree.Statement.checkBlockStatement(Statement.java)
at sun.tools.tree.CompoundStatement.check(CompoundStatement.java)
at sun.tools.tree.Statement.checkMethod(Statement.java)
at sun.tools.javac.SourceField.check(SourceField.java)
at sun.tools.javac.SourceClass.checkFields(SourceClass.java)
at sun.tools.javac.SourceClass.checkInternal(SourceClass.java)
at sun.tools.javac.SourceClass.check(SourceClass.java)
at sun.tools.javac.Main.compile(Main.java)
at sun.tools.javac.Main.main(Main.java)
error: An error has occurred in the compiler; please file a bug report (http://java.sun.com/cgi-bin/bugreport.cgi).
1 error
*/
import java.io.*;
public class StaticTryCatchBug
{
static FileReader foo;
/* static */ {
try {
foo = new FileReader("bar");
}
catch (FileNotFoundException x) {
}
}
public static void main(String[] args) {
}
}
This file contains a typo, the static qualifier for the block
that initializes foo has been commented out. This causes
a compiler error:
mushmouth% javac StaticTryCatchBug.java
sun.tools.java.CompilerError: copyInline
at sun.tools.tree.TryStatement.copyInline(TryStatement.java)
at sun.tools.tree.CompoundStatement.copyInline(CompoundStatement.java)
at sun.tools.tree.InlineMethodExpression.copyInline(InlineMethodExpression.java)
at sun.tools.tree.MethodExpression.makeVarInits(MethodExpression.java)
at sun.tools.tree.MethodExpression.checkValue(MethodExpression.java)
at sun.tools.tree.MethodExpression.check(MethodExpression.java)
at sun.tools.tree.ExpressionStatement.check(ExpressionStatement.java)
at sun.tools.tree.Statement.checkBlockStatement(Statement.java)
at sun.tools.tree.CompoundStatement.check(CompoundStatement.java)
at sun.tools.tree.Statement.checkMethod(Statement.java)
at sun.tools.javac.SourceField.check(SourceField.java)
at sun.tools.javac.SourceClass.checkFields(SourceClass.java)
at sun.tools.javac.SourceClass.checkInternal(SourceClass.java)
at sun.tools.javac.SourceClass.check(SourceClass.java)
at sun.tools.javac.Main.compile(Main.java)
at sun.tools.javac.Main.main(Main.java)
error: An error has occurred in the compiler; please file a bug report (http://java.sun.com/cgi-bin/bugreport.cgi).
1 error
*/
import java.io.*;
public class StaticTryCatchBug
{
static FileReader foo;
/* static */ {
try {
foo = new FileReader("bar");
}
catch (FileNotFoundException x) {
}
}
public static void main(String[] args) {
}
}
- duplicates
-
JDK-4038527 Try-catch in instance initializer causes compiler error.
-
- Closed
-