All modern Java compilers (Sun JDK compilers since 1.4, gcj, jikes, and
others) add an exception table entry around the monitorexit instruction in
the exception handler for a synchronized block. This triggers a bug in the
JIT compiler used in Sun JRE's up to at least version 1.2, causing the code
to enter an infinite loop, throwing IllegalMonitorStateExceptions. Thus,
code produced with -target 1.1 on all of these compilers cannot actually be
run on the intended target JVMs. Since I cannot actually fix the compilers
in question, and Sun has refused to fix this problem, I've attempted to
modify Proguard to fix their output.
I've attached a patch which removes these exception table entries when the
targetClassVersion is 1.2 or earlier. The instruction in question cannot
actually throw an exception under normal circumstances, unless there was an
error in the original bytecode, or a JNI call somehow corrupted the
internal JVM state, so this can be considered a "code size optimization".
However, as a side-effect, the resulting code actually runs correctly on
the JVMs it was intended for. The patch applies against the Proguard
4.5beta2 tarball. See the URLs in the patch for more background information
on the issue.
My primary use-case is compiling the Cortado applet, which is used to
provide Theora and Vorbis support in very old browsers, some of which still
ship very old JVMs. Since the entire point of this applet is to serve as a
fallback, it is important that it actually works on these old JVMs.
Eric Lafortune
None
None
Public
|
Date: 2009-11-07 23:56 Ok, we'll solve it like this. I've removed the MONITOR_EXIT line for the |
|
Date: 2009-11-07 20:42 I can confirm that just removing that line also produces code that actually |
|
Date: 2009-11-07 20:26 I assume you mean MONITOREXIT, but yes, I believe that would work. That was |
|
Date: 2009-11-07 20:07 Thanks for the detailed analysis and for the clean code. I would prefer to |
| Filename | Description | Download |
|---|---|---|
| proguard4.5beta2-remmonex.patch | Download |
| Field | Old Value | Date | By |
|---|---|---|---|
| priority | 5 | 2009-11-07 20:07 | lafortune |
| assigned_to | nobody | 2009-11-07 20:07 | lafortune |
| File Added | 349722: proguard4.5beta2-remmonex.patch | 2009-11-06 04:58 | tterribe |
Copyright © 2010 Geeknet, Inc. All rights reserved. Terms of Use