langtools/test/tools/javac/api/TestSearchPaths.java
changeset 36526 3b41f1c69604
parent 30730 d3ce7619db2c
equal deleted inserted replaced
36525:4caf88912b7f 36526:3b41f1c69604
     1 /*
     1 /*
     2  * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    94             // javah equivalent
    94             // javah equivalent
    95             testNativeHeaderOutput();
    95             testNativeHeaderOutput();
    96 
    96 
    97             // future-proof: guard against new StandardLocations being added
    97             // future-proof: guard against new StandardLocations being added
    98             if (!tested.equals(EnumSet.allOf(StandardLocation.class))) {
    98             if (!tested.equals(EnumSet.allOf(StandardLocation.class))) {
    99                 error("not all standard locations have been tested");
    99                 // FIXME: need to update for JDK 9 locations
       
   100                 // error("not all standard locations have been tested");
   100                 out.println("not yet tested: " + EnumSet.complementOf(tested));
   101                 out.println("not yet tested: " + EnumSet.complementOf(tested));
   101             }
   102             }
   102 
   103 
   103             if (errors > 0) {
   104             if (errors > 0) {
   104                 throw new Exception(errors + " errors occurred");
   105                 throw new Exception(errors + " errors occurred");
   211         String defaultPathString = sb.toString();
   212         String defaultPathString = sb.toString();
   212 
   213 
   213         setLocation(CLASS_PATH); // empty
   214         setLocation(CLASS_PATH); // empty
   214         setLocation(SOURCE_PATH); // empty
   215         setLocation(SOURCE_PATH); // empty
   215 
   216 
       
   217         // Use -source 8 -target 8 to enable use of platform class path options
   216         // FIXME: temporarily exclude cases referring to default bootclasspath
   218         // FIXME: temporarily exclude cases referring to default bootclasspath
   217         // for (int i = 1; i <= 10; i++) {
   219         // for (int i = 1; i <= 10; i++) {
   218         int[] cases = new int[] { 1, 2, 4, 5, 6, 7 };
   220         int[] cases = new int[] { 1, 2, 4, 5, 6, 7 };
   219         for (int i : cases) {
   221         for (int i : cases) {
   220             File classes = createDir(test + "/" + i + "/classes");
   222             File classes = createDir(test + "/" + i + "/classes");
   229 
   231 
   230             File jar;
   232             File jar;
   231 
   233 
   232             switch (i) {
   234             switch (i) {
   233                 case 1:
   235                 case 1:
   234                     options = getOptions("-d", classes.getPath(), "-Xbootclasspath/p:" + testClasses);
   236                     options = getOptions("-d", classes.getPath(),
       
   237                         "-source", "8", "-target", "8",
       
   238                         "-Xbootclasspath/p:" + testClasses);
   235                     mode = Mode.STARTS_WITH;
   239                     mode = Mode.STARTS_WITH;
   236                     match = Arrays.asList(testClasses);
   240                     match = Arrays.asList(testClasses);
   237                     break;
   241                     break;
   238 
   242 
   239                 case 2:
   243                 case 2:
   240                     // the default values for -extdirs and -endorseddirs come after the bootclasspath;
   244                     // the default values for -extdirs and -endorseddirs come after the bootclasspath;
   241                     // so to check -Xbootclasspath/a: we specify empty values for those options.
   245                     // so to check -Xbootclasspath/a: we specify empty values for those options.
   242                     options = getOptions("-d", classes.getPath(),
   246                     options = getOptions("-d", classes.getPath(),
   243                             "-Xbootclasspath/a:" + testClasses,
   247                         "-source", "8", "-target", "8",
   244                             "-extdirs", "",
   248                         "-Xbootclasspath/a:" + testClasses,
   245                             "-endorseddirs", "");
   249                         "-extdirs", "",
       
   250                         "-endorseddirs", "");
   246                     mode = Mode.ENDS_WITH;
   251                     mode = Mode.ENDS_WITH;
   247                     match = Arrays.asList(testClasses);
   252                     match = Arrays.asList(testClasses);
   248                     break;
   253                     break;
   249 
   254 
   250                 case 3:
   255                 case 3:
   256 
   261 
   257                 case 4:
   262                 case 4:
   258                     fileManager.setLocation(PLATFORM_CLASS_PATH, null);
   263                     fileManager.setLocation(PLATFORM_CLASS_PATH, null);
   259                     jar = new File(testJars, "j" + i + ".jar");
   264                     jar = new File(testJars, "j" + i + ".jar");
   260                     writeJar(jar, testClasses, "C" + i + ".class");
   265                     writeJar(jar, testClasses, "C" + i + ".class");
   261                     options = getOptions("-d", classes.getPath(), "-endorseddirs", testJars.getPath());
   266                     options = getOptions("-d", classes.getPath(),
       
   267                         "-source", "8", "-target", "8",
       
   268                         "-endorseddirs", testJars.getPath());
   262                     mode = Mode.CONTAINS;
   269                     mode = Mode.CONTAINS;
   263                     match = Arrays.asList(jar);
   270                     match = Arrays.asList(jar);
   264                     break;
   271                     break;
   265 
   272 
   266                 case 5:
   273                 case 5:
   267                     fileManager.setLocation(PLATFORM_CLASS_PATH, null);
   274                     fileManager.setLocation(PLATFORM_CLASS_PATH, null);
   268                     jar = new File(testJars, "j" + i + ".jar");
   275                     jar = new File(testJars, "j" + i + ".jar");
   269                     writeJar(jar, testClasses, "C" + i + ".class");
   276                     writeJar(jar, testClasses, "C" + i + ".class");
   270                     options = getOptions("-d", classes.getPath(), "-Djava.endorsed.dirs=" + testJars.getPath());
   277                     options = getOptions("-d", classes.getPath(),
       
   278                         "-source", "8", "-target", "8",
       
   279                         "-Djava.endorsed.dirs=" + testJars.getPath());
   271                     mode = Mode.CONTAINS;
   280                     mode = Mode.CONTAINS;
   272                     match = Arrays.asList(jar);
   281                     match = Arrays.asList(jar);
   273                     break;
   282                     break;
   274 
   283 
   275                 case 6:
   284                 case 6:
   276                     fileManager.setLocation(PLATFORM_CLASS_PATH, null);
   285                     fileManager.setLocation(PLATFORM_CLASS_PATH, null);
   277                     jar = new File(testJars, "j" + i + ".jar");
   286                     jar = new File(testJars, "j" + i + ".jar");
   278                     writeJar(jar, testClasses, "C" + i + ".class");
   287                     writeJar(jar, testClasses, "C" + i + ".class");
   279                     options = getOptions("-d", classes.getPath(), "-extdirs", testJars.getPath());
   288                     options = getOptions("-d", classes.getPath(),
       
   289                         "-source", "8", "-target", "8",
       
   290                         "-extdirs", testJars.getPath());
   280                     mode = Mode.CONTAINS;
   291                     mode = Mode.CONTAINS;
   281                     match = Arrays.asList(jar);
   292                     match = Arrays.asList(jar);
   282                     break;
   293                     break;
   283 
   294 
   284                 case 7:
   295                 case 7:
   285                     fileManager.setLocation(PLATFORM_CLASS_PATH, null);
   296                     fileManager.setLocation(PLATFORM_CLASS_PATH, null);
   286                     jar = new File(testJars, "j" + i + ".jar");
   297                     jar = new File(testJars, "j" + i + ".jar");
   287                     writeJar(jar, testClasses, "C" + i + ".class");
   298                     writeJar(jar, testClasses, "C" + i + ".class");
   288                     options = getOptions("-d", classes.getPath(), "-Djava.ext.dirs=" + testJars.getPath());
   299                     options = getOptions("-d", classes.getPath(),
       
   300                         "-source", "8", "-target", "8",
       
   301                         "-Djava.ext.dirs=" + testJars.getPath());
   289                     mode = Mode.CONTAINS;
   302                     mode = Mode.CONTAINS;
   290                     match = Arrays.asList(jar);
   303                     match = Arrays.asList(jar);
   291                     break;
   304                     break;
   292 
   305 
   293                 case 8:
   306                 case 8:
   297                     match = defaultPath;
   310                     match = defaultPath;
   298                     reference = "";
   311                     reference = "";
   299                     break;
   312                     break;
   300 
   313 
   301                 default:
   314                 default:
   302                     options = getOptions("-d", classes.getPath(), "-bootclasspath", defaultPathString);
   315                     options = getOptions("-d", classes.getPath(),
       
   316                         "-source", "8", "-target", "8",
       
   317                         "-bootclasspath", defaultPathString);
   303                     mode = Mode.EQUALS;
   318                     mode = Mode.EQUALS;
   304                     match = defaultPath;
   319                     match = defaultPath;
   305                     reference = "";
   320                     reference = "";
   306                     break;
   321                     break;
   307             }
   322             }