When System.gc() is launched in a test program, the test program creates Sockets
more than the limit specified in -Dsun.net.maxDatagramSockets.
CONFIGURATION:
OS :WinXP(SP3, Japanese, x86)
JDK : JDK7GA
java version "1.7.0"
Java(TM) SE Runtime Environment (build 1.7.0-b147)
Java HotSpot(TM) Client VM (build 21.0-b17, mixed mode)
REPRODUCE:
1. Compile the attached Limit.java
(javac -Xlint:deprecation Limit.java)
2. jar -cvf J800275.jar *.class
3. del *.class
4. java -Djava.security.policy=Limit.policy -Dsun.net.maxDatagramSockets=1 -cp J800275.jar Limit
The message shows up,
Exception in thread "main" java.lang.RuntimeException: Test failed (a): limit was set to 1
at Limit.main(Limit.java:33)
Please see comment section for a little bit more detail.