Bad PropertyDescriptior Performance on Java7wzberger Dec 15, 2011 8:10 AM
The test case below takes around 100ms with Java6 and around 5000ms with Java7 - is this a known Java7 bug?
public class PropertyDescriptorTest { public static void main(String[] args) { JComponent c = new JPanel(); String name = "name"; long start = System.currentTimeMillis(); try { for (int i=0; i<1000; i++) new PropertyDescriptor(name, c.getClass()).getReadMethod().invoke(c); } catch (Exception e) { e.printStackTrace(); } long stop = System.currentTimeMillis(); System.err.println(stop-start); } }
This content has been marked as final. Show 10 replies
1. Re: Bad PropertyDescriptior Performance on Java7gimbal2 Dec 15, 2011 9:17 AM (in response to wzberger)A google search for "java 7 PropertyDescriptor slow" doesn't return any direct results in any case. Are you using Java 7u2?
Normally I would rant about prematurely calling something a bug, but 5 seconds seems excessive for something so trivial. More testing needs to be done anyway, for example using a profiler to see exactly what is causing the huge delay.
2. Re: Bad PropertyDescriptior Performance on Java7sabre150 Dec 15, 2011 9:48 AM (in response to gimbal2)I can confirm there is a problem with 1.7.0.01 on Ubuntu 11.04 . It might be worth comparing the source code between 1.6 and 1.7 .
Edited by: sabre150 on Dec 15, 2011 3:47 PM
Doing a 'diff' between the two sources indicates fairly extensive changes between 1.6.0_27 and 1.7.0_01 .
3. Re: Bad PropertyDescriptior Performance on Java7wzberger Dec 15, 2011 10:02 AM (in response to gimbal2)Tried with Java7u0 and Java7u2 - the issue occurs for both.
4. Re: Bad PropertyDescriptior Performance on Java7EJP Feb 25, 2012 6:02 PM (in response to wzberger)Late answer, but I don't know why you would write code like that in the first place. You should use the Introspector to get the PropertyDescriptors for a class. Then they are constructed once, not 1000 times.
5. Re: Bad PropertyDescriptior Performance on Java7935194 May 4, 2012 5:51 PM (in response to EJP)I can confirm this issue in our software as well. Starting up our design suite in Java 7 takes 20 full seconds longer than it does in Java 6, and a profiler pins it in the constructor for PropertyDescriptor.
It looks like this bug which claims that the fix has been delivered, but I'm running 7u4 and it is still an issue.
6. Re: Bad PropertyDescriptior Performance on Java7EJP May 4, 2012 6:40 PM (in response to 935194)I still don't understand what the interest is in the time spent to construct thousands of PropertyDescriptors for the same class, when there is a built-in alternative that does it only once. Bugs are bugs but bad code is still bad code. Nor do i understand waiting for a fix to be delivered when a far better fix is in your own hands.
7. Re: Bad PropertyDescriptior Performance on Java7935194 May 7, 2012 5:14 PM (in response to EJP)EJP: I don't think you understand.
That test code simply demonstrates the problem. I do only instantiate a PropertyDescriptor once per property per class, and then they're found using the Introspector, but guess what: we've got a lot of them, and so it's really slow in Java 7. This slowdown only affects our app's startup time - after that it's fast, but it's a pretty serious slowdown at startup: an additional 20 seconds or so.
8. Re: Bad PropertyDescriptior Performance on Java7EJP May 7, 2012 8:03 PM (in response to 935194)I understood the code you posted. I didn't understand the code you didn't post.
9. Re: Bad PropertyDescriptior Performance on Java7935194 May 8, 2012 10:57 AM (in response to EJP)I haven't posted any code. I believe we are both referencing code posted above.
Look - don't jump into a forum thread that is discussing an genuine issue and bash the OP for how the SSCCE code is written, if that SSCCE illustrates the issue.
That code runs fast in Java 6, and slow in Java 7. We understand that it is a SSCCE. You wrote:
| ... but I don't know why you would write code like that in the first place
The reason why is simple: to demonstrate an issue for easy replication in a forum. That is all.
10. Re: Bad PropertyDescriptior Performance on Java7gimbal2 May 8, 2012 11:10 AM (in response to 935194)
carl_g wrote:If I understand the bug report correctly, its fixed for Java 8. But I can't imagine it won't be be backported to Java 7, which might mean it will end up in a possible 7u5 bugfix release.
It looks like this bug which claims that the fix has been delivered, but I'm running 7u4 and it is still an issue.