-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sync with JVM when opening modules & removed add opens + redo tests
- Loading branch information
Showing
10 changed files
with
196 additions
and
76 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 was deleted.
Oops, something went wrong.
5 changes: 4 additions & 1 deletion
5
.../zone/rong/imaginebreaker/LookupTest.java → ...ong/imaginebreaker/lookup/LookupTest.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
8 changes: 5 additions & 3 deletions
8
.../zone/rong/imaginebreaker/ModuleTest.java → ...ong/imaginebreaker/module/ModuleTest.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
36 changes: 36 additions & 0 deletions
36
src/test/java/zone/rong/imaginebreaker/reflectionfilter/NewFieldReflectionFilterTest.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,36 @@ | ||
package zone.rong.imaginebreaker.reflectionfilter; | ||
|
||
import jdk.internal.reflect.Reflection; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.condition.EnabledForJreRange; | ||
import org.junit.jupiter.api.condition.JRE; | ||
import org.junit.jupiter.api.parallel.Isolated; | ||
import zone.rong.imaginebreaker.ImagineBreaker; | ||
|
||
import java.lang.reflect.Method; | ||
import java.util.Set; | ||
|
||
@Isolated | ||
@EnabledForJreRange(min = JRE.JAVA_12) | ||
public class NewFieldReflectionFilterTest { | ||
|
||
@Test | ||
public void removeFieldFilters() { | ||
ImagineBreaker.openBootModule("java.base"); | ||
registerFieldFilter(); | ||
Assertions.assertThrows(NoSuchFieldException.class, Subject::retrieveSubjectField); | ||
ImagineBreaker.wipeFieldFilters(); | ||
Assertions.assertDoesNotThrow(Subject::retrieveSubjectField); | ||
} | ||
|
||
private void registerFieldFilter() { | ||
try { | ||
Method method = Reflection.class.getDeclaredMethod("registerFieldsToFilter", Class.class, Set.class); | ||
method.invoke(null, Subject.class, Set.of("subjectField")); | ||
} catch (Exception e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
} |
36 changes: 36 additions & 0 deletions
36
src/test/java/zone/rong/imaginebreaker/reflectionfilter/NewMethodReflectionFilterTest.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,36 @@ | ||
package zone.rong.imaginebreaker.reflectionfilter; | ||
|
||
import jdk.internal.reflect.Reflection; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.condition.EnabledForJreRange; | ||
import org.junit.jupiter.api.condition.JRE; | ||
import org.junit.jupiter.api.parallel.Isolated; | ||
import zone.rong.imaginebreaker.ImagineBreaker; | ||
|
||
import java.lang.reflect.Method; | ||
import java.util.Set; | ||
|
||
@Isolated | ||
@EnabledForJreRange(min = JRE.JAVA_12) | ||
public class NewMethodReflectionFilterTest { | ||
|
||
@Test | ||
public void removeMethodFilters() { | ||
ImagineBreaker.openBootModule("java.base"); | ||
registerMethodFilter(); | ||
Assertions.assertThrows(NoSuchMethodException.class, Subject::retrieveSubjectMethod); | ||
ImagineBreaker.wipeMethodFilters(); | ||
Assertions.assertDoesNotThrow(Subject::retrieveSubjectMethod); | ||
} | ||
|
||
private void registerMethodFilter() { | ||
try { | ||
Method method = Reflection.class.getDeclaredMethod("registerMethodsToFilter", Class.class, Set.class); | ||
method.invoke(null, Subject.class, Set.of("subjectMethod")); | ||
} catch (Exception e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
} |
35 changes: 35 additions & 0 deletions
35
src/test/java/zone/rong/imaginebreaker/reflectionfilter/OldFieldReflectionFilterTest.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,35 @@ | ||
package zone.rong.imaginebreaker.reflectionfilter; | ||
|
||
import jdk.internal.reflect.Reflection; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.condition.EnabledForJreRange; | ||
import org.junit.jupiter.api.condition.JRE; | ||
import org.junit.jupiter.api.parallel.Isolated; | ||
import zone.rong.imaginebreaker.ImagineBreaker; | ||
|
||
import java.lang.reflect.Method; | ||
|
||
@Isolated | ||
@EnabledForJreRange(min = JRE.JAVA_9, max = JRE.JAVA_11) | ||
public class OldFieldReflectionFilterTest { | ||
|
||
@Test | ||
public void removeFieldFilters() { | ||
ImagineBreaker.openBootModule("java.base"); | ||
registerFieldFilter(); | ||
Assertions.assertThrows(NoSuchFieldException.class, Subject::retrieveSubjectField); | ||
ImagineBreaker.wipeFieldFilters(); | ||
Assertions.assertDoesNotThrow(Subject::retrieveSubjectField); | ||
} | ||
|
||
private void registerFieldFilter() { | ||
try { | ||
Method method = Reflection.class.getDeclaredMethod("registerFieldsToFilter", Class.class, String[].class); | ||
method.invoke(null, Subject.class, new String[] { "subjectField" }); | ||
} catch (Exception e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
} |
35 changes: 35 additions & 0 deletions
35
src/test/java/zone/rong/imaginebreaker/reflectionfilter/OldMethodReflectionFilterTest.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,35 @@ | ||
package zone.rong.imaginebreaker.reflectionfilter; | ||
|
||
import jdk.internal.reflect.Reflection; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.condition.EnabledForJreRange; | ||
import org.junit.jupiter.api.condition.JRE; | ||
import org.junit.jupiter.api.parallel.Isolated; | ||
import zone.rong.imaginebreaker.ImagineBreaker; | ||
|
||
import java.lang.reflect.Method; | ||
|
||
@Isolated | ||
@EnabledForJreRange(min = JRE.JAVA_9, max = JRE.JAVA_11) | ||
public class OldMethodReflectionFilterTest { | ||
|
||
@Test | ||
public void removeMethodFilters() { | ||
ImagineBreaker.openBootModule("java.base"); | ||
registerMethodFilter(); | ||
Assertions.assertThrows(NoSuchMethodException.class, Subject::retrieveSubjectMethod); | ||
ImagineBreaker.wipeMethodFilters(); | ||
Assertions.assertDoesNotThrow(Subject::retrieveSubjectMethod); | ||
} | ||
|
||
private void registerMethodFilter() { | ||
try { | ||
Method method = Reflection.class.getDeclaredMethod("registerMethodsToFilter", Class.class, String[].class); | ||
method.invoke(null, Subject.class, new String[] { "subjectMethod" }); | ||
} catch (Exception e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
} |
22 changes: 22 additions & 0 deletions
22
src/test/java/zone/rong/imaginebreaker/reflectionfilter/Subject.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,22 @@ | ||
package zone.rong.imaginebreaker.reflectionfilter; | ||
|
||
import java.lang.reflect.Field; | ||
import java.lang.reflect.Method; | ||
|
||
class Subject { | ||
|
||
private static int subjectField = -1; | ||
|
||
private static int subjectMethod() { | ||
return -1; | ||
} | ||
|
||
static Field retrieveSubjectField() throws NoSuchFieldException { | ||
return Subject.class.getDeclaredField("subjectField"); | ||
} | ||
|
||
static Method retrieveSubjectMethod() throws NoSuchMethodException { | ||
return Subject.class.getDeclaredMethod("subjectMethod"); | ||
} | ||
|
||
} |