< prev index next >

test/java/lang/Class/getDeclaredField/FieldSetAccessibleTest.java

Print this page

        

@@ -22,10 +22,11 @@
  */
 
 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,13 +45,15 @@
 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,29 +258,43 @@
 
     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 -> ModuleLayer.boot().findModule(p.getName(1).toString()).isPresent())
+                        .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() {
+            return ModuleFinder.ofSystem().findAll().stream()
+                               .map(mref -> mref.descriptor().name())
+                               .filter(mn -> !mn.contains("deploy") &&
+                                             !mn.contains("plugin") &&
+                                             !mn.contains("javaws"))
+                               .collect(Collectors.toSet());
+        }
     }
 
     // Test with or without a security manager
     public static enum TestCase {
         UNSECURE, SECURE;
< prev index next >