-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix ATs to classes with implicit constructors and add more validation (…
…#21) --------- Co-authored-by: Sebastian Hartte <[email protected]>
- Loading branch information
1 parent
5816c51
commit 0c5eb12
Showing
21 changed files
with
238 additions
and
22 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
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
public class C1 { | ||
|
||
C1() {} | ||
} |
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 |
---|---|---|
@@ -1,3 +1,2 @@ | ||
class C1 { | ||
|
||
} |
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,2 @@ | ||
public AnEnum <init>(Ljava/lang/String;IZ)V # This is invalid, we cannot widen the access of an enum ctor past package | ||
default AnEnum <init>(Ljava/lang/String;II)V # Useless, but valid |
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 @@ | ||
Access transformer PUBLIC LEAVE {atpath}:1 targeting constructor of AnEnum attempted to make an enum constructor PUBLIC |
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,11 @@ | ||
public enum AnEnum { | ||
; | ||
|
||
AnEnum(int i) { | ||
|
||
} | ||
|
||
AnEnum(boolean ok) { | ||
|
||
} | ||
} |
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,11 @@ | ||
public enum AnEnum { | ||
; | ||
|
||
private AnEnum(int i) { | ||
|
||
} | ||
|
||
AnEnum(boolean ok) { | ||
|
||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
tests/data/accesstransformer/implicit_constructors/accesstransformer.cfg
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,15 @@ | ||
protected PrivateClass <init>()V # Should create a protected constructor | ||
default PrivateClass$NestedProtected <init>()V # Should not cause any change, as default < protected | ||
public TestPrivateCtor # Should create a default constructor | ||
|
||
# Should only change the class to public since the implicit constructor is expected to have the same access level | ||
public PrivateClass$Both | ||
public PrivateClass$Both <init>()V | ||
|
||
public PrivateRecord # Error because the ctor needs to be AT'd too | ||
|
||
public PrivateRecord$Nested | ||
public PrivateRecord$Nested <init>(I)V | ||
|
||
protected PrivateClass$Inner # Make the class itself protected | ||
public PrivateClass$Inner <init>(LPrivateClass;)V # and the constructor public |
1 change: 1 addition & 0 deletions
1
tests/data/accesstransformer/implicit_constructors/expected.log
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 @@ | ||
Access transformer PUBLIC LEAVE {atpath}:9 targeting record class PrivateRecord attempts to widen its access without widening the constructor's access. You must AT the constructor too: "public PrivateRecord <init>(I)V" |
16 changes: 16 additions & 0 deletions
16
tests/data/accesstransformer/implicit_constructors/expected/PrivateClass.java
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,16 @@ | ||
private class PrivateClass { | ||
protected PrivateClass() {} | ||
|
||
protected static class NestedProtected { | ||
|
||
} | ||
|
||
public static class Both { | ||
|
||
} | ||
|
||
protected class Inner { | ||
public Inner() {} | ||
|
||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
tests/data/accesstransformer/implicit_constructors/expected/PrivateRecord.java
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,5 @@ | ||
public record PrivateRecord(int a) { | ||
public record Nested(int b) { | ||
|
||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
tests/data/accesstransformer/implicit_constructors/expected/TestPrivateCtor.java
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 @@ | ||
public class TestPrivateCtor { | ||
TestPrivateCtor() {} | ||
|
||
} |
14 changes: 14 additions & 0 deletions
14
tests/data/accesstransformer/implicit_constructors/source/PrivateClass.java
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,14 @@ | ||
private class PrivateClass { | ||
|
||
protected static class NestedProtected { | ||
|
||
} | ||
|
||
protected static class Both { | ||
|
||
} | ||
|
||
private class Inner { | ||
|
||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
tests/data/accesstransformer/implicit_constructors/source/PrivateRecord.java
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,5 @@ | ||
private record PrivateRecord(int a) { | ||
private record Nested(int b) { | ||
|
||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
tests/data/accesstransformer/implicit_constructors/source/TestPrivateCtor.java
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,3 @@ | ||
class TestPrivateCtor { | ||
|
||
} |
Oops, something went wrong.