58 import static java.util.stream.Collectors.toList; |
58 import static java.util.stream.Collectors.toList; |
59 import java.util.stream.Stream; |
59 import java.util.stream.Stream; |
60 import javax.lang.model.util.Elements; |
60 import javax.lang.model.util.Elements; |
61 import javax.tools.FileObject; |
61 import javax.tools.FileObject; |
62 import jdk.jshell.MemoryFileManager.SourceMemoryJavaFileObject; |
62 import jdk.jshell.MemoryFileManager.SourceMemoryJavaFileObject; |
63 import jdk.jshell.ClassTracker.ClassInfo; |
|
64 import java.lang.Runtime.Version; |
63 import java.lang.Runtime.Version; |
65 |
64 |
66 /** |
65 /** |
67 * The primary interface to the compiler API. Parsing, analysis, and |
66 * The primary interface to the compiler API. Parsing, analysis, and |
68 * compilation to class files (in memory). |
67 * compilation to class files (in memory). |
276 boolean result = task.call(); |
275 boolean result = task.call(); |
277 fileManager.registerClassFileCreationListener(null); |
276 fileManager.registerClassFileCreationListener(null); |
278 return result; |
277 return result; |
279 } |
278 } |
280 |
279 |
281 |
280 // Returns the list of classes generated during this compile. |
282 List<ClassInfo> classInfoList(OuterWrap w) { |
281 // Stores the mapping between class name and current compiled bytes. |
|
282 List<String> classList(OuterWrap w) { |
283 List<OutputMemoryJavaFileObject> l = classObjs.get(w); |
283 List<OutputMemoryJavaFileObject> l = classObjs.get(w); |
284 if (l == null) return Collections.emptyList(); |
284 if (l == null) { |
285 return l.stream() |
285 return Collections.emptyList(); |
286 .map(fo -> state.classTracker.classInfo(fo.getName(), fo.getBytes())) |
286 } |
287 .collect(Collectors.toList()); |
287 List<String> list = new ArrayList<>(); |
|
288 for (OutputMemoryJavaFileObject fo : l) { |
|
289 state.setClassnameToBytes(fo.getName(), fo.getBytes()); |
|
290 list.add(fo.getName()); |
|
291 } |
|
292 return list; |
288 } |
293 } |
289 |
294 |
290 private void listenForNewClassFile(OutputMemoryJavaFileObject jfo, JavaFileManager.Location location, |
295 private void listenForNewClassFile(OutputMemoryJavaFileObject jfo, JavaFileManager.Location location, |
291 String className, JavaFileObject.Kind kind, FileObject sibling) { |
296 String className, JavaFileObject.Kind kind, FileObject sibling) { |
292 //debug("listenForNewClassFile %s loc=%s kind=%s\n", className, location, kind); |
297 //debug("listenForNewClassFile %s loc=%s kind=%s\n", className, location, kind); |