Skip to content

Commit f0a2dec

Browse files
fix ProofBundleIOTest (and setting classpath/bootclasspath in .key files): make sure that Java files are always read through FileRepo, set bcp/cp earlier, remove String.key from bundle
1 parent 0a20b91 commit f0a2dec

6 files changed

Lines changed: 36 additions & 1365 deletions

File tree

key.core/src/main/java/de/uka/ilkd/key/java/JavaService.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ public class JavaService {
114114
@NonNull
115115
private final Path bootClassPath;
116116

117+
private final FileRepo fileRepo;
117118

118119
/**
119120
* A list of {@link File} objects that describes the classpath to be searched
@@ -123,11 +124,12 @@ public class JavaService {
123124
private final Collection<Path> libraryPath;
124125

125126
public JavaService(Services services, @NonNull Path bootClassPath,
126-
@NonNull Collection<Path> libraryPath) {
127+
@NonNull Collection<Path> libraryPath, FileRepo fileRepo) {
127128
this.services = services;
128129
this.mapping = new KeYJPMapping();
129130
this.bootClassPath = bootClassPath;
130131
this.libraryPath = libraryPath;
132+
this.fileRepo = fileRepo;
131133
programFactory = new JavaParserFactory(services);
132134
typeConverter = new JP2KeYTypeConverter(services, programFactory.getTypeSolver(), mapping);
133135
converter = new JP2KeYConverter(services, new Namespace<>());
@@ -137,6 +139,8 @@ private JavaService(JavaService o, Services services) {
137139
this.services = services;
138140
this.bootClassPath = o.bootClassPath;
139141
this.libraryPath = o.libraryPath;
142+
// TODO: copy filerepo instead?
143+
this.fileRepo = o.fileRepo;
140144
this.mapping = o.mapping.copy();
141145
programFactory = o.programFactory.copy(services);
142146
typeConverter = new JP2KeYTypeConverter(services, programFactory.getTypeSolver(), mapping);
@@ -238,7 +242,7 @@ public List<de.uka.ilkd.key.java.ast.CompilationUnit> readCompilationUnits(
238242
Path parent,
239243
Collection<Path> files, FileRepo repo)
240244
throws IOException, BuildingExceptions {
241-
parseSpecialClasses();
245+
parseSpecialClasses(repo);
242246
var cus = new ArrayList<CompilationUnit>(files.size());
243247
for (Path file : files) {
244248
var cu = unwrapParseResult(file.toString(), parseCompilationUnit(file, repo));
@@ -732,7 +736,9 @@ private com.github.javaparser.ast.type.Type keyType2JPType(Type type) {
732736
* @return the parsed and resolved recoder statement block
733737
*/
734738
Node parseBlock(String input, JPContext context) {
735-
parseSpecialClasses();
739+
// ensure bootclasspath/classpath are read (needed for resolution in modalities in taclets)
740+
parseSpecialClasses(fileRepo);
741+
736742
// TODO javaparser change grammar of the parser to allow blocks without context information
737743
// Context-block
738744
Node original;

key.core/src/main/java/de/uka/ilkd/key/java/Services.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import de.uka.ilkd.key.proof.*;
1717
import de.uka.ilkd.key.proof.init.InitConfig;
1818
import de.uka.ilkd.key.proof.init.Profile;
19+
import de.uka.ilkd.key.proof.io.consistency.FileRepo;
1920
import de.uka.ilkd.key.proof.mgt.SpecificationRepository;
2021
import de.uka.ilkd.key.util.KeYResourceManager;
2122

@@ -473,19 +474,19 @@ public JavaService getJavaService() {
473474
}
474475

475476
private JavaService activateJavaPath(@NonNull Path bootClassPath,
476-
@NonNull Collection<Path> libraryPaths) {
477+
@NonNull Collection<Path> libraryPaths, FileRepo fileRepo) {
477478
if (javaService != null && javaService.getBootClassPath().equals(bootClassPath)
478479
&& CollectionUtil.containsSame(javaService.getLibraryPath(), libraryPaths)) {
479480
return javaService;
480481
}
481482
LOGGER.info("activate java with {} and {}", bootClassPath, libraryPaths);
482-
javaService = new JavaService(this, bootClassPath, libraryPaths);
483+
javaService = new JavaService(this, bootClassPath, libraryPaths, fileRepo);
483484
javaInfo = new JavaInfo(new KeYProgModelInfo(javaService), this);
484485
return javaService;
485486
}
486487

487488
public JavaService activateJava(@Nullable Path bootClassPath,
488-
@NonNull Collection<Path> libraryPaths) {
489+
@NonNull Collection<Path> libraryPaths, FileRepo fileRepo) {
489490
Path path;
490491
if (bootClassPath != null) {
491492
path = bootClassPath;
@@ -497,11 +498,11 @@ public JavaService activateJava(@Nullable Path bootClassPath,
497498
libraryPaths = Collections.emptyList();
498499
}
499500

500-
return activateJavaPath(path, libraryPaths);
501+
return activateJavaPath(path, libraryPaths, fileRepo);
501502
}
502503

503504
public void activateJava(@Nullable Path bootClassPath) {
504-
activateJava(bootClassPath, Collections.emptyList());
505+
activateJava(bootClassPath, Collections.emptyList(), null);
505506
}
506507

507508
public static Path getReduxPath() {

key.core/src/main/java/de/uka/ilkd/key/java/loader/JP2KeYConverter.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -708,9 +708,14 @@ public Object visit(FieldAccessExpr n, Void arg) {
708708
return new FieldReference(pi, c, variable, translatePackageReference(n.getScope()));
709709
}
710710
} catch (UnsolvedSymbolException e) {
711-
ResolvedType type = n.calculateResolvedType();
712-
var keyType = getKeYJavaType(type);
713-
return new TypeRef(keyType);
711+
try {
712+
ResolvedType type = n.calculateResolvedType();
713+
var keyType = getKeYJavaType(type);
714+
return new TypeRef(keyType);
715+
} catch (UnsolvedSymbolException e1) {
716+
throw new ParserException("Name could not be resolved '" + n + "'",
717+
Location.fromNode(n));
718+
}
714719
}
715720
}
716721

key.core/src/main/java/de/uka/ilkd/key/proof/init/ProblemInitializer.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,9 @@ private void readJava(EnvInput envInput, InitConfig initConfig) throws ProofInpu
238238
if (fileRepo != null) {
239239
// set the paths in the FileRepo (all three methods can deal with null parameters)
240240
fileRepo.setJavaPath(javaPath);
241-
fileRepo.setClassPath(classPath);
242-
fileRepo.setBootClassPath(bootClassPath);
241+
// cp and bcp should have been set earlier (in activateJava)
242+
//fileRepo.setClassPath(classPath);
243+
//fileRepo.setBootClassPath(bootClassPath);
243244
}
244245

245246
// weigl: 2021-01, Early including the includes of the KeYUserProblemFile,
@@ -406,11 +407,17 @@ private void setUpProofHelper(ProofOblInput problem, ProofAggregate pl)
406407
}
407408
}
408409

409-
private void activateInitConfigJava(InitConfig config, EnvInput envInput) {
410+
private void activateInitConfigJava(InitConfig config, EnvInput envInput, FileRepo fileRepo) {
410411
var bootClassPath = envInput.readBootClassPath();
411412
var classPath = envInput.readClassPath();
412413
config.getServices().activateJava(bootClassPath,
413-
classPath != null ? classPath : Collections.emptyList());
414+
classPath != null ? classPath : Collections.emptyList(), fileRepo);
415+
416+
if (fileRepo != null) {
417+
fileRepo.setClassPath(classPath);
418+
fileRepo.setBootClassPath(bootClassPath);
419+
config.setFileRepo(fileRepo);
420+
}
414421
}
415422

416423
/**
@@ -428,7 +435,7 @@ private InitConfig createInitConfigFor(EnvInput envInput) throws ProofInputExcep
428435
}
429436

430437
InitConfig config = new InitConfig(services);
431-
activateInitConfigJava(config, envInput);
438+
activateInitConfigJava(config, envInput, fileRepo);
432439

433440
// the first time, read in standard rules
434441
ImmutableList<RuleSource> tacletBases = profile.getStandardRules().getTacletBase();

key.core/src/test/java/KeyJavaPipelineTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public KeYJavaPipeline createPipelineTest(Path testFolder) throws IOException {
5151
assertNotNull(nss.sorts().lookup("int"));
5252
assertNotNull(nss.sorts().lookup("boolean"));
5353
var inputFolder = testFolder.resolve("input");
54-
var js = services.activateJava(null, Collections.singleton(inputFolder));
54+
var js = services.activateJava(null, Collections.singleton(inputFolder), null);
5555
js.parseSpecialClasses();
5656

5757
final var jp = js.getProgramFactory().createJavaParser();

0 commit comments

Comments
 (0)