8211004: javac is complaining about non-denotable types and refusing to generate the class file
Reviewed-by: jlahoda
This commit is contained in:
parent
844dfb3ab6
commit
456bd1ed1c
src/jdk.compiler/share/classes/com/sun/tools/javac
test/langtools/tools/javac
8203436
diags
generics/diamond/neg
@ -50,9 +50,11 @@ import com.sun.tools.javac.comp.Check.CheckContext;
|
||||
import com.sun.tools.javac.comp.DeferredAttr.AttrMode;
|
||||
import com.sun.tools.javac.comp.MatchBindingsComputer.MatchBindings;
|
||||
import com.sun.tools.javac.jvm.*;
|
||||
|
||||
import static com.sun.tools.javac.resources.CompilerProperties.Fragments.Diamond;
|
||||
import static com.sun.tools.javac.resources.CompilerProperties.Fragments.DiamondInvalidArg;
|
||||
import static com.sun.tools.javac.resources.CompilerProperties.Fragments.DiamondInvalidArgs;
|
||||
|
||||
import com.sun.tools.javac.resources.CompilerProperties.Errors;
|
||||
import com.sun.tools.javac.resources.CompilerProperties.Fragments;
|
||||
import com.sun.tools.javac.resources.CompilerProperties.Warnings;
|
||||
@ -2909,6 +2911,12 @@ public class Attr extends JCTree.Visitor {
|
||||
// ...
|
||||
// }
|
||||
InferenceContext inferenceContext = resultInfo.checkContext.inferenceContext();
|
||||
Type enclType = clazztype.getEnclosingType();
|
||||
if (enclType != null &&
|
||||
enclType.hasTag(CLASS) &&
|
||||
!chk.checkDenotable((ClassType)enclType)) {
|
||||
log.error(tree.encl, Errors.EnclosingClassTypeNonDenotable(enclType));
|
||||
}
|
||||
final boolean isDiamond = TreeInfo.isDiamond(tree);
|
||||
if (isDiamond
|
||||
&& ((tree.constructorType != null && inferenceContext.free(tree.constructorType))
|
||||
|
@ -3912,3 +3912,8 @@ compiler.warn.declared.using.preview=\
|
||||
|
||||
compiler.warn.attempt.to.synchronize.on.instance.of.value.based.class=\
|
||||
attempt to synchronize on an instance of a value-based class
|
||||
|
||||
# 0: type
|
||||
compiler.err.enclosing.class.type.non.denotable=\
|
||||
enclosing class type: {0}\n\
|
||||
is non-denotable, try casting to a denotable type
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* @test /nodynamiccopyright/
|
||||
* @bug 8203436
|
||||
* @bug 8203436 8211004
|
||||
* @summary javac should fail early when emitting illegal signature attributes
|
||||
* @compile/fail/ref=T8203436a.out -XDrawDiagnostics T8203436a.java
|
||||
*/
|
||||
|
@ -1,2 +1,2 @@
|
||||
- compiler.err.cannot.generate.class: compiler.misc.anonymous.class: T8203436a$1, (compiler.misc.illegal.signature: compiler.misc.anonymous.class: T8203436a$1, compiler.misc.type.captureof: 1, ?)
|
||||
T8203436a.java:12:7: compiler.err.enclosing.class.type.non.denotable: T8203436a<compiler.misc.type.captureof: 1, ?>
|
||||
1 error
|
||||
|
@ -1,2 +1,2 @@
|
||||
- compiler.err.cannot.generate.class: compiler.misc.anonymous.class: T8203436b$1, (compiler.misc.illegal.signature: compiler.misc.anonymous.class: T8203436b$1, java.lang.Object&T8203436b.A&T8203436b.B)
|
||||
T8203436b.java:17:10: compiler.err.enclosing.class.type.non.denotable: T8203436b<java.lang.Object&T8203436b.A&T8203436b.B>
|
||||
1 error
|
||||
|
@ -206,3 +206,4 @@ compiler.warn.source.target.conflict
|
||||
compiler.warn.target.default.source.conflict
|
||||
compiler.err.preview.not.latest
|
||||
compiler.err.preview.without.source.or.release
|
||||
compiler.misc.illegal.signature # the compiler can now detect more non-denotable types before class writing
|
||||
|
@ -21,8 +21,7 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
// key: compiler.err.cannot.generate.class
|
||||
// key: compiler.misc.illegal.signature
|
||||
// key: compiler.err.enclosing.class.type.non.denotable
|
||||
|
||||
class IllegalSignature<X> {
|
||||
class Inner { }
|
||||
|
@ -1,2 +1,3 @@
|
||||
Neg21.java:13:9: compiler.err.enclosing.class.type.non.denotable: Neg21<java.lang.Object&java.io.Serializable&java.lang.Cloneable>
|
||||
Neg21.java:13:28: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg21.A), (compiler.misc.diamond.invalid.arg: java.lang.Object&java.io.Serializable&java.lang.Cloneable, (compiler.misc.diamond: Neg21.A))
|
||||
1 error
|
||||
2 errors
|
||||
|
Loading…
x
Reference in New Issue
Block a user