Skip to content

Commit

Permalink
Bugfix for eclipse-jdt#985: ECJ throws false error "Package collides …
Browse files Browse the repository at this point in the history
…with type".
  • Loading branch information
nettozahler committed Nov 1, 2024
1 parent 6b20051 commit 1cd66db
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2015, 2018 IBM Corporation and others.
* Copyright (c) 2015, 2024 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -99,9 +99,13 @@ public NameEnvironmentAnswer findClass(char[] typeName, String qualifiedPackageN

try (InputStream inputStream = jfo.openInputStream()) {
ClassFileReader reader = ClassFileReader.read(inputStream.readAllBytes(), qualifiedBinaryFileName);
if (reader != null) {
return new NameEnvironmentAnswer(reader, fetchAccessRestriction(qualifiedBinaryFileName));
}

// To avoid false compiler errors "package collides with type" on case insensitive file systems
// (e. g. Windows), make a case sensitive comparison of class name and type name from reader. The
// reader contains the CASE SENSITIVE type name.
return reader != null && className.equals(new String(reader.getName()))
? new NameEnvironmentAnswer(reader, fetchAccessRestriction(qualifiedBinaryFileName))
: null;
}
} catch (ClassFormatException e) {
// treat as if class file is missing
Expand Down

0 comments on commit 1cd66db

Please sign in to comment.