Applet.getCodeBase() returns null for local Applets since Java 7 update 25

陌路散爱 提交于 2019-12-23 13:12:23

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!