< prev index next >
test/java/lang/Class/getDeclaredField/FieldSetAccessibleTest.java
Print this page
*** 22,31 ****
--- 22,32 ----
*/
import java.io.FilePermission;
import java.io.IOException;
import java.io.UncheckedIOException;
+ import java.lang.module.ModuleFinder;
import java.lang.reflect.AccessibleObject;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.lang.reflect.InaccessibleObjectException;
import java.lang.reflect.ReflectPermission;
*** 44,56 ****
--- 45,59 ----
import java.util.Arrays;
import java.util.Collections;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.List;
+ import java.util.Set;
import java.util.PropertyPermission;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;
+ import java.util.stream.Collectors;
import java.util.stream.Stream;
import jdk.internal.module.Modules;
/**
*** 255,283 ****
static class ClassNameJrtStreamBuilder implements Iterable<String>{
final FileSystem jrt;
final Path root;
ClassNameJrtStreamBuilder() {
jrt = FileSystems.getFileSystem(URI.create("jrt:/"));
root = jrt.getPath("/modules");
}
@Override
public Iterator<String> iterator() {
try {
return Files.walk(root)
.filter(p -> p.getNameCount() > 2)
! .filter(p -> ModuleLayer.boot().findModule(p.getName(1).toString()).isPresent())
.map(p -> p.subpath(2, p.getNameCount()))
.map(p -> p.toString())
.filter(s -> s.endsWith(".class") && !s.endsWith("module-info.class"))
.iterator();
} catch(IOException x) {
throw new UncheckedIOException("Unable to walk \"/modules\"", x);
}
}
}
// Test with or without a security manager
public static enum TestCase {
UNSECURE, SECURE;
--- 258,299 ----
static class ClassNameJrtStreamBuilder implements Iterable<String>{
final FileSystem jrt;
final Path root;
+ final Set<String> modules;
ClassNameJrtStreamBuilder() {
jrt = FileSystems.getFileSystem(URI.create("jrt:/"));
root = jrt.getPath("/modules");
+ modules = systemModules();
}
@Override
public Iterator<String> iterator() {
try {
return Files.walk(root)
.filter(p -> p.getNameCount() > 2)
! .filter(p -> modules.contains(p.getName(1).toString()))
.map(p -> p.subpath(2, p.getNameCount()))
.map(p -> p.toString())
.filter(s -> s.endsWith(".class") && !s.endsWith("module-info.class"))
.iterator();
} catch(IOException x) {
throw new UncheckedIOException("Unable to walk \"/modules\"", x);
}
}
+
+ /*
+ * Filter deployment modules
+ */
+ static Set<String> systemModules() {
+ Set<String> mods = Set.of("javafx.deploy", "jdk.deploy", "jdk.plugin", "jdk.javaws");
+ return ModuleFinder.ofSystem().findAll().stream()
+ .map(mref -> mref.descriptor().name())
+ .filter(mn -> !mods.contains(mn))
+ .collect(Collectors.toSet());
+ }
}
// Test with or without a security manager
public static enum TestCase {
UNSECURE, SECURE;
< prev index next >