Sample code that is unexpectedly affected by jvm / jvm-options

I am looking for code examples whose output depends on things like:

  • Java version
  • VM
  • Java / JVM Options

The following code can be used as an example:

Integer foo = 400;
Integer bar = 400;
System.out.println(foo == bar)

Looking at this code, many people guess this is a lie, but it depends on the value of IntegerCache.high, which can be changed using -Djava.lang.Integer.IntegerCache.high = 1000

I think there are many examples when you change behavior with memory limitations, but are there any more unexpected examples?

+4
source share
1 answer

Impact of the Java version:

1) Take a look at the reader as follows:

public class Reader {
   private final String input;
   private int currentPosition;
   private Pattern numberPattern = Pattern.compile(...);

   public String readNextInt() {
       return numberPattern.matcher(input.substring(currentPosition)).group();
   }
}

Java , String.substring() / . Java 7 , substring() String , , .

2) Java 1.2 , , . 1.2 JVM 80- , . , java.

strictfp.

3) Java 8 , , , . .

4) Java 5 JSR-133. JSR-133 , . . , Java , Java 5. JSR-133 .

5) Mergesort Java 7. , IllegalArgumentException. .

6) java , ( , , escape- Java 8, ), .

VM: VM, , / JIT, GC (, Azul Zulu c4 ) , Excelsior JET. , JVM.

Java/JVM:

1) . , -XX: + UseBiasedLocking -XX: BiasedLockingStartupDelay = n concurrency, . . Azul Zulu - STW, (, , , STW ).

2) XX: + AlwaysPreTouch JVM, linux .

4) -XX: + BindGCTaskThreadsToCPU JDK8, , , gc:)

5) -XX: + UseNUMA NUMA, JVM NUMA. , " 40% NUMA- ".

6) -XX: + UseCondCardMark , . java- 512 ( "" ), ( , 9). , 64 L1. , 32kByte (= 512 * 64) , . -XX: + UseCondCardMark if (card[address >> 9] == 0) card[address >> 9] = 1, 32 .

7) , GC, , , gc .

+3

All Articles