Skip to content

Commit 16a6357

Browse files
authored
fix #3721, getParent().toUri() requires absolute paths (#3722)
2 parents 9d0379c + e033817 commit 16a6357

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

key.core/src/main/java/de/uka/ilkd/key/proof/io/KeYFile.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,9 @@ public Includes readIncludes() throws ProofInputException {
219219
if (includes == null) {
220220
try {
221221
KeyAst.File ctx = getParseContext();
222-
includes = ctx.getIncludes(file.file().getParent().toUri().toURL());
222+
// weigl: fix #3721, absolute path is required to solve relative filenames.
223+
Path absPath = file.file().toAbsolutePath().getParent();
224+
includes = ctx.getIncludes(absPath.toUri().toURL());
223225
} catch (ParseCancellationException e) {
224226
throw new ParseCancellationException(e);
225227
} catch (Exception e) {
@@ -240,7 +242,7 @@ public Path readBootClassPath() {
240242
Path bootClassPathFile = Paths.get(bootClassPath);
241243
if (!bootClassPathFile.isAbsolute()) {
242244
// convert to absolute by resolving against the parent path of the parsed file
243-
var parentDirectory = file.file().getParent();
245+
Path parentDirectory = file.file().getParent();
244246
bootClassPathFile = parentDirectory.resolve(bootClassPath);
245247
}
246248

@@ -259,7 +261,7 @@ public Path readBootClassPath() {
259261
@Override
260262
public @NonNull List<Path> readClassPath() {
261263
ProblemInformation pi = getProblemInformation();
262-
var parentDirectory = file.file().getParent();
264+
Path parentDirectory = file.file().getParent();
263265
List<Path> fileList = new ArrayList<>();
264266
for (String cp : pi.getClasspath()) {
265267
if (cp == null) {
@@ -280,10 +282,10 @@ public Path readJavaPath() throws ProofInputException {
280282
ProblemInformation pi = getProblemInformation();
281283
String javaPath = pi.getJavaSource();
282284
if (javaPath != null) {
283-
var absFile = Paths.get(javaPath);
285+
Path absFile = Paths.get(javaPath);
284286
if (!absFile.isAbsolute()) {
285287
// convert to absolute by resolving against the parent path of the parsed file
286-
var parent = file.file().getParent();
288+
Path parent = file.file().getParent();
287289
absFile = parent.resolve(javaPath);
288290
}
289291
if (!Files.exists(absFile)) {

0 commit comments

Comments
 (0)