|
74 | 74 | import java.util.List; |
75 | 75 | import java.util.Locale; |
76 | 76 | import java.util.stream.Collectors; |
| 77 | +import java.util.stream.StreamSupport; |
77 | 78 |
|
78 | 79 | // For Windows focus fix |
79 | 80 | import javax.swing.JDialog; |
| 81 | +import javax.tools.StandardLocation; |
80 | 82 |
|
81 | 83 | import static edu.rice.cs.plt.debug.DebugUtil.debug; |
82 | 84 | import static edu.rice.cs.plt.debug.DebugUtil.error; |
@@ -160,7 +162,11 @@ public void write(int b) { |
160 | 162 | }); |
161 | 163 |
|
162 | 164 | try { |
163 | | - _js = JShell.builder().out(printStream).err(printStream).build(); |
| 165 | + _js = JShell.builder() |
| 166 | + .out(printStream) |
| 167 | + .err(printStream) |
| 168 | + .compilerOptions("-classpath", getClassPathString()) |
| 169 | + .build(); |
164 | 170 | } catch(IllegalStateException e) { |
165 | 171 | //Potentially exit system or try to create a new JShell instance |
166 | 172 | System.err.println("JShell is not available in this environment"); |
@@ -704,9 +710,16 @@ public void junitJVMReady() { } |
704 | 710 | public void addBuildDirectoryClassPath(File f) { _classPathManager.addBuildDirectoryCP(f); } |
705 | 711 | public void addProjectFilesClassPath(File f) { _classPathManager.addProjectFilesCP(f); } |
706 | 712 | public void addExternalFilesClassPath(File f) { _classPathManager.addExternalFilesCP(f); } |
| 713 | + |
707 | 714 | public Iterable<File> getClassPath() { |
708 | 715 | // need to make a serializable snapshot |
709 | 716 | return IterUtil.snapshot(_classPathManager.getClassPath()); |
710 | 717 | } |
711 | | - |
| 718 | + |
| 719 | + private String getClassPathString() { |
| 720 | + Iterable<File> classPathFiles = _classPathManager.getClassPath(); |
| 721 | + return StreamSupport.stream(Spliterators.spliteratorUnknownSize(classPathFiles.iterator(), 0), false) // Convert Iterable<File> to Stream<File> |
| 722 | + .map(File::getAbsolutePath) |
| 723 | + .collect(Collectors.joining(";")); |
| 724 | + } |
712 | 725 | } |
0 commit comments