Use eclipse to view stack allocation, and eclipse to view stacks
This article originated from a colleague who asked me:
String str1 = "abc ";
String str2 = "abc ";
String str3 = new String ("abc ");
Str1 = str2 is true, does it mean that str1 and str2 are allocated on the stack? They are not added to the new space.
Then LZ gave it a YY, and thought of a way to use eclipse to view the stack allocation of variables. The Authority remains to be verified. If it is inappropriate, please kindly advise!
The test procedure is as follows:
public class StackStringTest {public static void main(String[] args) {String str1 = "abc";String str2 = "abc";System.out.println(str1 == str2);String str3 = new String("abc");String str4 = new String("abc");System.out.println(str3 == str4);int a = 1;Integer b = new Integer(1);System.out.println(a);System.out.println(b);}}
Break each sentence and debug it in one step. The following result is displayed:
The conclusion is as follows:
1. whether it's String a = "a" or String a = new String ("a"), they are all allocated to the peer stack (all have IDs, while int type a does not have IDs)
2. the reason why str1 = str2 is true is that when the str2 = "abc" statement is executed, the system first detects the address space (id = 19) with the value "abc ), in order to save space, it will not re-create a new area for str2, but direct to the heap range where str1 is located, so the IDs of str1 and str2 are equal.
In eclipse, how does backtrace view the function call stack in eclipse?
This should be the case:
Window-> Open view
Select call hierarchy
Eclipse stack positioning other projects with high reward
Haha, it's very high. That's why the classification of this problem is too speechless... Khan ^_^ ~~~
Hello, the landlord. I tried the situation you said. The strange thing is that I don't have such a problem on my local computer and it points to a correct one, no matter whether Project a is running or Project B is pointing to it .....
So I suspect that your project compilation is still a problem;
Generally, the error message of the Java Class tracked by Eclipse is related to the Java Class file compilation,
Therefore, it is recommended to delete the class file under WebRoot/WEB-INF/classes in Project B (or A), so that Eclise can re-compile the source code in the src package, there are many methods to re-compile, as you mentioned earlier, it seems that "clean" does not work. The recommended operations are as follows: Right-click Project B (or A) and choose Properties to open the Java Build Path attribute page. On the "Source" tab, direct the Default Output Folder to another new Folder (such as the bin directory) in the project. After confirmation, exit! In this way, the binfile will have the latest Class file, and then enter the property page again, and reset the Default Output Folder to Project B (or) /WebRoot/WEB-INF/classes, Eclipse re-compile the Src Source file, so, it should not appear frequently Link error, you first try it, hope to help you; if you have any questions, contact me again. However, I have limited time and don't often go to qq to answer questions. I may be able to help you with the answer only when I have time ~~~