Fix native library filtering for Android ART in Util.java - #5259
Fix native library filtering for Android ART in Util.java#52591799833473 wants to merge 2 commits into
Conversation
Added a method to check for native library file names and updated bootclasspath handling to exclude native libraries.
There was a problem hiding this comment.
Pull request overview
This PR improves ECJ’s platform/bootclasspath handling by recognizing native library files (.so, .dll, .dylib) and preventing them from being treated as potential ZIP/JMOD archives or added to platform libraries—addressing Android ART bootclasspath entries like /system/lib64/libart.so.
Changes:
- Added a new native-library filename/path check and used it to exclude native libs from
isPotentialZipArchive()andarchiveFormat(). - Filtered native libraries out of
collectPlatformLibraries()when reading bootclasspath properties and when scanningjavaHome/lib.
Suppressed comments (1)
org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/util/Util.java:736
- The Javadoc link
{@link #isClassFileName}is ambiguous because Util defines both isClassFileName(char[]) and isClassFileName(String). This can produce Javadoc warnings or link to the unintended overload. Please link to a specific signature.
* The name may be a simple file name, a file system path, or a jar entry
* path. Comparison is done character-by-character to avoid extra string
* allocations, consistent with {@link #isClassFileName}.
* </p>
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Hi @Copilot, Thanks for the review. I've read the three suggestions, but they are all code quality optimizations (low priority), not functional bugs. Since the core changes work and all tests pass, I'd prefer to keep them as-is for now. If you consider any of them blocking, please let me know and I'll address them. Otherwise, I'd appreciate it if we could proceed with merging. Thanks for your time! And thanks to @iloveeclipse for your time too! |
Store the result of file.getAbsolutePath() in a local variable to avoid redundant calls, as suggested by Copilot review. Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
Hello @iloveeclipse , May I ask for your advice again on whether I should merge this PR? Thank you for your time! |
AI Statement:
This contribution was developed with the assistance of AI tools and has been manually reviewed by me.(including Code)
What it does
Prevents native libraries (
.so,.dll,.dylib) from being misidentified as ZIP/JMOD archives or added to the bootclasspath. Fixes #5253.On Android ART, the bootclasspath may contain native library paths (e.g.
/system/lib64/libart.so). ECJ currently treats these as potential ZIP archives because they have an unrecognized file extension, which can lead to unnecessary file probing or classpath pollution.Changes:
isNativeLibrary(String)helper with zero-allocation, case-insensitive character comparison (consistent with existingisClassFileName/isJavaFileNamestyle).isPotentialZipArchive()→ returnsfalse.archiveFormat()→ returns-1.collectPlatformLibraries()bootclasspath collection, both when parsingsun.boot.class.path/vm.boot.class.pathand when scanningjavaHome/lib.How to test
I have pulled the changes from this PR and successfully compiled them locally using the following command:
And built locally with:
mvn clean compile -Pbuild-individual-bundles mvn test -Pbuild-individual-bundlesFull test suite was not run locally due to resource constraints (Termux on Android). I rely on CI for complete testing.
Known limitations / Follow-up work
isNativeLibrarywith various path formats (simple name, absolute path, jar entry path) is recommended as a follow-up.isNativeLibrarychecksFile.separatorCharfor directory/extension disambiguation. On Android/Linux (primary target) this is'/'and works correctly for both file-system paths and jar entry paths. Windows paths using'/'as an alternative separator are not explicitly handled; this is consistent with existing methods inUtilbut could be improved if cross-platform path mixing is a concern.isClassFileName/isJavaFileNameand avoid temporary string allocations.String.regionMatchescould be considered later for readability without sacrificing performance.Author checklist