Debugger: "Skip simple getters"

How IDEA detects, whether a getter is simple?

Tom

0
11 comments
Avatar
Permanently deleted user

No one at JB knows it?

Tom

0
Avatar
Permanently deleted user

I'm pretty sure that a simple getter is a method similar to the following:

0
Avatar
Permanently deleted user

Cannot be, because for me much more difficult getter will be skipped as well.

Tom

0
Avatar
Permanently deleted user

Nope, currently the criterion is different: it bases only on the name of the getter, so any method that is considered as "getter"
will be skipped if the option is on.
Getters like the one from your example are inlined by javac, so they are skipped "automatically", they simply do not exist in the
bytecode :)
Anyway, Thomas correctly mentioned that debugger's notion of "simple getters" should be revised.

--
Best regards,
Eugene Zhuravlev
Software Developer
JetBrains Inc.
http://www.jetbrains.com
"Develop with pleasure!"


0
Avatar
Permanently deleted user

Hi Eugene,

Thanks for the answer.

Getters like the one from your example are inlined by javac,


Always? I always compile with optimization=off and detected such behaviour.

Tom

0
Avatar
Permanently deleted user

afaik the optimizations key doesn't affect javac's output.
And as for simple getters inlining - I think it's done always since jdk 1.4

--
Best regards,
Eugene Zhuravlev
Software Developer
JetBrains Inc.
http://www.jetbrains.com
"Develop with pleasure!"


"Thomas Singer (MoTJ)" <nomail@nodomain.com> wrote in message news:d5f197$b1k$1@is.intellij.net...

Hi Eugene,

>

Thanks for the answer.

>
>> Getters like the one from your example are inlined by javac,
>

Always? I always compile with optimization=off and detected such behaviour.

>

Tom



0
Avatar
Permanently deleted user

Hmm, I've tried it with JDK 1.5.0_03 and this example:

public class InlineGetter {
private int number;

public InlineGetter(int number) {
this.number = number;
}

public int getNumber() {
return number;
}

public void print() {
System.out.println("number = " + getNumber());
}
}

After compilation and un-"jad"ding I get:

public class InlineGetter
{

public InlineGetter(int number)
{
this.number = number;
}

public int getNumber()
{
return number;
}

public void print()
{
System.out.println((new StringBuilder()).append("number =
").append(getNumber()).toString());
}

private int number;
}

To me it looks like the getter is not inlined.

Tom

0
Avatar
Permanently deleted user

Then it is inlined by hotspot on runtime - I was wrong saying that it is missing from the bytecode.
Anyway, debugger acts as if there is no method.

--
Best regards,
Eugene Zhuravlev
Software Developer
JetBrains Inc.
http://www.jetbrains.com
"Develop with pleasure!"


"Thomas Singer (MoTJ)" <nomail@nodomain.com> wrote in message news:d5fj9f$43e$1@is.intellij.net...

Hmm, I've tried it with JDK 1.5.0_03 and this example:

>

public class InlineGetter {
private int number;

>

public InlineGetter(int number) {
this.number = number;
}

>

public int getNumber() {
return number;
}

>

public void print() {
System.out.println("number = " + getNumber());
}
}

>

After compilation and un-"jad"ding I get:

>

public class InlineGetter
{

>

public InlineGetter(int number)
{
this.number = number;
}

>

public int getNumber()
{
return number;
}

>

public void print()
{
System.out.println((new StringBuilder()).append("number = ").append(getNumber()).toString());
}

>

private int number;
}

>

To me it looks like the getter is not inlined.

>

Tom



0
Avatar
Permanently deleted user

Note that the inspection for "call to simple getter or setter within class" does check for the structure of the method contents, not just the name. If you're looking for code to fix the debugger, feel free to borrow.

--Dave Griffith

0
Avatar
Permanently deleted user

Thanks Dave,
but what to do with getters from libraries?

--
Best regards,
Eugene Zhuravlev
Software Developer
JetBrains Inc.
http://www.jetbrains.com
"Develop with pleasure!"

"Dave Griffith" <dave.griffith@cnn.com> wrote in message news:23320205.1115379254731.JavaMail.itn@is.intellij.net...

Note that the inspection for "call to simple getter or setter within class" does check for the structure of the method contents,
not just the name. If you're looking for code to fix the debugger, feel free to borrow.

>

--Dave Griffith



0
Avatar
Permanently deleted user


The inspection is only for calling simple getters/setters from within their own class, a very fussy style of coding. Thus, no questions about libraries.

--Dave Griffith

0

Please sign in to leave a comment.