MCPcopy Index your code
hub / github.com/apache/tomcat / generateClass

Method generateClass

java/org/apache/jasper/compiler/JDTCompiler.java:73–567  ·  view source on GitHub ↗
(Map<String,SmapStratum> smaps)

Source from the content-addressed store, hash-verified

71 private final Log log = LogFactory.getLog(JDTCompiler.class); // must not be static
72
73 @Override
74 protected void generateClass(Map<String,SmapStratum> smaps)
75 throws FileNotFoundException, JasperException, Exception {
76
77 long t1 = 0;
78 if (log.isDebugEnabled()) {
79 t1 = System.currentTimeMillis();
80 }
81
82 final String sourceFile = ctxt.getServletJavaFileName();
83 final String outputDir = ctxt.getOptions().getScratchDir().getAbsolutePath();
84 String packageName = ctxt.getServletPackageName();
85 final String targetClassName =
86 ((packageName.length() != 0) ? (packageName + ".") : "") + ctxt.getServletClassName();
87 final ClassLoader classLoader = ctxt.getJspLoader();
88 String[] fileNames = new String[] { sourceFile };
89 String[] classNames = new String[] { targetClassName };
90 final List<JavacErrorDetail> problemList = new ArrayList<>();
91
92 class CompilationUnit implements ICompilationUnit {
93
94 private final String className;
95 private final String sourceFile;
96
97 CompilationUnit(String sourceFile, String className) {
98 this.className = className;
99 this.sourceFile = sourceFile;
100 }
101
102 @Override
103 public char[] getFileName() {
104 return sourceFile.toCharArray();
105 }
106
107 @Override
108 public char[] getContents() {
109 char[] result;
110 try (FileInputStream is = new FileInputStream(sourceFile);
111 InputStreamReader isr = new InputStreamReader(is, ctxt.getOptions().getJavaEncoding());
112 Reader reader = new BufferedReader(isr)) {
113 char[] chars = new char[8192];
114 StringBuilder buf = new StringBuilder();
115 int count;
116 while ((count = reader.read(chars, 0, chars.length)) > 0) {
117 buf.append(chars, 0, count);
118 }
119 result = new char[buf.length()];
120 buf.getChars(0, result.length, result, 0);
121 } catch (IOException ioe) {
122 log.error(Localizer.getMessage("jsp.error.compilation.source", sourceFile), ioe);
123 result = new char[0];
124 }
125 return result;
126 }
127
128 @Override
129 public char[] getMainTypeName() {
130 int dot = className.lastIndexOf('.');

Callers

nothing calls this directly

Calls 15

getMessageMethod · 0.95
compileMethod · 0.95
installSmapMethod · 0.95
getServletPackageNameMethod · 0.80
lengthMethod · 0.80
getServletClassNameMethod · 0.80
getJspLoaderMethod · 0.80
keepGeneratedMethod · 0.80
isPrototypeModeMethod · 0.80
isDebugEnabledMethod · 0.65
getScratchDirMethod · 0.65

Tested by

no test coverage detected