< prev index next >

test/jdk/tools/jlink/plugins/StripDebugPluginTest.java

Print this page
rev 51977 : [mq]: 8211350-no-jprt


  51 import com.sun.tools.classfile.Attribute;
  52 import com.sun.tools.classfile.ClassFile;
  53 import com.sun.tools.classfile.Code_attribute;
  54 import com.sun.tools.classfile.ConstantPoolException;
  55 import com.sun.tools.classfile.Method;
  56 import java.util.HashMap;
  57 import java.util.Map;
  58 import jdk.tools.jlink.internal.ResourcePoolManager;
  59 import jdk.tools.jlink.internal.plugins.StripDebugPlugin;
  60 import jdk.tools.jlink.plugin.ResourcePoolEntry;
  61 import jdk.tools.jlink.plugin.ResourcePool;
  62 import jdk.tools.jlink.plugin.Plugin;
  63 import tests.Helper;
  64 
  65 public class StripDebugPluginTest {
  66     public static void main(String[] args) throws Exception {
  67         new StripDebugPluginTest().test();
  68     }
  69 
  70     public void test() throws Exception {
  71         // JPRT not yet ready for jmods
  72         Helper helper = Helper.newHelper();
  73         if (helper == null) {
  74             System.err.println("Test not run, NO jmods directory");
  75             return;
  76         }
  77 
  78         List<String> classes = Arrays.asList("toto.Main", "toto.com.foo.bar.X");
  79         Path moduleFile = helper.generateModuleCompiledClasses(
  80                 helper.getJmodSrcDir(), helper.getJmodClassesDir(), "leaf1", classes);
  81         Path moduleInfo = moduleFile.resolve("module-info.class");
  82 
  83         // Classes have been compiled in debug.
  84         List<Path> covered = new ArrayList<>();
  85         byte[] infoContent = Files.readAllBytes(moduleInfo);
  86         try (Stream<Path> stream = Files.walk(moduleFile)) {
  87             for (Iterator<Path> iterator = stream.iterator(); iterator.hasNext(); ) {
  88                 Path p = iterator.next();
  89                 if (Files.isRegularFile(p) && p.toString().endsWith(".class")) {
  90                     byte[] content = Files.readAllBytes(p);
  91                     String path = "/" + helper.getJmodClassesDir().relativize(p).toString();
  92                     String moduleInfoPath = path + "/module-info.class";
  93                     check(path, content, moduleInfoPath, infoContent);
  94                     covered.add(p);
  95                 }
  96             }




  51 import com.sun.tools.classfile.Attribute;
  52 import com.sun.tools.classfile.ClassFile;
  53 import com.sun.tools.classfile.Code_attribute;
  54 import com.sun.tools.classfile.ConstantPoolException;
  55 import com.sun.tools.classfile.Method;
  56 import java.util.HashMap;
  57 import java.util.Map;
  58 import jdk.tools.jlink.internal.ResourcePoolManager;
  59 import jdk.tools.jlink.internal.plugins.StripDebugPlugin;
  60 import jdk.tools.jlink.plugin.ResourcePoolEntry;
  61 import jdk.tools.jlink.plugin.ResourcePool;
  62 import jdk.tools.jlink.plugin.Plugin;
  63 import tests.Helper;
  64 
  65 public class StripDebugPluginTest {
  66     public static void main(String[] args) throws Exception {
  67         new StripDebugPluginTest().test();
  68     }
  69 
  70     public void test() throws Exception {

  71         Helper helper = Helper.newHelper();




  72 
  73         List<String> classes = Arrays.asList("toto.Main", "toto.com.foo.bar.X");
  74         Path moduleFile = helper.generateModuleCompiledClasses(
  75                 helper.getJmodSrcDir(), helper.getJmodClassesDir(), "leaf1", classes);
  76         Path moduleInfo = moduleFile.resolve("module-info.class");
  77 
  78         // Classes have been compiled in debug.
  79         List<Path> covered = new ArrayList<>();
  80         byte[] infoContent = Files.readAllBytes(moduleInfo);
  81         try (Stream<Path> stream = Files.walk(moduleFile)) {
  82             for (Iterator<Path> iterator = stream.iterator(); iterator.hasNext(); ) {
  83                 Path p = iterator.next();
  84                 if (Files.isRegularFile(p) && p.toString().endsWith(".class")) {
  85                     byte[] content = Files.readAllBytes(p);
  86                     String path = "/" + helper.getJmodClassesDir().relativize(p).toString();
  87                     String moduleInfoPath = path + "/module-info.class";
  88                     check(path, content, moduleInfoPath, infoContent);
  89                     covered.add(p);
  90                 }
  91             }


< prev index next >