Skip to content

Commit 8357972

Browse files
committed
simplify the javac check facade
1 parent 3f01c36 commit 8357972

3 files changed

Lines changed: 19 additions & 92 deletions

File tree

key.ui/src/main/java/de/uka/ilkd/key/gui/plugins/javac/JavaCompilerCheckFacade.java

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import de.uka.ilkd.key.gui.PositionedIssueString;
1919
import de.uka.ilkd.key.java.Position;
2020
import de.uka.ilkd.key.parser.Location;
21-
import de.uka.ilkd.key.proof.init.ProblemInitializer;
2221
import de.uka.ilkd.key.settings.Configuration;
2322

2423
import org.key_project.util.Streams;
@@ -35,8 +34,6 @@
3534
* <p>
3635
* For setting up <code>javac</code> it uses the KeY project information about the bootpath and
3736
* classpath.
38-
* Any issues found in the compilation are reported to a provided listener of type
39-
* {@link ProblemInitializer.ProblemInitializerListener}.
4037
* <p>
4138
* Checking the target Java code can be enabled / disabled by providing the property
4239
* <code>-PKEY_JAVAC_DISABLE=true</code> / <code>-PKEY_JAVAC_DISABLE=false</code> on startup of KeY.
@@ -61,7 +58,7 @@ public static void main(String[] args) {
6158
var settings = new JavacSettings();
6259
settings.readSettings(params);
6360

64-
List<PositionedIssueString> result = check(null,
61+
List<PositionedIssueString> result = check(
6562
Paths.get(params.getString("bootClassPath")),
6663
params.getStringList("classPath").stream().map(Paths::get).toList(),
6764
Paths.get(params.getString("javaPath")), settings).get();
@@ -93,11 +90,8 @@ public static void main(String[] args) {
9390

9491
/**
9592
* initiates the compilation check on the target Java source (the Java program to be verified)
96-
* in a separate process (with another java runtime) and
97-
* reports any issues to the provided <code>listener</code>
93+
* in a separate process (with another java runtime)
9894
*
99-
* @param listener the {@link ProblemInitializer.ProblemInitializerListener} to be informed
100-
* about any issues found in the target Java program
10195
* @param bootClassPath the {@link Path} referring to the path containing the core Java classes
10296
* @param classPath the {@link List} of {@link Path}s referring to the directory that make up
10397
* the target Java programs classpath
@@ -107,7 +101,6 @@ public static void main(String[] args) {
107101
* @return future providing the list of diagnostics
108102
*/
109103
public static @NonNull CompletableFuture<List<PositionedIssueString>> checkExternally(
110-
ProblemInitializer.ProblemInitializerListener listener,
111104
Path bootClassPath, List<Path> classPath, Path javaPath,
112105
JavacSettings settings) {
113106
if (Boolean.getBoolean("KEY_JAVAC_DISABLE")) {
@@ -177,11 +170,7 @@ public static void main(String[] args) {
177170

178171
/**
179172
* initiates the compilation check on the target Java source (the Java program to be verified)
180-
* and
181-
* reports any issues to the provided <code>listener</code>
182173
*
183-
* @param listener the {@link ProblemInitializer.ProblemInitializerListener} to be informed
184-
* about any issues found in the target Java program
185174
* @param bootClassPath the {@link Path} referring to the path containing the core Java classes
186175
* @param classPath the {@link List} of {@link Path}s referring to the directory that make up
187176
* the target Java programs classpath
@@ -191,7 +180,6 @@ public static void main(String[] args) {
191180
* @return future providing the list of diagnostics
192181
*/
193182
public static @NonNull CompletableFuture<List<PositionedIssueString>> check(
194-
ProblemInitializer.ProblemInitializerListener listener,
195183
Path bootClassPath, List<Path> classPath, Path javaPath,
196184
JavacSettings settings) {
197185
if (Boolean.getBoolean("KEY_JAVAC_DISABLE")) {
@@ -205,9 +193,6 @@ public static void main(String[] args) {
205193

206194
if (compiler == null) {
207195
LOGGER.info("Javac is not available in current java runtime. Javac check skipped");
208-
if (listener != null) {
209-
listener.reportStatus(null, "No javac compiler found. Java check disabled.");
210-
}
211196
return CompletableFuture.completedFuture(Collections.emptyList());
212197
}
213198

@@ -249,8 +234,9 @@ public static void main(String[] args) {
249234
}
250235

251236
if (bootClassPath != null) {
252-
options.add("-bootclasspath");
253-
options.add(bootClassPath.toAbsolutePath().toString());
237+
// options.add("-bootclasspath");
238+
// options.add(bootClassPath.toAbsolutePath().toString());
239+
LOGGER.info("The \"bootclasspath\" Option is set but not supported.");
254240
}
255241

256242
if (classPath != null && !classPath.isEmpty()) {
@@ -277,6 +263,10 @@ public static void main(String[] args) {
277263
Iterable<? extends JavaFileObject> compilationUnits =
278264
fileManager.getJavaFileObjects(files.toArray(new Path[0]));
279265

266+
LOGGER.info(
267+
"running Javac check with following\n\toptions: {},\n\tclasses: {},\n\tcompilation units: {},",
268+
options, classes, compilationUnits);
269+
280270
JavaCompiler.CompilationTask task = compiler.getTask(output, fileManager, diagnostics,
281271
options, classes, compilationUnits);
282272

key.ui/src/main/java/de/uka/ilkd/key/gui/plugins/javac/JavacExtension.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,11 +157,11 @@ private void loadProof(Proof selectedProof) throws RuntimeException {
157157

158158
JavacSettings settings = JavacSettingsProvider.getJavacSettings();
159159
CompletableFuture<List<PositionedIssueString>> task = settings.getUseProcessors()
160-
? JavaCompilerCheckFacade.checkExternally(mediator.getUI(), bootClassPath,
160+
? JavaCompilerCheckFacade.checkExternally(bootClassPath,
161161
classpath,
162162
javaPath,
163163
settings)
164-
: JavaCompilerCheckFacade.check(mediator.getUI(), bootClassPath, classpath,
164+
: JavaCompilerCheckFacade.check(bootClassPath, classpath,
165165
javaPath, settings);
166166
try {
167167
task.thenAccept(it -> SwingUtilities.invokeLater(() -> {

key.ui/src/test/java/de/uka/ilkd/key/gui/plugins/javac/JavaCompilerCheckFacadeTest.java

Lines changed: 8 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,10 @@
77
import java.util.Collections;
88
import java.util.concurrent.ExecutionException;
99

10-
import de.uka.ilkd.key.proof.ProofAggregate;
11-
import de.uka.ilkd.key.proof.init.ProblemInitializer;
12-
import de.uka.ilkd.key.proof.init.ProofOblInput;
13-
1410
import org.junit.jupiter.api.Test;
1511

12+
import static org.junit.jupiter.api.Assertions.assertTrue;;
13+
1614
/**
1715
* @author Alexander Weigl
1816
* @version 1 (29.01.23)
@@ -22,82 +20,21 @@ class JavaCompilerCheckFacadeTest {
2220
void compile1() throws ExecutionException, InterruptedException {
2321
File src = new File("examples/firstTouch/06-BinarySearch/src/").getAbsoluteFile();
2422
System.out.println(src);
25-
ProblemInitializer.ProblemInitializerListener emptyListener =
26-
new ProblemInitializer.ProblemInitializerListener() {
27-
@Override
28-
public void proofCreated(ProblemInitializer sender,
29-
ProofAggregate proofAggregate) {
30-
}
31-
32-
@Override
33-
public void progressStarted(Object sender) {
34-
}
35-
36-
@Override
37-
public void progressStopped(Object sender) {
38-
}
39-
40-
@Override
41-
public void reportStatus(Object sender, String status, int progress) {
42-
}
43-
44-
@Override
45-
public void reportStatus(Object sender, String status) {
46-
}
47-
48-
@Override
49-
public void resetStatus(Object sender) {
50-
}
51-
52-
@Override
53-
public void reportException(Object sender, ProofOblInput input, Exception e) {
54-
}
55-
};
5623
var promise =
57-
JavaCompilerCheckFacade.check(emptyListener, null, Collections.emptyList(),
24+
JavaCompilerCheckFacade.check(null, Collections.emptyList(),
5825
src.toPath(), new JavacSettings());
59-
promise.get();
26+
var result = promise.get();
27+
assertTrue(result.isEmpty());
6028
}
6129

6230
@Test
6331
void compileExternal() throws ExecutionException, InterruptedException {
6432
File src = new File("examples/firstTouch/06-BinarySearch/src/").getAbsoluteFile();
6533
System.out.println(src);
66-
ProblemInitializer.ProblemInitializerListener emptyListener =
67-
new ProblemInitializer.ProblemInitializerListener() {
68-
@Override
69-
public void proofCreated(ProblemInitializer sender,
70-
ProofAggregate proofAggregate) {
71-
}
72-
73-
@Override
74-
public void progressStarted(Object sender) {
75-
}
76-
77-
@Override
78-
public void progressStopped(Object sender) {
79-
}
80-
81-
@Override
82-
public void reportStatus(Object sender, String status, int progress) {
83-
}
84-
85-
@Override
86-
public void reportStatus(Object sender, String status) {
87-
}
88-
89-
@Override
90-
public void resetStatus(Object sender) {
91-
}
92-
93-
@Override
94-
public void reportException(Object sender, ProofOblInput input, Exception e) {
95-
}
96-
};
9734
var promise =
98-
JavaCompilerCheckFacade.checkExternally(emptyListener, null, Collections.emptyList(),
35+
JavaCompilerCheckFacade.checkExternally(null, Collections.emptyList(),
9936
src.toPath(), new JavacSettings());
100-
promise.get();
37+
var result = promise.get();
38+
assertTrue(result.isEmpty());
10139
}
102-
10340
}

0 commit comments

Comments
 (0)