我对Java 8政策有一个看似奇怪的问题。
我在Java 7中使用了以下权限来更新51并且它工作正常:
grant {
(...)
java.net.SocketPermission "localhost:1024-", "accept,connect,listen,resolve";
};
但现在我正在检查Java 8支持,我得到了这个例外:
Exception in thread "RMI TCP Connection(idle)" java.security.AccessControlException: access denied ("java.net.SocketPermission" "10.1.17.112:55703" "accept,resolve")
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at sun.plugin2.applet.AWTAppletSecurityManager.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkAccept(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.checkAcceptPermission(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport.checkAcceptPermission(Unknown Source)
at sun.rmi.transport.Transport$1.run(Unknown Source)
at sun.rmi.transport.Transport$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
运行IPConfig向我显示10.1.17.122是我本地计算机的IP:
Ethernet adapter Local Area Connection:
IPv4 Address. . . . . . . . . . . : 10.1.17.112
Subnet Mask . . . . . . . . . . . : 255.255.252.0
Default Gateway . . . . . . . . . : 10.1.19.254
如果我将权限更改为127.0.0.1,那么它既不能正常工作:
grant {
(...)
java.net.SocketPermission "127.0.0.1:1024-", "accept,connect,listen,resolve";
};
但是,如果我输入我的IP地址,一切正常:
grant {
(...)
java.net.SocketPermission "10.1.17.112:1024-", "accept,connect,listen,resolve";
};
任何想法为什么?
编辑: 对我来说,它似乎是Java 8中的一个Bug,任何人都可以证实这一点吗?
答案 0 :(得分:2)
"本地主机"是127.0.0.1。 " 10.1.17.112"完全是另一回事。你很幸运,它曾经工作过。
答案 1 :(得分:1)
我想我找到了我想要的东西:http://bugs.java.com/bugdatabase/view_bug.do?bug_id=7077696
建议的解决方法对我有用。
2011-11-09 周围的工作
使用-Djava.net.preferIPv4Stack = true
运行
感谢您的帮助!