diff --git a/backport/LICENSE.txt b/backport/LICENSE.txt new file mode 100644 index 000000000..28c9615e4 --- /dev/null +++ b/backport/LICENSE.txt @@ -0,0 +1,29 @@ + Retrotranslator: a Java bytecode transformer that translates Java classes + compiled with JDK 5.0 into classes that can be run on JVM 1.4. + + Copyright (c) 2005, 2006 Taras Puchko + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 3. Neither the name of the copyright holders nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + THE POSSIBILITY OF SUCH DAMAGE. diff --git a/backport/readme.html b/backport/readme.html new file mode 100644 index 000000000..d4cafcf89 --- /dev/null +++ b/backport/readme.html @@ -0,0 +1,549 @@ + + + + Retrotranslator + + + + + + + + +

Retrotranslator

SourceForge.net Logo +
+ +

Contents

+
    +
  1. What is Retrotranslator?
  2. +
  3. What Java 5 features are supported?
  4. +
  5. How to use Retrotranslator from a command line?
  6. +
  7. How to use Retrotranslator from Apache Ant or Maven?
  8. +
  9. How to use Retrotranslator from IntelliJ IDEA?
  10. +
  11. How to use Just-in-Time Retrotranslator?
  12. +
  13. What Java 5 classes and methods are supported?
  14. +
  15. How to write an extension for Retrotranslator?
  16. +
  17. What are the limitations?
  18. +
  19. Alternative tools
  20. +
  21. Contact
  22. +
  23. License
  24. +
+ +

What is Retrotranslator?

+Retrotranslator is a Java bytecode transformer +that translates Java classes compiled with JDK 5.0 into classes that can be run on JVM 1.4. +It is a free, open-source tool based on the ASM bytecode manipulation framework +and concurrency utilities +backported to Java 1.4. + +

What Java 5 features are supported?

+ + +

How to use Retrotranslator from a command line?

+
    +
  1. Download + and unzip the binary distribution file Retrotranslator-n.n.n-bin.zip, + where n.n.n is the latest Retrotranslator release number. +
  2. +
  3. + Compile your classes with JDK 5.0 and put them into some directory, e.g. myclasses. +
  4. +
  5. + Go to the unzipped directory Retrotranslator-n.n.n-bin and execute:
    + java -jar retrotranslator-transformer-n.n.n.jar -srcdir myclasses +
  6. +
  7. + If you use Java 5 API put retrotranslator-runtime-n.n.n.jar and + backport-util-concurrent.jar into the classpath of your application. +
  8. +
  9. + Run or debug the application as usual on any JVM 1.4, preferably JRE 1.4.2. +
  10. +
+ +

The full command line syntax:
+ java -jar retrotranslator-transformer-n.n.n.jar <options> +
or
+ java -cp retrotranslator-transformer-n.n.n.jar net.sf.retrotranslator.transformer.Retrotranslator <options>

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
OptionDescriptionDefault
-srcdirDirectory with classes compiled using JDK 5.0 (may be specified several times).-
-srcjarJAR file with classes compiled using JDK 5.0 (may be specified several times).-
-destdirDirectory to place classes compatible with J2SE 1.4.Location of sources
-destjarJAR file to place classes compatible with J2SE 1.4.Location of sources
-stripsignAsks the translator to strip signature (generics) information.Off
-verboseAsks the translator for verbose output.Off
-lazyAsks the translator to transform only Java 5 classes.Off
-advancedAllows to override Java 1.4 methods for better Java 5 compatibility.Off
-verifyAsks the translator for warnings when references to unknown classes, methods, or fields are found.Off
-classpathThe classpath to use for verification including rt.jar, jce.jar, + jsse.jar (from JRE 1.4), retrotranslator-runtime-n.n.n.jar, + and backport-util-concurrent.jar.Current classpath
-srcmaskFiles to translate (either bytecode or UTF-8 text) , e.g. "*.class;*.tld". + Only three special characters are supported: "*?;".*.class
-embedPackage name for a private copy of retrotranslator-runtime-n.n.n.jar and + backport-util-concurrent.jar to be put into -destdir or -destjar. + This makes your application independent of other versions of Retrotranslator present in the classpath. + -
-retainapiAsks the translator to modify classes for JVM 1.4 compatibility but keep use of Java 5 API. + References introduced by a compiler will also remain unchanged, + like the use of java.lang.StringBuilder for string concatenation + or the implicit valueOf method call for autoboxing.Off
+

+ For example, if you have a Java 5 application myapplication5.jar you can use the following command + to produce myapplication4.jar that will run on J2SE 1.4 and is independent of Retrotranslator, + since required classes are added to the translated application with a different package name: +

+

+ java -jar retrotranslator-transformer-n.n.n.jar + -srcjar myapplication5.jar -destjar myapplication4.jar -embed com.mycompany.internal
+

+ +

How to use Retrotranslator from Apache Ant or Maven?

+ +

The distribution contains an integrated Apache Ant task + net.sf.retrotranslator.transformer.RetrotranslatorTask. It has the following syntax:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
AttributeDescriptionDefault
srcdirDirectory with classes compiled using JDK 5.0.-
srcjarJAR file with classes compiled using JDK 5.0.-
destdirDirectory to place classes compatible with J2SE 1.4.Location of sources
destjarJAR file to place classes compatible with J2SE 1.4.Location of sources
stripsignAsks the translator to strip signature (generics) information.Off
verboseAsks the translator for verbose output.Off
lazyAsks the translator to transform only Java 5 classes.Off
advancedAllows to override Java 1.4 methods for better Java 5 compatibility.Off
verifyAsks the translator for warnings when references to unknown classes, methods, or fields are found.Off
classpathThe classpath to use for verification including rt.jar, jce.jar, + jsse.jar (from JRE 1.4), retrotranslator-runtime-n.n.n.jar, + and backport-util-concurrent.jar. + Current classpath
srcmaskFiles to translate (either bytecode or UTF-8 text) , e.g. "*.class;*.tld". + Only three special characters are supported: "*?;".*.class
embedPackage name for a private copy of retrotranslator-runtime-n.n.n.jar and + backport-util-concurrent.jar to be put into -destdir or -destjar. + This makes your application independent of other versions of Retrotranslator present in the classpath. + -
retainapiAsks the translator to modify classes for JVM 1.4 compatibility but keep use of Java 5 API. + References introduced by a compiler will also remain unchanged, + like the use of java.lang.StringBuilder for string concatenation + or the implicit valueOf method call for autoboxing.Off
failonwarningIndicates whether the build will fail when there are verification warnings.On
+

+ You may use nested src elements to specify source directories or JAR files, and nested + classpath elements to specify classpath for verification. For example: +

+
+    <path id="classpath">
+        <fileset dir="lib" includes="**/*.jar"/>
+    </path>
+    <taskdef name="retrotranslator" classpathref="classpath"
+             classname="net.sf.retrotranslator.transformer.RetrotranslatorTask" />
+    <retrotranslator destdir="build/classes14" verify="true">
+        <src path="build/classes15"/>
+        <classpath location="${java14_home}/jre/lib/rt.jar"/>
+        <classpath refid="classpath"/>
+    </retrotranslator>
+
+

+ For Maven there is a + Retrotranslator plugin + from the Mojo Project. +

+

How to use Retrotranslator from IntelliJ IDEA?

+

+ To automatically translate and verify classes compiled by IntelliJ IDEA + you may download a plugin + that generates classes compatible with 1.4 virtual machines from your Java 5 source code. +

+ +

How to use Just-in-Time Retrotranslator?

+ +

+ JIT Retrotranslator is able to translate at runtime Java classes loaded with any classloader. + It works on J2SE 1.4 from Sun, IBM, BEA, and Apple, but does nothing on J2SE 5.0 and other platforms. + However translation at runtime consumes additional memory and processing resources and it will not + work if your classes make use of Java 5 API but were compiled with "-target 1.4". +

+ + +

What Java 5 classes and methods are supported?

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
PackageClassMethods and fieldsCompatibility notes
java.lang.annotation* (all classes)* (all methods) 
java.util.concurrent,
java.util.concurrent.atomic,
java.util.concurrent.locks
almost all classesalmost all methods + Backport of JSR 166
+ Condition.awaitNanos(long) method is supported but with + + very little accuracy guarantees. +
java.ioCloseable* + new Closeable[...] is replaced with new Object[...] +
Flushable* + new Flushable[...] is replaced with new Object[...] +
PrintStream + append(CharSequence), append(CharSequence, int, int), append(char) +  
PrintWriter + PrintWriter(File), PrintWriter(File, String), PrintWriter(String), PrintWriter(String, String) +  
Readerread(CharBuffer) 
Writer + append(CharSequence), append(CharSequence, int, int), append(char) +  
java.langAppendable* + + new Appendable[...] is replaced with new Object[...] +
BooleanparseBoolean(String), compareTo(Boolean) 
BytevalueOf(byte) 
CharactervalueOf(char) 
Class* (21 new methods) + Class.getMethod(String, Class...) and Class.getDeclaredMethod(String, Class...) are + intercepted in advanced mode to better support generics and covariant return types on several JVM implementations. +
Deprecated* 
DoublevalueOf(double) 
Enum* 
FloatvalueOf(float) 
IllegalArgumentExceptionIllegalArgumentException(String, Throwable),
+ IllegalArgumentException(Throwable)
 
IllegalStateExceptionIllegalStateException(String, Throwable),
+ IllegalStateException(Throwable)
 
IntegervalueOf(int) 
Iterable* + new Iterable[...] is replaced with new Object[...] +
LongvalueOf(long) 
Package* (4 new methods) 
Readable* + new Readable[...] is replaced with new Object[...] +
ShortvalueOf(short) 
Stringcontains(CharSequence),
contentEquals(CharSequence),
+ replace(CharSequence, CharSequence)
 
StringBuffer + StringBuffer(CharSequence), append(CharSequence), append(CharSequence, int, int), + insert(int, CharSequence), insert(int, CharSequence, int, int) +  
StringBuilder + All methods supported in StringBuffer + StringBuilder is replaced with StringBuffer
SuppressWarnings* 
SystemnanoTime(), clearProperty(String) + Backport of JSR 166
+ System.nanoTime() method precision + + may vary on different platforms. +
ThreadgetStackTrace(), getId() + Thread.getStackTrace() returns non-empty stack trace only for the current thread;
+ Thread.getId() does not reflect the order in which threads are created.
TypeNotPresentException* 
java.lang.reflectAnnotatedElement* + new AnnotatedElement[...] is replaced with new Object[...] +
Constructor* (11 new methods) 
Field* (8 new methods) 
GenericArrayType* 
GenericDeclaration* + new GenericDeclaration[...] is replaced with new Object[...] +
GenericSignatureFormatError* 
MalformedParameterizedTypeException* 
Method* (14 new methods) 
ParameterizedType* 
Type* + new Type[...] is replaced with new Object[...] +
TypeVariable* 
WildcardType* 
java.mathBigDecimal + BigDecimal(int), BigDecimal(long), ZERO, ONE, TEN, divideAndRemainder(BigDecimal), + divideToIntegralValue(BigDecimal), pow(int), remainder(BigDecimal), toPlainString(), valueOf(double), + valueOf(long)BigDecimal.setScale(int, int) supports negative scales in advanced mode.
java.rmi.serverRemoteObjectInvocationHandler* 
java.util.nioCharBuffer + append(CharSequence), append(CharSequence, int, int), append(char), read(CharBuffer) +  
java.utilAbstractQueue* +  
Arrays* (21 new methods) 
Collections* (13 new methods) + Backport of JSR 166 +
EnumMap* 
EnumSet* 
LinkedList* (5 new methods) 
PriorityQueue* 
Queue* + new Queue[...] is replaced with new Object[...] +
UUID* 
java.util.regexMatcher + quoteReplacement(String), toMatchResult() 
MatchResult* + new MatchResult[...] is replaced with new Object[...] +
Patternquote(String) 
+ +

How to write an extension for Retrotranslator?

+ +

+ Since most backported classes are discovered by Retrotranslator at translation time, + you may write an extension and simply put it into the Retrotranslator classpath to make it work. + For example, all references to + java.util.EnumSet + are replaced with references to + + net.sf.retrotranslator.runtime.java.util.EnumSet_ (trailing underscore) if the latter can be found. + But if you replace a whole class that exists in J2SE 1.4 you may encounter interoperability issues with other libraries. + So, for example, support for Java 5 fields, methods, and constructors of + java.math.BigDecimal is placed into + + + net.sf.retrotranslator.runtime.java.math._BigDecimal (leading underscore): +

+ +

+ However, if the backported methods require access + to non-public methods or fields of the instance, they cannot be fully handled by Retrotranslator. + While you can use reflection to access any data, translated code generally should not depend on security settings. + For example, it is impossible to write an implementation for methods getSource() + and setSource() of java.beans.PropertyEditorSupport that will work in any environment. + Also this approach cannot be used to replace instance field references. +

+

+ If you have written an extension that does not contain copyrighted code, you may send + a patch + under the Retrotranslator license. +

+ +

What are the limitations?

+ +

+ Basically, only classes, methods, and fields listed above should work, and other features, + like formatted input/output, are not supported. Known issues: +

+ + +

Alternative tools

+ + +

Contact

+ + +

License

+
+    Retrotranslator: a Java bytecode transformer that translates Java classes
+    compiled with JDK 5.0 into classes that can be run on JVM 1.4.
+
+    Copyright (c) 2005, 2006 Taras Puchko
+    All rights reserved.
+
+    Redistribution and use in source and binary forms, with or without
+    modification, are permitted provided that the following conditions
+    are met:
+    1. Redistributions of source code must retain the above copyright
+       notice, this list of conditions and the following disclaimer.
+    2. Redistributions in binary form must reproduce the above copyright
+       notice, this list of conditions and the following disclaimer in the
+       documentation and/or other materials provided with the distribution.
+    3. Neither the name of the copyright holders nor the names of its
+       contributors may be used to endorse or promote products derived from
+       this software without specific prior written permission.
+
+    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+    AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+    ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+    LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+    CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+    SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+    INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+    CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+    ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+    THE POSSIBILITY OF SUCH DAMAGE.
+
+ + diff --git a/backport/retrotranslator-runtime-1.0.8.jar b/backport/retrotranslator-runtime-1.0.8.jar new file mode 100644 index 000000000..e6472d402 Binary files /dev/null and b/backport/retrotranslator-runtime-1.0.8.jar differ diff --git a/backport/retrotranslator-transformer-1.0.8.jar b/backport/retrotranslator-transformer-1.0.8.jar new file mode 100644 index 000000000..499fa687d Binary files /dev/null and b/backport/retrotranslator-transformer-1.0.8.jar differ diff --git a/backport/translate.bat b/backport/translate.bat new file mode 100644 index 000000000..3348b95c4 --- /dev/null +++ b/backport/translate.bat @@ -0,0 +1,4 @@ +java -jar retrotranslator-transformer-1.0.8.jar -srcjar ../lib/struts2-core-2.0.0.jar -destjar struts2-core-j4-2.0.0.jar +java -jar retrotranslator-transformer-1.0.8.jar -srcjar ../lib/struts2-api-2.0.0.jar -destjar struts2-api-j4-2.0.0.jar +java -jar retrotranslator-transformer-1.0.8.jar -srcjar ../lib/struts2-extras-2.0.0.jar -destjar struts2-extras-j4-2.0.0.jar +java -jar retrotranslator-transformer-1.0.8.jar -srcjar ../lib/xwork-2.0-SNAPSHOT.jar -destjar xwork-j4-2.0-SNAPSHOT.jar