Refine search
@Configuration class AppConfig { @Bean Main mainRunner() { new Main() } }
@Override public ICompilerRequestor getBatchRequestor() { final ICompilerRequestor r = super.getBatchRequestor(); return new ICompilerRequestor() { @Override public void acceptResult(CompilationResult compilationResult) { if (compilationResult.hasErrors()) { for (CategorizedProblem problem:compilationResult.problems) { if (JDTBatchCompiler.this.jdtCompiler != null) { JDTBatchCompiler.this.jdtCompiler.reportProblem(problem); } else { throw new SpoonException(problem.toString()); } } } r.acceptResult(compilationResult); // this is required to complete the compilation and produce the class files } }; }
public static void main(String... args) { Main main = new Main(); main.testMethod(1); } public void testMethod(int i) { testMethod(i); System.out.println(i); }
/** * @deprecated - use {@link BatchCompiler#compile(String, PrintWriter, PrintWriter, CompilationProgress)} instead * e.g. BatchCompiler.compile(commandLine, new PrintWriter(System.out), new PrintWriter(System.err), null); */ public static boolean compile(String commandLine) { return new Main(new PrintWriter(System.out), new PrintWriter(System.err), false /* systemExit */, null /* options */, null /* progress */).compile(tokenize(commandLine)); }
@Override public int run(InputStream in, OutputStream out, OutputStream err, String... arguments) { boolean succeed = new Main( new PrintWriter(new OutputStreamWriter(out != null ? out : System.out)), new PrintWriter(new OutputStreamWriter(err != null ? err : System.err)), true/* systemExit */, null/* options */, null/* progress */).compile(arguments); return succeed ? 0 : -1; } }
protected Main getMain() { return new Main(new PrintWriter(new OutputStreamWriter( System.out)), new PrintWriter(new OutputStreamWriter( errorStream)), false /* systemExit */, null /* options */, null); }
FileSystem environment = getLibraryAccess(); try { this.compilerOptions = new CompilerOptions(this.options); new Compiler( environment, getHandlingPolicy(), this.compilerOptions, getBatchRequestor(), getProblemFactory(), this.out, this.progress); if (checkVMVersion(ClassFileConstants.JDK1_6)) { initializeAnnotationProcessorManager(); if (this.classNames != null) { this.batchCompiler.setBinaryTypes(processClassNames(this.batchCompiler.lookupEnvironment)); if (checkVMVersion(ClassFileConstants.JDK9)) { initRootModules(this.batchCompiler.lookupEnvironment, environment); try { this.logger.startLoggingSources(); this.batchCompiler.compile(getCompilationUnits()); } finally { this.logger.endLoggingSources(); loggingExtraProblems(); this.extraProblems = null;
case readyToCloseEndingWithDestinationPath: state = readyToCloseOrOtherEntry; addNewEntry(paths, currentClasspathName, currentRuleSpecs, customEncoding, currentDestinationPath, isSourceOnly, rejectDestinationPathOnJars); case destinationPathReadyToClose: throw new IllegalArgumentException( this.bind("configure.incorrectDestinationPathEntry", //$NON-NLS-1$ currentPath)); case bracketClosed: if (currentDestinationPath != null) { throw new IllegalArgumentException( this.bind("configure.duplicateDestinationPathEntry", //$NON-NLS-1$ currentPath)); if (currentDestinationPath != null) { throw new IllegalArgumentException( this.bind("configure.accessRuleAfterDestinationPath", //$NON-NLS-1$ currentPath)); case readyToCloseEndingWithRules: case readyToCloseEndingWithDestinationPath: addNewEntry(paths, currentClasspathName, currentRuleSpecs, customEncoding, currentDestinationPath, isSourceOnly, rejectDestinationPathOnJars); addPendingErrors(this.bind("configure.incorrectClasspath", currentPath));//$NON-NLS-1$
/** * @deprecated - use {@link BatchCompiler#compile(String, PrintWriter, PrintWriter, CompilationProgress)} instead * e.g. BatchCompiler.compile(commandLine, outWriter, errWriter, null); */ public static boolean compile(String commandLine, PrintWriter outWriter, PrintWriter errWriter) { return new Main(outWriter, errWriter, false /* systemExit */, null /* options */, null /* progress */).compile(tokenize(commandLine)); }
protected ArrayList<FileSystem.Classpath> handleExtdirs(ArrayList<String> extdirsClasspaths) { final File javaHome = getJavaHome(); for (int i = 0; i < directoriesToCheck.length; i++) directoriesToCheck[i] = new File(extdirsClasspaths.get(i)); File[][] extdirsJars = getLibrariesFiles(directoriesToCheck); if (extdirsJars != null) { for (int i = 0, max = extdirsJars.length; i < max; i++) { addPendingErrors(this.bind( "configure.incorrectExtDirsEntry", //$NON-NLS-1$ directoriesToCheck[i].getAbsolutePath()));
@Override public void multipleClasspathSections(String jarFilePath) { addPendingErrors(bind("configure.multipleClasspathSections", jarFilePath)); //$NON-NLS-1$ } };
/** * */ public void compiling() { printlnOut(this.main.bind("progress.compiling")); //$NON-NLS-1$ } private void endLoggingExtraProblems() {
/** * @deprecated - use {@link #initialize(PrintWriter, PrintWriter, boolean, Map, CompilationProgress)} instead * e.g. initialize(outWriter, errWriter, systemExit, customDefaultOptions, null) */ protected void initialize(PrintWriter outWriter, PrintWriter errWriter, boolean systemExit, Map<String, String> customDefaultOptions) { this.initialize(outWriter, errWriter, systemExit, customDefaultOptions, null /* progress */); } protected void initialize(PrintWriter outWriter, PrintWriter errWriter, boolean systemExit, Map<String, String> customDefaultOptions, CompilationProgress compilationProgress) {
private void addFilesFrom(File javaHome, String propertyName, String defaultPath, ArrayList<File> files) { String extdirsStr = System.getProperty(propertyName); File[] directoriesToCheck = null; if (extdirsStr == null) { if (javaHome != null) { directoriesToCheck = new File[] { new File(javaHome, defaultPath) }; } } else { StringTokenizer tokenizer = new StringTokenizer(extdirsStr, File.pathSeparator); ArrayList<String> paths = new ArrayList<String>(); while (tokenizer.hasMoreTokens()) { paths.add(tokenizer.nextToken()); } if (paths.size() != 0) { directoriesToCheck = new File[paths.size()]; for (int i = 0; i < directoriesToCheck.length; i++) { directoriesToCheck[i] = new File(paths.get(i)); } } } if (directoriesToCheck != null) { addFiles(Main.getLibrariesFiles(directoriesToCheck), files); } }
public static Main m; static{ m = new Main(); m.initialize(); }
@Override public CompilationUnit[] getCompilationUnits() { CompilationUnit[] units = super.getCompilationUnits(); if (!ignoredFiles.isEmpty()) { List<CompilationUnit> l = new ArrayList<CompilationUnit>(); for (CompilationUnit unit : units) { if (!ignoredFiles.contains(new String(unit.getFileName()))) { l.add(unit); } } units = l.toArray(new CompilationUnit[0]); } if (useFactory) { for (int i = 0; i < units.length; i++) { CompilationUnit unit = units[i]; units[i] = new CompilationUnitWrapper(this.jdtCompiler, unit); } } return units; }
/** * @deprecated - use {@link BatchCompiler#compile(String, PrintWriter, PrintWriter, CompilationProgress)} instead * e.g. BatchCompiler.compile(commandLine, new PrintWriter(System.out), new PrintWriter(System.err), null); */ public static boolean compile(String commandLine) { return new Main(new PrintWriter(System.out), new PrintWriter(System.err), false /* systemExit */, null /* options */, null /* progress */).compile(tokenize(commandLine)); }
@Override public int run(InputStream in, OutputStream out, OutputStream err, String... arguments) { boolean succeed = new Main( new PrintWriter(new OutputStreamWriter(out != null ? out : System.out)), new PrintWriter(new OutputStreamWriter(err != null ? err : System.err)), true/* systemExit */, null/* options */, null/* progress */).compile(arguments); return succeed ? 0 : -1; } }
FileSystem environment = getLibraryAccess(); try { this.compilerOptions = new CompilerOptions(this.options); new Compiler( environment, getHandlingPolicy(), this.compilerOptions, getBatchRequestor(), getProblemFactory(), this.out, this.progress); if (checkVMVersion(ClassFileConstants.JDK1_6)) { initializeAnnotationProcessorManager(); if (this.classNames != null) { this.batchCompiler.setBinaryTypes(processClassNames(this.batchCompiler.lookupEnvironment)); if (checkVMVersion(ClassFileConstants.JDK9)) { initRootModules(this.batchCompiler.lookupEnvironment, environment); try { this.logger.startLoggingSources(); this.batchCompiler.compile(getCompilationUnits()); } finally { this.logger.endLoggingSources(); loggingExtraProblems(); this.extraProblems = null;
case readyToCloseEndingWithDestinationPath: state = readyToCloseOrOtherEntry; addNewEntry(paths, currentClasspathName, currentRuleSpecs, customEncoding, currentDestinationPath, isSourceOnly, rejectDestinationPathOnJars); case destinationPathReadyToClose: throw new IllegalArgumentException( this.bind("configure.incorrectDestinationPathEntry", //$NON-NLS-1$ currentPath)); case bracketClosed: if (currentDestinationPath != null) { throw new IllegalArgumentException( this.bind("configure.duplicateDestinationPathEntry", //$NON-NLS-1$ currentPath)); if (currentDestinationPath != null) { throw new IllegalArgumentException( this.bind("configure.accessRuleAfterDestinationPath", //$NON-NLS-1$ currentPath)); case readyToCloseEndingWithRules: case readyToCloseEndingWithDestinationPath: addNewEntry(paths, currentClasspathName, currentRuleSpecs, customEncoding, currentDestinationPath, isSourceOnly, rejectDestinationPathOnJars); addPendingErrors(this.bind("configure.incorrectClasspath", currentPath));//$NON-NLS-1$