/** Compile the servlet from .java file to .class file */ private void generateClass() throws FileNotFoundException, JasperException, Exception { long t1 = 0; if (log.isLoggable(Level.FINE)) { t1 = System.currentTimeMillis(); } String javaFileName = ctxt.getServletJavaFileName(); String classpath = ctxt.getClassPath(); String sep = System.getProperty("path.separator"); // Initializing classpath ArrayList<File> cpath = new ArrayList<File>(); HashSet<String> paths = new HashSet<String>(); // Process classpath, which includes system classpath from compiler // options, plus the context classpath from the classloader String sysClassPath = options.getSystemClassPath(); if (sysClassPath != null) { StringTokenizer tokenizer = new StringTokenizer(sysClassPath, sep); while (tokenizer.hasMoreElements()) { String path = tokenizer.nextToken(); if (!paths.contains(path) && !systemJarInWebinf(path)) { paths.add(path); cpath.add(new File(path)); } } } if (classpath != null) { StringTokenizer tokenizer = new StringTokenizer(classpath, sep); while (tokenizer.hasMoreElements()) { String path = tokenizer.nextToken(); if (!paths.contains(path) && !systemJarInWebinf(path)) { paths.add(path); cpath.add(new File(path)); } } } if (log.isLoggable(Level.FINE)) { log.fine("Using classpath: " + sysClassPath + sep + classpath); } javaCompiler.setClassPath(cpath); // Set debug info javaCompiler.setDebug(options.getClassDebugInfo()); // Initialize and set java extensions String exts = System.getProperty("java.ext.dirs"); if (exts != null) { javaCompiler.setExtdirs(exts); } if (options.getCompilerTargetVM() != null) { javaCompiler.setTargetVM(options.getCompilerTargetVM()); } if (options.getCompilerSourceVM() != null) { javaCompiler.setSourceVM(options.getCompilerSourceVM()); } // Start java compilation JavacErrorDetail[] javacErrors = javaCompiler.compile(ctxt.getFullClassName(), pageNodes); if (javacErrors != null) { // If there are errors, always generate java files to disk. javaCompiler.doJavaFile(true); log.severe("Error compiling file: " + javaFileName); errDispatcher.javacError(javacErrors); } if (log.isLoggable(Level.FINE)) { long t2 = System.currentTimeMillis(); log.fine("Compiled " + javaFileName + " " + (t2 - t1) + "ms"); } // Save or delete the generated Java files, depending on the // value of "keepgenerated" attribute javaCompiler.doJavaFile(ctxt.keepGenerated()); // JSR45 Support if (!ctxt.isPrototypeMode() && !options.isSmapSuppressed()) { smapUtil.installSmap(); } // START CR 6373479 if (jsw != null && jsw.getServletClassLastModifiedTime() <= 0) { jsw.setServletClassLastModifiedTime(javaCompiler.getClassLastModified()); } // END CR 6373479 if (options.getSaveBytecode()) { javaCompiler.saveClassFile(ctxt.getFullClassName(), ctxt.getClassFileName()); } // On some systems, due to file caching, the time stamp for the updated // JSP file may actually be greater than that of the newly created byte // codes in the cache. In such cases, adjust the cache time stamp to // JSP page time, to avoid unnecessary recompilations. ctxt.getRuntimeContext().adjustBytecodeTime(ctxt.getFullClassName(), jspModTime); }