JAVA bytecode optimization
Posted
by
Idob
on Stack Overflow
See other posts from Stack Overflow
or by Idob
Published on 2012-11-25T10:32:28Z
Indexed on
2012/11/25
11:04 UTC
Read the original article
Hit count: 164
java
|Performance
This is a basic question.
I have code which shouldn't run on metadata beans. All metadata beans are located under metadata package.
Now,
I use reflection API to find out whether a class is located in the the metadata package.
if (newEntity.getClass().getPackage().getName().contains("metadata"))
I use this If in several places within this code.
The question is: Should I do this once with:
boolean isMetadata = false
if (newEntity.getClass().getPackage().getName().contains("metadata")) {
isMetadata = true;
}
C++ makes optimizations and knows that this code was already called and it won't call it again. Does JAVA makes optimization? I know reflection API is a beat heavy and I prefer not to lose expensive runtime.
© Stack Overflow or respective owner