Home > front end >  Java static static variable cache problem
Java static static variable cache problem

Time:03-16

Encountered a problem today, CSDN mobile sisters help,,,,,,,,,

I am in Constant class definition defines a static variable
Public static final ints PAGER_SIZE=15;
Today due to business needs, I revise the public static final ints PAGER_SIZE=12, then the Constant that contains the class files, update to the tomcat server, restart the server but PAGER_SIZE straight or 15, replaced several times, restart several times tomcat or 15, then put the whole project all deleted, only effective up to redeploy
Project with spring +, the springmvc framework, could you tell me how to solve this problem,

CodePudding user response:

No one? Don't sink!

CodePudding user response:

Nobody answer?

CodePudding user response:

I also met, tomcat8, jdk1.8 inside a class defines a static final constant, modified the constant values compiled into the tomcat restart, the value of the access is still before is drunk and delete cache useless, can only close tomcat start time to just go..

CodePudding user response:

Know how to solve the problem, this problem is quite pit, if changed the static final constants, need to replace the modification. The class files, and call all the constants. Class, temporarily do not know much about the specific reasons,

CodePudding user response:

Static variables in the compiled, can write directly to the reference!

Constant class definition defines a static variable public static final ints PAGER_SIZE=15;

Business class used like this: String temp="Love" + Constant. PAGER_SIZE;

The actual compiled, the result is: the String temp="Love15";//compiler has been optimized, the code you modified PAGER_SIZE is useless

CodePudding user response:

Problem isn't static variables, but the final, final modify variables, where will directly after being quoted in reference writing to death, you updated variables, cited place because has written died, nature will not change
  • Related