java - Inspecting a variable appears to be changing the behaviour of a run -
i'm debugging following code.
arraylist<arraylist<linkedlist<fileinfo>>> cache = emptycache(); private void addtocache(final fileinfo fileinfo) { final int first = 0xff & byte.valueof(fileinfo.getfirstbytefrommiddle()); final int second = 0xff & byte.valueof(fileinfo.getsecondbytefrommiddle()); if (first < 0 || second < 0) system.err.println("error"); cache.get(first).get(second).add(fileinfo); }
without breakpoint set on system.err.println("error")
, observe on console.
/library/java/javavirtualmachines/jdk1.8.0_25.jdk/contents/home/bin/java -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:58469,suspend=y,server=n -dfile.encoding=utf-8 -classpath "/library/java/javavirtualmachines/jdk1.8.0_25.jdk/contents/home/lib/ant-javafx.jar:/library/java/javavirtualmachines/jdk1.8.0_25.jdk/contents/home/lib/dt.jar:/library/java/javavirtualmachines/jdk1.8.0_25.jdk/contents/home/lib/javafx-mx.jar:/library/java/javavirtualmachines/jdk1.8.0_25.jdk/contents/home/lib/jconsole.jar:/library/java/javavirtualmachines/jdk1.8.0_25.jdk/contents/home/lib/sa-jdi.jar:/library/java/javavirtualmachines/jdk1.8.0_25.jdk/contents/home/lib/tools.jar:/library/java/javavirtualmachines/jdk1.8.0_25.jdk/contents/home/jre/lib/charsets.jar:/library/java/javavirtualmachines/jdk1.8.0_25.jdk/contents/home/jre/lib/deploy.jar:/library/java/javavirtualmachines/jdk1.8.0_25.jdk/contents/home/jre/lib/javaws.jar:/library/java/javavirtualmachines/jdk1.8.0_25.jdk/contents/home/jre/lib/jce.jar:/library/java/javavirtualmachines/jdk1.8.0_25.jdk/contents/home/jre/lib/jfr.jar:/library/java/javavirtualmachines/jdk1.8.0_25.jdk/contents/home/jre/lib/jfxswt.jar:/library/java/javavirtualmachines/jdk1.8.0_25.jdk/contents/home/jre/lib/jsse.jar:/library/java/javavirtualmachines/jdk1.8.0_25.jdk/contents/home/jre/lib/management-agent.jar:/library/java/javavirtualmachines/jdk1.8.0_25.jdk/contents/home/jre/lib/plugin.jar:/library/java/javavirtualmachines/jdk1.8.0_25.jdk/contents/home/jre/lib/resources.jar:/library/java/javavirtualmachines/jdk1.8.0_25.jdk/contents/home/jre/lib/rt.jar:/library/java/javavirtualmachines/jdk1.8.0_25.jdk/contents/home/jre/lib/ext/cldrdata.jar:/library/java/javavirtualmachines/jdk1.8.0_25.jdk/contents/home/jre/lib/ext/dnsns.jar:/library/java/javavirtualmachines/jdk1.8.0_25.jdk/contents/home/jre/lib/ext/jfxrt.jar:/library/java/javavirtualmachines/jdk1.8.0_25.jdk/contents/home/jre/lib/ext/localedata.jar:/library/java/javavirtualmachines/jdk1.8.0_25.jdk/contents/home/jre/lib/ext/nashorn.jar:/library/java/javavirtualmachines/jdk1.8.0_25.jdk/contents/home/jre/lib/ext/sunec.jar:/library/java/javavirtualmachines/jdk1.8.0_25.jdk/contents/home/jre/lib/ext/sunjce_provider.jar:/library/java/javavirtualmachines/jdk1.8.0_25.jdk/contents/home/jre/lib/ext/sunpkcs11.jar:/library/java/javavirtualmachines/jdk1.8.0_25.jdk/contents/home/jre/lib/ext/zipfs.jar:/users/petur/development/einfalda/einfalda/target/classes:/users/petur/.m2/repository/org/apache/commons/commons-collections4/4.0/commons-collections4-4.0.jar:/users/petur/.m2/repository/commons-io/commons-io/2.4/commons-io-2.4.jar:/applications/intellij idea 14.app/contents/lib/idea_rt.jar" eu.petur.einfalda.einfalda /users/petur/documents connected target vm, address: '127.0.0.1:58469', transport: 'socket' disconnected target vm, address: '127.0.0.1:58469', transport: 'socket' exception in thread "main" java.lang.arrayindexoutofboundsexception: -125 @ java.util.arraylist.elementdata(arraylist.java:418) @ java.util.arraylist.get(arraylist.java:431) @ eu.petur.einfalda.dupfinder.addtocache(dupfinder.java:94) @ eu.petur.einfalda.dupfinder.findduplicates(dupfinder.java:30) @ eu.petur.einfalda.einfalda.main(einfalda.java:23) process finished exit code 1
however, if set breakpoint on line system.err.println("error")
program runs fine , exits process finished exit code 0
. likewise if use system.out.println
display values of 2 varialbes, after have been set.
why can not reproduce bug when variable inspected before used?
i solved problem disabling jit using -djava.compiler=none
vm option. can imagine issue has optimization.
Comments
Post a Comment