test/hotspot/jtreg/runtime/appcds/OldClassTest.java
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File open Sdiff test/hotspot/jtreg/runtime/appcds

test/hotspot/jtreg/runtime/appcds/OldClassTest.java

Print this page




  50     File jarSrcFile = new File(JarBuilder.getOrCreateHelloJar());
  51 
  52     File dir = new File(System.getProperty("test.classes", "."));
  53     File jarFile = new File(dir, "OldClassTest_old.jar");
  54     String jar = jarFile.getPath();
  55 
  56     if (!jarFile.exists() || jarFile.lastModified() < jarSrcFile.lastModified()) {
  57       createTestJarFile(jarSrcFile, jarFile);
  58     } else {
  59       System.out.println("Already up-to-date: " + jarFile);
  60     }
  61 
  62     String appClasses[] = TestCommon.list("Hello");
  63 
  64     // CASE 1: pre-JDK 1.5 compiled classes should be excluded from the dump
  65     OutputAnalyzer output = TestCommon.dump(jar, appClasses);
  66     TestCommon.checkExecReturn(output, 0, true, "Pre JDK 1.5 class not supported by CDS");
  67 
  68     TestCommon.run(
  69         "-cp", jar,
  70         "-verbose:class",
  71         "Hello")
  72       .assertNormalExit("Hello Unicode world (Old)");
  73 
  74     // CASE 2: if we exlcude old version of this class, we should not pick up
  75     //         the newer version of this class in a subsequent classpath element.
  76     String classpath = jar + File.pathSeparator + jarSrcFile.getPath();
  77     output = TestCommon.dump(classpath, appClasses);
  78     TestCommon.checkExecReturn(output, 0, true, "Pre JDK 1.5 class not supported by CDS");
  79 
  80     TestCommon.run(
  81         "-cp", classpath,
  82         "-verbose:class",
  83         "Hello")
  84       .assertNormalExit("Hello Unicode world (Old)");
  85   }
  86 
  87   static void createTestJarFile(File jarSrcFile, File jarFile) throws Exception {
  88     jarFile.delete();
  89     Files.copy(jarSrcFile.toPath(), jarFile.toPath());
  90 
  91     File dir = new File(System.getProperty("test.classes", "."));
  92     File outdir = new File(dir, "old_class_test_classes");
  93     outdir.delete();
  94     outdir.mkdir();
  95 
  96     writeClassFile(new File(outdir, "Hello.class"), makeOldHello());
  97 
  98     JarBuilder.update(jarFile.getPath(), outdir.getPath());
  99   }
 100 
 101   static void writeClassFile(File file, byte bytecodes[]) throws Exception {
 102     try (FileOutputStream fos = new FileOutputStream(file)) {




  50     File jarSrcFile = new File(JarBuilder.getOrCreateHelloJar());
  51 
  52     File dir = new File(System.getProperty("test.classes", "."));
  53     File jarFile = new File(dir, "OldClassTest_old.jar");
  54     String jar = jarFile.getPath();
  55 
  56     if (!jarFile.exists() || jarFile.lastModified() < jarSrcFile.lastModified()) {
  57       createTestJarFile(jarSrcFile, jarFile);
  58     } else {
  59       System.out.println("Already up-to-date: " + jarFile);
  60     }
  61 
  62     String appClasses[] = TestCommon.list("Hello");
  63 
  64     // CASE 1: pre-JDK 1.5 compiled classes should be excluded from the dump
  65     OutputAnalyzer output = TestCommon.dump(jar, appClasses);
  66     TestCommon.checkExecReturn(output, 0, true, "Pre JDK 1.5 class not supported by CDS");
  67 
  68     TestCommon.run(
  69         "-cp", jar,

  70         "Hello")
  71       .assertNormalExit("Hello Unicode world (Old)");
  72 
  73     // CASE 2: if we exlcude old version of this class, we should not pick up
  74     //         the newer version of this class in a subsequent classpath element.
  75     String classpath = jar + File.pathSeparator + jarSrcFile.getPath();
  76     output = TestCommon.dump(classpath, appClasses);
  77     TestCommon.checkExecReturn(output, 0, true, "Pre JDK 1.5 class not supported by CDS");
  78 
  79     TestCommon.run(
  80         "-cp", classpath,

  81         "Hello")
  82       .assertNormalExit("Hello Unicode world (Old)");
  83   }
  84 
  85   static void createTestJarFile(File jarSrcFile, File jarFile) throws Exception {
  86     jarFile.delete();
  87     Files.copy(jarSrcFile.toPath(), jarFile.toPath());
  88 
  89     File dir = new File(System.getProperty("test.classes", "."));
  90     File outdir = new File(dir, "old_class_test_classes");
  91     outdir.delete();
  92     outdir.mkdir();
  93 
  94     writeClassFile(new File(outdir, "Hello.class"), makeOldHello());
  95 
  96     JarBuilder.update(jarFile.getPath(), outdir.getPath());
  97   }
  98 
  99   static void writeClassFile(File file, byte bytecodes[]) throws Exception {
 100     try (FileOutputStream fos = new FileOutputStream(file)) {


test/hotspot/jtreg/runtime/appcds/OldClassTest.java
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File