问题
Since Java 7 Update 25, Applet's method getCodeBase()
seems to return NULL
for local applets. I haven't found anything in Java 7u25 release notes that would announce/explain this change, but I found an email discussion which claims the change is actually intended.
Can anyone help me to find a resource/documentation where I could learn more about this change?
回答1:
release notes are here:
http://www.oracle.com/technetwork/java/javase/7u25-relnotes-1955741.html
its in there.
"Local Applets return NULL for "
回答2:
UPDATE (1/21/2014): Java 7 update 51 appears to have fixed this Java bug
Oracle claims the fix was 'security' related, and was required to prevent a sandboxed applet from obtaining access to "file path" information (the folder name where the applet is being run). But Oracle failed horrible, as explained in great detail here:
http://www.duckware.com/tech/java-security-clusterfuck.html
Google "java bug report" and submit a bug report to Oracle.
回答3:
Oracle bug #8017250 (which apparently is related to Unable to debug applet with JDK 7u21 and 7u25 as well) has some more details. In particular, it states that this is “not an issue” (i.e. intentional) and suggests the following alternatives:
If applet need to load resource:
- if the resource is in applet JAR(s), they should be able to load it with ClassLoader.getResoruceAsStream directly, without needing the codebase information.
- if the resource is in arbitary location, not inside applet JAR, they should have other ways to get to that location, since it's not part of the applet resource anyway. (e.g.
user.home
java system property, provided that their applet has all-permissions)
来源:https://stackoverflow.com/questions/17233662/applet-getcodebase-returns-null-for-local-applets-since-java-7-update-25