8282160: JShell circularly-required classes cannot be defined
Reviewed-by: vromero
This commit is contained in:
parent
d5ae3833b1
commit
11fa03f3ee
src/jdk.jshell/share/classes/jdk/jshell
test/langtools/jdk/jshell
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -131,6 +131,13 @@ public abstract class Diag {
|
||||
return getCode().equals("compiler.err.not.stmt");
|
||||
}
|
||||
|
||||
/**
|
||||
* This is a method does not override superclass error
|
||||
*/
|
||||
boolean isOverrideError() {
|
||||
return getCode().equals("compiler.err.method.does.not.override.superclass");
|
||||
}
|
||||
|
||||
/**
|
||||
* This is a resolution error.
|
||||
*/
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -40,6 +40,7 @@ final class DiagList extends ArrayList<Diag> {
|
||||
private int cntNotStmt = 0;
|
||||
private int cntUnreach = 0;
|
||||
private int cntResolve = 0;
|
||||
private int cntOverride = 0;
|
||||
private int cntOther = 0;
|
||||
|
||||
DiagList() {
|
||||
@ -64,6 +65,8 @@ final class DiagList extends ArrayList<Diag> {
|
||||
++cntNotStmt;
|
||||
} else if (d.isResolutionError()) {
|
||||
++cntResolve;
|
||||
} else if (d.isOverrideError()) {
|
||||
++cntOverride;
|
||||
} else {
|
||||
++cntOther;
|
||||
}
|
||||
@ -114,7 +117,7 @@ final class DiagList extends ArrayList<Diag> {
|
||||
}
|
||||
|
||||
boolean hasErrors() {
|
||||
return (cntNotStmt + cntResolve + cntUnreach + cntOther) > 0;
|
||||
return (cntNotStmt + cntResolve + cntUnreach + cntOverride + cntOther) > 0;
|
||||
}
|
||||
|
||||
boolean hasResolutionErrorsAndNoOthers() {
|
||||
@ -130,7 +133,7 @@ final class DiagList extends ArrayList<Diag> {
|
||||
}
|
||||
|
||||
boolean hasOtherThanNotStatementErrors() {
|
||||
return (cntResolve + cntUnreach + cntOther) > 0;
|
||||
return (cntResolve + cntUnreach + cntOverride + cntOther) > 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -23,7 +23,7 @@
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8145239 8129559 8080354 8189248 8010319 8246353 8247456
|
||||
* @bug 8145239 8129559 8080354 8189248 8010319 8246353 8247456 8282160
|
||||
* @summary Tests for EvaluationState.classes
|
||||
* @build KullaTesting TestingInputStream ExpectedDiagnostic
|
||||
* @run testng ClassesTest
|
||||
@ -342,4 +342,22 @@ public class ClassesTest extends KullaTesting {
|
||||
assertEval("new A()");
|
||||
}
|
||||
|
||||
public void testCircular8282160() {
|
||||
TypeDeclSnippet classKey = classKey(assertEval("""
|
||||
class B {
|
||||
C c;
|
||||
public void run() {}
|
||||
}
|
||||
""",
|
||||
added(RECOVERABLE_NOT_DEFINED)));
|
||||
assertEval("""
|
||||
class C extends B {
|
||||
@Override
|
||||
public void run() {}
|
||||
}
|
||||
""",
|
||||
added(VALID),
|
||||
ste(classKey, Status.RECOVERABLE_NOT_DEFINED, Status.VALID, true, null));
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user