mirror of
https://github.com/darlinghq/darling-openjdk.git
synced 2024-11-23 12:29:56 +00:00
8213725: JShell NullPointerException due to class file with unexpected package
Reviewed-by: jlahoda
This commit is contained in:
parent
4dfa364ff1
commit
020877da03
@ -327,7 +327,7 @@ class Eval {
|
||||
String initCode = rinit.part(compileSource);
|
||||
ExpressionInfo ei =
|
||||
ExpressionToTypeInfo.localVariableTypeForInitializer(initCode, state, false);
|
||||
if (ei != null) {
|
||||
if (ei != null && ei.declareTypeName != null) {
|
||||
typeName = ei.declareTypeName;
|
||||
fullTypeName = ei.fullTypeName;
|
||||
displayType = ei.displayTypeName;
|
||||
|
@ -737,7 +737,7 @@ public class KullaTesting {
|
||||
expectedSubKind, unressz, othersz);
|
||||
String signature = var.typeName();
|
||||
assertEquals(signature, expectedTypeName,
|
||||
"Expected " + var.source() + " to have the name: " +
|
||||
"Expected " + var.source() + " to have the type name: " +
|
||||
expectedTypeName + ", got: " + signature);
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8144903 8177466 8191842 8211694
|
||||
* @bug 8144903 8177466 8191842 8211694 8213725
|
||||
* @summary Tests for EvaluationState.variables
|
||||
* @library /tools/lib
|
||||
* @modules jdk.compiler/com.sun.tools.javac.api
|
||||
@ -492,6 +492,21 @@ public class VariablesTest extends KullaTesting {
|
||||
assertVarDeclRedefNoInit("String", "s", "\"hi\"", "null");
|
||||
}
|
||||
|
||||
public void badPkgVarDecl() {
|
||||
Compiler compiler = new Compiler();
|
||||
Path nopkgdirpath = Paths.get("cp", "xyz");
|
||||
compiler.compile(nopkgdirpath,
|
||||
"public class TestZ { public static int V = 0; }\n");
|
||||
assertDeclareFail("import static xyz.TestZ.V;",
|
||||
"compiler.err.cant.access");
|
||||
|
||||
|
||||
VarSnippet v1 = varKey(assertEval("var v = xyz.TestZ.V;", IGNORE_VALUE, null,
|
||||
DiagCheck.DIAG_ERROR, DiagCheck.DIAG_OK, added(RECOVERABLE_NOT_DEFINED)));
|
||||
assertVariableDeclSnippet(v1, "v", "java.lang.Object", RECOVERABLE_NOT_DEFINED, SubKind.VAR_DECLARATION_WITH_INITIALIZER_SUBKIND, 0, 1);
|
||||
assertEval("1+1", "2");
|
||||
}
|
||||
|
||||
private void assertVarDeclRedefNoInit(String typeName, String name, String value, String dvalue) {
|
||||
assertVarDeclRedefNoInit(typeName, name, value, value, dvalue);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user