Esempio n. 1
0
 @Test
 public void testJDKModules() {
   Assert.assertTrue(JDKUtils.isJDKModule("java.base"));
   Assert.assertTrue(JDKUtils.isJDKModule("java.desktop"));
   Assert.assertTrue(JDKUtils.isJDKModule("java.compiler")); // last one
   Assert.assertFalse(JDKUtils.isJDKModule("java.stef"));
 }
  // overridden by test subclass
  protected String[] getCeylonProjectClasspath(IJavaProject javaProject) throws JavaModelException {
    final List<String> classpathList = new ArrayList<String>();

    for (CeylonClasspathContainer container : getCeylonClasspathContainers(javaProject)) {
      boolean changed = container.resolveClasspath(new NullProgressMonitor(), false);
      if (changed) {
        container.refreshClasspathContainer(new NullProgressMonitor(), javaProject);
      }
    }

    // add the car files of the output directory
    IProject project = javaProject.getProject();
    Context context = getProjectTypeChecker(project).getContext();

    IPath modulesFolder = getCeylonModulesOutputFolder(project).getLocation();
    classpathList.add(modulesFolder.append("default").append("default.car").toOSString());

    RepositoryManager provider = context.getRepositoryManager();
    Set<Module> modulesToAdd = context.getModules().getListOfModules();
    // modulesToAdd.add(projectModules.getLanguageModule());
    for (Module module : modulesToAdd) {
      String name = module.getNameAsString();
      if (name.equals(Module.DEFAULT_MODULE_NAME)
          || JDKUtils.isJDKModule(name)
          || JDKUtils.isOracleJDKModule(name)
          || !isProjectModule(javaProject, module)) {
        continue;
      }
      IPath modulePath = getModuleArchive(provider, module);
      if (modulePath != null) {
        if (modulePath.toFile().exists()) {
          // if (project.getLocation().isPrefixOf(modulePath)) {
          // if (!classpathList.contains(modulePath.toOSString())) {
          classpathList.add(modulePath.toOSString());
          // }
          // }
        } else {
          System.err.println(
              "ignoring nonexistent module artifact for launch classpath: " + modulePath);
        }
      } else {
        System.err.println(
            "no module archive found for launch classpath: "
                + module.getNameAsString()
                + "/"
                + module.getVersion());
      }
    }

    return classpathList.toArray(new String[classpathList.size()]);
  }
  /**
   * Prints a list of module name, version, path to the given file, to be used by the runtime
   * launcher, because passing it as an argument/environment would easily exceed the OS size limits.
   */
  private void writeModuleInfoFile(File tmpFile, ILaunchConfiguration configuration)
      throws IOException, CoreException {
    FileWriter writer = new FileWriter(tmpFile);
    IJavaProject javaProject = getJavaProject(configuration);
    IProject project = javaProject.getProject();
    Context context = getProjectTypeChecker(project).getContext();

    RepositoryManager provider = context.getRepositoryManager();
    Set<Module> modulesToAdd = context.getModules().getListOfModules();
    boolean seenDefault = false;
    for (Module module : modulesToAdd) {
      String name = module.getNameAsString();
      if (JDKUtils.isJDKModule(name) || JDKUtils.isOracleJDKModule(name)) {
        continue;
      }
      if (module.isDefault()) seenDefault = true;
      IPath modulePath = getModuleArchive(provider, module);
      if (modulePath != null && modulePath.toFile().exists()) {
        String path = modulePath.toOSString();
        System.err.println(
            "Adding module: " + module.getNameAsString() + "/" + module.getVersion() + ": " + path);
        // print module name + NL (+ version + NL)? + path + NL
        writer.append(module.getNameAsString());
        writer.append(System.lineSeparator());
        if (!module.isDefault()) {
          writer.append(module.getVersion());
          writer.append(System.lineSeparator());
        }
        writer.append(path);
        writer.append(System.lineSeparator());
      }
    }
    // for some reason the default module can be missing from the list of modules
    if (!seenDefault) {
      IPath modulesFolder = getCeylonModulesOutputFolder(project).getLocation();
      IPath defaultCar = modulesFolder.append("default").append("default.car");
      if (defaultCar.toFile().exists()) {
        String path = defaultCar.toOSString();
        Module module = context.getModules().getDefaultModule();
        System.err.println("Adding default module: " + module.getNameAsString() + ": " + path);
        // print module name + NL + path + NL
        writer.append(module.getNameAsString());
        writer.append(System.lineSeparator());
        writer.append(path);
        writer.append(System.lineSeparator());
      }
    }
    writer.flush();
    writer.close();
  }
Esempio n. 4
0
 @Test
 public void testOracleJDKPackages() {
   Assert.assertTrue(JDKUtils.isOracleJDKAnyPackage("com.oracle.net"));
   Assert.assertTrue(JDKUtils.isOracleJDKAnyPackage("com.sun.awt"));
   Assert.assertTrue(JDKUtils.isOracleJDKAnyPackage("com.sun.imageio.plugins.bmp"));
   Assert.assertTrue(JDKUtils.isOracleJDKAnyPackage("com.sun.java.swing.plaf.gtk"));
   Assert.assertTrue(JDKUtils.isOracleJDKAnyPackage("com.sun.nio.sctp"));
   Assert.assertTrue(JDKUtils.isOracleJDKAnyPackage("sun.nio"));
   Assert.assertTrue(JDKUtils.isOracleJDKAnyPackage("sunw.util")); // last one
   Assert.assertFalse(JDKUtils.isOracleJDKAnyPackage("fr.epardaud"));
 }
Esempio n. 5
0
 @Test
 public void testJDKPackages() {
   Assert.assertTrue(JDKUtils.isJDKAnyPackage("java.awt"));
   Assert.assertTrue(JDKUtils.isJDKAnyPackage("java.lang"));
   Assert.assertTrue(JDKUtils.isJDKAnyPackage("java.util"));
   Assert.assertTrue(JDKUtils.isJDKAnyPackage("javax.swing"));
   Assert.assertTrue(JDKUtils.isJDKAnyPackage("org.w3c.dom"));
   Assert.assertTrue(JDKUtils.isJDKAnyPackage("org.xml.sax.helpers")); // last one
   Assert.assertFalse(JDKUtils.isJDKAnyPackage("fr.epardaud"));
 }
Esempio n. 6
0
 @Test
 public void testOracleJDKModules() {
   Assert.assertTrue(JDKUtils.isOracleJDKModule("oracle.jdk.base"));
   Assert.assertTrue(JDKUtils.isOracleJDKModule("oracle.jdk.desktop"));
   Assert.assertTrue(JDKUtils.isOracleJDKModule("oracle.jdk.httpserver"));
   Assert.assertTrue(JDKUtils.isOracleJDKModule("oracle.jdk.tools.base")); // last one
   Assert.assertFalse(JDKUtils.isOracleJDKModule("oracle.jdk.stef"));
   Assert.assertFalse(JDKUtils.isOracleJDKModule("jdk.base"));
 }
 static {
   for (String module : JDKUtils.getJDKModuleNames()) JDK_MODULES.add(module);
   for (String module : JDKUtils.getOracleJDKModuleNames()) JDK_MODULES.add(module);
 }