As discussed in the previous more general question , the problem is that the second reflection method is not determined by the public API class, but by a private implementation, which does not work, because accessibility rules 9 apply.
The fix is ββto use the getCodeBase method for the public interface instead:
Class<?> sclass = Class.forName("javax.jnlp.BasicService");
It also avoids the reflection of an anti-pattern for working with dynamic defining classes.
Using a static implementation would also avoid this problem (however, this problem has a problem that requires javaws.jar , which may not be easy to get in some build environments).
import javax.jnlp.BasicService; import javax.jnlp.ServiceManager; BasicService basicSvc = (BasicService)ServiceManager.lookup("javax.jnlp.BasicService"); URL u = basicSvc.getCodeBase();
Thanks to @Holger to test the reflection implementation and @Alan Bateman , guessing what the real problem was not seeing the code. Separate the two questions posed by @nicolai , which makes it a lot cleaner.
eckes source share