Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8150051

IllegalArgumentException: path too long for directory fm.setLocationFromPaths(StandardLocation.SYSTEM_MODULES,classes)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • None
    • tools

      Create directory "classes" with exploded module m
      modules/m/module-info.class
      modules/m/p/D.class

      invoke fm.setLocationFromPaths(StandardLocation.SYSTEM_MODULES,classes);

      Exception will be thrown
      java.lang.IllegalArgumentException: path too long for directory
      at com.sun.tools.javac.file.Locations$SystemModulesLocationHandler.setPaths(jdk.compiler@9-internal/Locations.java:1377)
      at com.sun.tools.javac.file.Locations.setLocation(jdk.compiler@9-internal/Locations.java:1548)
      at com.sun.tools.javac.file.JavacFileManager.setLocationFromPaths(jdk.compiler@9-internal/JavacFileManager.java:807)

      JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
              StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null);
              Path modules = base.resolve("modules");
              Path classes = Files.createDirectories(base.resolve("classes"));
              tb.writeJavaFiles(modules.resolve("m"), "module m { }", "package p; public class D { }");
                  tb.new JavacTask()
                          .options("-modulesourcepath",modules.toString())
                          .outdir(classes)
                          .files(modules.resolve("m/p/D.java"))
                          .run();
                  fm.setLocationFromPaths(StandardLocation.SYSTEM_MODULES,classes);

            jjg Jonathan Gibbons
            anazarov Andrey Nazarov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: