The 'print' (and 'dump') command in jdb can resolve the value of a field in 'this' without you actually specifying 'this.' before the identifier, but when this happens, it throws away the rest of the line. This means that any array index or field reference after the identifier name is ignored.
To use this test case, type this:
javac -g Print.java
jdb Print
stop in Print.stop
run
---
This is the output for some print commands. The text after the identifier
(x and p respectively) is ignored.
main[1] print x[0]
this.x = { value of x[0] } <-- the whole x array is given, not x[0]
main[1] print p.x[0]
this.p = Print@1dc60ce7 <-- object p is given, not p.x[0]
main[1]
But if you add 'this.' at the start, it works properly.
main[1] print this.x[0]
this.x[0] = value of x[0]
main[1] print this.p.x[0]
this.p.x[0] = value of p.x[0]
main[1]
For the first case, this is what you SHOULD see:
main[1] print x[0]
this.x[0] = value of x[0]
main[1] print p.x[0]
this.p.x[0] = value of p.x[0]
main[1]
--- Here is the test case code:
public class Print
{
String x[] = new String[1];
Print p;
public static void main(String argv[])
{
Print p = new Print();
p.x[0] = "value of x[0]";
p.p = new Print();
p.p.x[0] = "value of p.x[0]";
p.stop();
}
void stop()
{
}
}
To use this test case, type this:
javac -g Print.java
jdb Print
stop in Print.stop
run
---
This is the output for some print commands. The text after the identifier
(x and p respectively) is ignored.
main[1] print x[0]
this.x = { value of x[0] } <-- the whole x array is given, not x[0]
main[1] print p.x[0]
this.p = Print@1dc60ce7 <-- object p is given, not p.x[0]
main[1]
But if you add 'this.' at the start, it works properly.
main[1] print this.x[0]
this.x[0] = value of x[0]
main[1] print this.p.x[0]
this.p.x[0] = value of p.x[0]
main[1]
For the first case, this is what you SHOULD see:
main[1] print x[0]
this.x[0] = value of x[0]
main[1] print p.x[0]
this.p.x[0] = value of p.x[0]
main[1]
--- Here is the test case code:
public class Print
{
String x[] = new String[1];
Print p;
public static void main(String argv[])
{
Print p = new Print();
p.x[0] = "value of x[0]";
p.p = new Print();
p.p.x[0] = "value of p.x[0]";
p.stop();
}
void stop()
{
}
}