mirror of
https://github.com/openjdk/jdk.git
synced 2026-07-28 03:43:21 +00:00
8332236: javac crashes with module imports and implicitly declared class
Reviewed-by: vromero
This commit is contained in:
parent
4e77cf881d
commit
d04ac14bdb
@ -4118,7 +4118,7 @@ public class JavacParser implements Parser {
|
||||
for (JCTree def : origDefs) {
|
||||
if (def.hasTag(Tag.PACKAGEDEF)) {
|
||||
log.error(def.pos(), Errors.ImplicitClassShouldNotHavePackageDeclaration);
|
||||
} else if (def.hasTag(Tag.IMPORT)) {
|
||||
} else if (def.hasTag(Tag.IMPORT) || def.hasTag(Tag.MODULEIMPORT)) {
|
||||
topDefs.append(def);
|
||||
} else if (!def.hasTag(Tag.SKIP)) {
|
||||
defs.append(def);
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @bug 8328481
|
||||
* @bug 8328481 8332236
|
||||
* @summary Check behavior of module imports.
|
||||
* @library /tools/lib
|
||||
* @modules java.logging
|
||||
@ -719,4 +719,26 @@ public class ImportModule extends TestRunner {
|
||||
.writeAll();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testImplicitlyDeclaredClass(Path base) throws Exception {
|
||||
Path current = base.resolve(".");
|
||||
Path src = current.resolve("src");
|
||||
Path classes = current.resolve("classes");
|
||||
tb.writeFile(src.resolve("Test.java"),
|
||||
"""
|
||||
import module java.base;
|
||||
void main() {
|
||||
}
|
||||
""");
|
||||
|
||||
Files.createDirectories(classes);
|
||||
|
||||
new JavacTask(tb)
|
||||
.options("--enable-preview", "--release", SOURCE_VERSION)
|
||||
.outdir(classes)
|
||||
.files(tb.findJavaFiles(src))
|
||||
.run(Task.Expect.SUCCESS)
|
||||
.writeAll();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user