-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
8328649: Disallow enclosing instances for local classes in constructo…
…r prologues Reviewed-by: vromero
- Loading branch information
1 parent
83eba86
commit d80d478
Showing
5 changed files
with
40 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* @test /nodynamiccopyright/ | ||
* @bug 8328649 | ||
* @summary Verify local classes in constructor prologues don't have enclosing instances | ||
* @compile/fail/ref=LocalClassCtorPrologue.out -XDrawDiagnostics LocalClassCtorPrologue.java | ||
* @enablePreview | ||
*/ | ||
|
||
class LocalClassCtorPrologue { | ||
|
||
int x; | ||
|
||
LocalClassCtorPrologue() { | ||
class Local { | ||
{ | ||
x++; // this should fail | ||
} | ||
} | ||
super(); | ||
} | ||
|
||
public class Inner { | ||
public Inner() { | ||
class Local { | ||
{ | ||
x++; // this should work | ||
} | ||
}; | ||
super(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
LocalClassCtorPrologue.java:16:17: compiler.err.no.encl.instance.of.type.in.scope: LocalClassCtorPrologue | ||
- compiler.note.preview.filename: LocalClassCtorPrologue.java, DEFAULT | ||
- compiler.note.preview.recompile | ||
1 error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
d80d478
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review
Issues