Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide NativeAPI service to apps launched by bootstraps #2375

Conversation

alexarchambault
Copy link
Member

@alexarchambault alexarchambault commented Feb 22, 2022

This fixes errors such as this one, that can be seen when using jni-utils from an app launched by a coursier bootstrap:

java.util.ServiceConfigurationError: coursier.jniutils.NativeApi: coursier.bootstrap.launcher.jniutils.BootstrapNativeApi not a subtype
    java.base/java.util.ServiceLoader.fail(ServiceLoader.java:593)
    java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.hasNextService(ServiceLoader.java:14)
    java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.hasNext(ServiceLoader.java:13)
    java.base/java.util.ServiceLoader$2.hasNext(ServiceLoader.java:1309)
    java.base/java.util.ServiceLoader$3.hasNext(ServiceLoader.java:1393)
    coursier.jniutils.NativeApi.get(NativeApi.java:32)
    …

@alexarchambault
Copy link
Member Author

Ideally, that would deserve a non-regression test… Maybe if / when I'll make it a bit more robust, by having this also hide the bootstrap own classes.

@alexarchambault
Copy link
Member Author

alexarchambault commented Feb 22, 2022

That said, I'm not fond of hiding stuff with class loader hacks such as this… If ever users try to duplicate the class path by walking over the class loader hierarchy (and looking at each URLClassLoader say, then loading everything in a new distinct class loader hierarchy), they'll miss the loaders hiding stuff, and will get faulty duplicated class paths…

utest having issues running specific tests if their names have '.'
@alexarchambault alexarchambault force-pushed the hide-native-api-service-in-bootstraps branch from ca2a764 to 2aeb490 Compare February 22, 2022 21:36
@alexarchambault alexarchambault merged commit 0b52b52 into coursier:master Feb 22, 2022
@alexarchambault alexarchambault deleted the hide-native-api-service-in-bootstraps branch February 22, 2022 21:55
alexarchambault added a commit to alexarchambault/sbt-coursier that referenced this pull request Aug 12, 2022
That pulls coursier > 2.1.0-M5, that has coursier/coursier#2375
alexarchambault added a commit to alexarchambault/sbt-coursier that referenced this pull request Aug 15, 2022
That pulls coursier > 2.1.0-M5, that has coursier/coursier#2375
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant