Skip to content

Instantly share code, notes, and snippets.

@rednaxelafx
Created July 23, 2011 13:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rednaxelafx/1101401 to your computer and use it in GitHub Desktop.
Save rednaxelafx/1101401 to your computer and use it in GitHub Desktop.
example that shows the difference in the strategy used to implement the string pool in JVMs. watch for the effect of PermGen removal in newer HotSpot
$ use6u25
$ java -version
java version "1.6.0_25"
Java(TM) SE Runtime Environment (build 1.6.0_25-b06)
Java HotSpot(TM) 64-Bit Server VM (build 20.0-b11, mixed mode)
$ groovysh
Groovy Shell (1.7.5, JVM: 1.6.0_25)
Type 'help' or '\h' for help.
-------------------------------------------------------------------------------
groovy:000> s = new String([(byte) 'a', (byte) 'b'] as byte[])
===> ab
groovy:000> t = s.intern()
===> ab
groovy:000> s.is t
===> false
groovy:000> quit
$ use7b144
$ java -version
java version "1.7.0-ea"
Java(TM) SE Runtime Environment (build 1.7.0-ea-b144)
Java HotSpot(TM) 64-Bit Server VM (build 21.0-b14, mixed mode)
$ groovysh
Groovy Shell (1.7.5, JVM: 1.7.0-ea)
Type 'help' or '\h' for help.
-------------------------------------------------------------------------------
groovy:000> s = new String([(byte) 'a', (byte) 'b'] as byte[])
===> ab
groovy:000> t = s.intern()
===> ab
groovy:000> s.is t
===> true
groovy:000> quit
$ usejrockit
$ java -version
java version "1.6.0_20"
Java(TM) SE Runtime Environment (build 1.6.0_20-b02)
Oracle JRockit(R) (build R28.0.1-21-133393-1.6.0_20-20100512-2126-linux-x86_64, compiled mode)
rednaxelafx@fx-laptop:~/build$ groovysh
Groovy Shell (1.7.5, JVM: 1.6.0_20)
Type 'help' or '\h' for help.
-------------------------------------------------------------------------------
groovy:000> s = new String([(byte) 'a', (byte) 'b'] as byte[])
===> ab
groovy:000> t = s.intern()
===> ab
groovy:000> s.is t
===> true
groovy:000> quit
$ usej9
$ java -version
java version "1.6.0"
Java(TM) SE Runtime Environment (build pxa6460sr8fp1-20100624_01(SR8 FP1))
IBM J9 VM (build 2.4, JRE 1.6.0 IBM J9 2.4 Linux amd64-64 jvmxa6460sr8ifx-20100609_59383 (JIT enabled, AOT enabled)
J9VM - 20100609_059383
JIT - r9_20100401_15339ifx2
GC - 20100308_AA)
JCL - 20100624_01
$ groovysh
Groovy Shell (1.7.5, JVM: 1.6.0)
Type 'help' or '\h' for help.
-------------------------------------------------------------------------------
groovy:000> s = new String([(byte) 'a', (byte) 'b'] as byte[])
===> ab
groovy:000> t = s.intern()
===> ab
groovy:000> s.is t
===> false
groovy:000> quit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment