< prev index next >

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

Print this page


  55             "    }",
  56             "}"
  57         };
  58         return sts;
  59     }
  60 
  61     static String[] getVersion(int version) {
  62         String[] sts = {
  63             "package version;",
  64             "public class Version {",
  65             "    public int getVersion(){ return " + version + "; }",
  66             "}"
  67         };
  68         return sts;
  69     }
  70 
  71     static void writeFile(File file, String... contents) throws Exception {
  72         if (contents == null) {
  73             throw new java.lang.RuntimeException("No input for writing to file" + file);
  74         }

  75         FileOutputStream fos = new FileOutputStream(file);
  76         PrintStream ps = new PrintStream(fos);

  77         for (String str : contents) {
  78             ps.println(str);
  79         }
  80         ps.close();
  81         fos.close();
  82     }
  83 
  84     /* version.jar entries and files:
  85      * META-INF/
  86      * META-INF/MANIFEST.MF
  87      * version/
  88      * version/Main.class
  89      * version/Version.class
  90      * META-INF/versions/
  91      * META-INF/versions/<major-version>/
  92      * META-INF/versions/<major-version>/version/
  93      * META-INF/versions/<major-version>/version/Version.class
  94      */
  95     static void createClassFilesAndJar() throws Exception {
  96         String tempDir = System.getProperty("test.classes");
  97         File baseDir = new File(tempDir + File.separator + "base");
  98         File vDir    = new File(tempDir + File.separator + MAJOR_VERSION_STRING);
  99 
 100         baseDir.mkdirs();
 101         vDir.mkdirs();




  55             "    }",
  56             "}"
  57         };
  58         return sts;
  59     }
  60 
  61     static String[] getVersion(int version) {
  62         String[] sts = {
  63             "package version;",
  64             "public class Version {",
  65             "    public int getVersion(){ return " + version + "; }",
  66             "}"
  67         };
  68         return sts;
  69     }
  70 
  71     static void writeFile(File file, String... contents) throws Exception {
  72         if (contents == null) {
  73             throw new java.lang.RuntimeException("No input for writing to file" + file);
  74         }
  75         try (
  76              FileOutputStream fos = new FileOutputStream(file);
  77              PrintStream ps = new PrintStream(fos)
  78         ) {
  79             for (String str : contents) {
  80                 ps.println(str);
  81             }
  82         }

  83     }
  84 
  85     /* version.jar entries and files:
  86      * META-INF/
  87      * META-INF/MANIFEST.MF
  88      * version/
  89      * version/Main.class
  90      * version/Version.class
  91      * META-INF/versions/
  92      * META-INF/versions/<major-version>/
  93      * META-INF/versions/<major-version>/version/
  94      * META-INF/versions/<major-version>/version/Version.class
  95      */
  96     static void createClassFilesAndJar() throws Exception {
  97         String tempDir = System.getProperty("test.classes");
  98         File baseDir = new File(tempDir + File.separator + "base");
  99         File vDir    = new File(tempDir + File.separator + MAJOR_VERSION_STRING);
 100 
 101         baseDir.mkdirs();
 102         vDir.mkdirs();


< prev index next >