8159439: javac throws NPE with Module attribute and super_class != 0
Reviewed-by: jjg
This commit is contained in:
parent
396d6f6285
commit
b69fa0a44d
langtools
src/jdk.compiler/share/classes/com/sun/tools/javac
test
@ -50,6 +50,7 @@ import javax.tools.JavaFileObject;
|
|||||||
import javax.tools.JavaFileObject.Kind;
|
import javax.tools.JavaFileObject.Kind;
|
||||||
import javax.tools.StandardLocation;
|
import javax.tools.StandardLocation;
|
||||||
|
|
||||||
|
import com.sun.tools.javac.code.ClassFinder;
|
||||||
import com.sun.tools.javac.code.Directive;
|
import com.sun.tools.javac.code.Directive;
|
||||||
import com.sun.tools.javac.code.Directive.ExportsDirective;
|
import com.sun.tools.javac.code.Directive.ExportsDirective;
|
||||||
import com.sun.tools.javac.code.Directive.RequiresDirective;
|
import com.sun.tools.javac.code.Directive.RequiresDirective;
|
||||||
@ -101,6 +102,8 @@ import static com.sun.tools.javac.code.TypeTag.CLASS;
|
|||||||
|
|
||||||
import com.sun.tools.javac.tree.JCTree.JCDirective;
|
import com.sun.tools.javac.tree.JCTree.JCDirective;
|
||||||
import com.sun.tools.javac.tree.JCTree.Tag;
|
import com.sun.tools.javac.tree.JCTree.Tag;
|
||||||
|
import com.sun.tools.javac.util.Abort;
|
||||||
|
import com.sun.tools.javac.util.Position;
|
||||||
|
|
||||||
import static com.sun.tools.javac.code.Flags.ABSTRACT;
|
import static com.sun.tools.javac.code.Flags.ABSTRACT;
|
||||||
import static com.sun.tools.javac.code.Flags.ENUM;
|
import static com.sun.tools.javac.code.Flags.ENUM;
|
||||||
@ -217,6 +220,9 @@ public class Modules extends JCTree.Visitor {
|
|||||||
for (ModuleSymbol msym: roots) {
|
for (ModuleSymbol msym: roots) {
|
||||||
msym.complete();
|
msym.complete();
|
||||||
}
|
}
|
||||||
|
} catch (CompletionFailure ex) {
|
||||||
|
log.error(JCDiagnostic.DiagnosticFlag.NON_DEFERRABLE, Position.NOPOS, "cant.access", ex.sym, ex.getDetailValue());
|
||||||
|
if (ex instanceof ClassFinder.BadClassFile) throw new Abort();
|
||||||
} finally {
|
} finally {
|
||||||
depth--;
|
depth--;
|
||||||
}
|
}
|
||||||
|
@ -2418,6 +2418,9 @@ public class ClassReader {
|
|||||||
// reset and read rest of classinfo
|
// reset and read rest of classinfo
|
||||||
bp = startbp;
|
bp = startbp;
|
||||||
int n = nextChar();
|
int n = nextChar();
|
||||||
|
if ((flags & MODULE) != 0 && n > 0) {
|
||||||
|
throw badClassFile("module.info.invalid.super.class");
|
||||||
|
}
|
||||||
if (ct.supertype_field == null)
|
if (ct.supertype_field == null)
|
||||||
ct.supertype_field = (n == 0)
|
ct.supertype_field = (n == 0)
|
||||||
? Type.noType
|
? Type.noType
|
||||||
|
@ -1850,6 +1850,9 @@ compiler.misc.bad.module-info.name=\
|
|||||||
compiler.misc.class.file.wrong.class=\
|
compiler.misc.class.file.wrong.class=\
|
||||||
class file contains wrong class: {0}
|
class file contains wrong class: {0}
|
||||||
|
|
||||||
|
compiler.misc.module.info.invalid.super.class=\
|
||||||
|
module-info with invalid super class
|
||||||
|
|
||||||
compiler.misc.class.file.not.found=\
|
compiler.misc.class.file.not.found=\
|
||||||
class file for {0} not found
|
class file for {0} not found
|
||||||
|
|
||||||
|
@ -76,6 +76,7 @@ tools/javac/annotations/typeAnnotations/newlocations/RepeatingTypeAnnotations.ja
|
|||||||
tools/javac/annotations/typeAnnotations/referenceinfos/Lambda.java 8057687 generic-all emit correct byte code an attributes for type annotations
|
tools/javac/annotations/typeAnnotations/referenceinfos/Lambda.java 8057687 generic-all emit correct byte code an attributes for type annotations
|
||||||
tools/javac/annotations/typeAnnotations/referenceinfos/NestedTypes.java 8057687 generic-all emit correct byte code an attributes for type annotations
|
tools/javac/annotations/typeAnnotations/referenceinfos/NestedTypes.java 8057687 generic-all emit correct byte code an attributes for type annotations
|
||||||
tools/javac/warnings/suppress/TypeAnnotations.java 8057683 generic-all improve ordering of errors with type annotations
|
tools/javac/warnings/suppress/TypeAnnotations.java 8057683 generic-all improve ordering of errors with type annotations
|
||||||
|
tools/javac/modules/T8159439/NPEForModuleInfoWithNonZeroSuperClassTest.java 8160396 generic-all current version of jtreg needs a new promotion to include lastes version of ASM
|
||||||
|
|
||||||
###########################################################################
|
###########################################################################
|
||||||
#
|
#
|
||||||
|
@ -120,6 +120,7 @@ compiler.err.locn.cant.get.module.name.for.jar # bad binary ? Inf
|
|||||||
compiler.misc.bad.module-info.name # bad class file
|
compiler.misc.bad.module-info.name # bad class file
|
||||||
compiler.err.locn.bad.module-info # bad class file
|
compiler.err.locn.bad.module-info # bad class file
|
||||||
compiler.err.locn.cant.read.file # bad class file
|
compiler.err.locn.cant.read.file # bad class file
|
||||||
|
compiler.misc.module.info.invalid.super.class # bad class file
|
||||||
compiler.err.locn.cant.read.directory # file system issue
|
compiler.err.locn.cant.read.directory # file system issue
|
||||||
compiler.misc.unnamed.module # fragment uninteresting in and of itself
|
compiler.misc.unnamed.module # fragment uninteresting in and of itself
|
||||||
compiler.misc.kindname.module # fragment uninteresting in and of itself
|
compiler.misc.kindname.module # fragment uninteresting in and of itself
|
||||||
|
9
langtools/test/tools/javac/modules/T8159439/NPEForModuleInfoWithNonZeroSuperClassTest.java
Normal file
9
langtools/test/tools/javac/modules/T8159439/NPEForModuleInfoWithNonZeroSuperClassTest.java
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
/*
|
||||||
|
* @test /nodynamiccopyright/
|
||||||
|
* @bug 8159439
|
||||||
|
* @summary javac throws NPE with Module attribute and super_class != 0
|
||||||
|
* @build module-info
|
||||||
|
* @compile/fail/ref=NPEForModuleInfoWithNonZeroSuperClassTest.out -XDrawDiagnostics NPEForModuleInfoWithNonZeroSuperClassTest.java
|
||||||
|
*/
|
||||||
|
|
||||||
|
class NPEForModuleInfoWithNonZeroSuperClassTest {}
|
2
langtools/test/tools/javac/modules/T8159439/NPEForModuleInfoWithNonZeroSuperClassTest.out
Normal file
2
langtools/test/tools/javac/modules/T8159439/NPEForModuleInfoWithNonZeroSuperClassTest.out
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
- compiler.err.cant.access: mod.module-info, (compiler.misc.bad.class.file.header: module-info.class, (compiler.misc.module.info.invalid.super.class))
|
||||||
|
1 error
|
55
langtools/test/tools/javac/modules/T8159439/module-info.jcod
Normal file
55
langtools/test/tools/javac/modules/T8159439/module-info.jcod
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
module mod {
|
||||||
|
0xCAFEBABE;
|
||||||
|
0; // minor version
|
||||||
|
53; // version
|
||||||
|
[] { // Constant Pool
|
||||||
|
; // first element is empty
|
||||||
|
Utf8 "mod/module-info"; // #1
|
||||||
|
class #1; // #2
|
||||||
|
Utf8 "java/lang/Object"; // #3
|
||||||
|
class #3; // #4
|
||||||
|
Utf8 "java.base"; // #5
|
||||||
|
Utf8 "pkg"; // #6
|
||||||
|
Utf8 "Module"; // #7
|
||||||
|
Utf8 "Version"; // #8
|
||||||
|
Utf8 "6.0"; // #9
|
||||||
|
} // Constant Pool
|
||||||
|
|
||||||
|
0x8000; // access
|
||||||
|
#2;// this_cpx
|
||||||
|
#4;// super_cpx
|
||||||
|
|
||||||
|
[] { // Interfaces
|
||||||
|
} // Interfaces
|
||||||
|
|
||||||
|
[] { // fields
|
||||||
|
} // fields
|
||||||
|
|
||||||
|
[] { // methods
|
||||||
|
} // methods
|
||||||
|
|
||||||
|
[] { // Attributes
|
||||||
|
Attr(#7) { // Module
|
||||||
|
[] { // requires
|
||||||
|
#5 0x8020;
|
||||||
|
} // requires
|
||||||
|
|
||||||
|
[] { // exports
|
||||||
|
#6
|
||||||
|
[] { // to
|
||||||
|
}; // end to
|
||||||
|
} // exports
|
||||||
|
|
||||||
|
[] { // uses
|
||||||
|
} // uses
|
||||||
|
|
||||||
|
[] { // provides
|
||||||
|
} // provides
|
||||||
|
|
||||||
|
} // end Module
|
||||||
|
;
|
||||||
|
Attr(#8) { // Version
|
||||||
|
0x0009;
|
||||||
|
} // end Version
|
||||||
|
} // Attributes
|
||||||
|
} // end module mod
|
Loading…
x
Reference in New Issue
Block a user