<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Jiramot.info &#187; re-engineer</title>
	<atom:link href="http://www.jiramot.info/tag/re-engineer/feed" rel="self" type="application/rss+xml" />
	<link>http://www.jiramot.info</link>
	<description>me?.note.each{ println it }</description>
	<lastBuildDate>Fri, 30 Jul 2010 19:57:08 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Cross-Compile java 1.5 to java 1.4 with Retrotranslator</title>
		<link>http://www.jiramot.info/cross-compile-java-15-to-java-14-with-retrotranslator</link>
		<comments>http://www.jiramot.info/cross-compile-java-15-to-java-14-with-retrotranslator#comments</comments>
		<pubDate>Thu, 13 Nov 2008 16:27:25 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Article]]></category>
		<category><![CDATA[re-engineer]]></category>

		<guid isPermaLink="false">http://www.jiramot.info/?p=33</guid>
		<description><![CDATA[Retrotranslator เป็น jar file ที่เอาไว้แปลง source และ byte code ของ java 1.5 ให้ไปรันที่ 1.4
จะ เปลี่ยนพวก library บางตัวที่ java 1.4 ไม่มี โดน Retrotranslator จะทำการแก้ ให้ไป call funcion ใน package ของ Retrotranslator แทนที่จะ call จาก library ของ java 1.5
Retrotranslator
Contents
What is Retrotranslator?
What Java 5 features are supported?
How to use Retrotranslator from a command line?
How to use Retrotranslator from [...]]]></description>
			<content:encoded><![CDATA[<p>Retrotranslator เป็น jar file ที่เอาไว้แปลง source และ byte code ของ java 1.5 ให้ไปรันที่ 1.4<br />
จะ เปลี่ยนพวก library บางตัวที่ java 1.4 ไม่มี โดน Retrotranslator จะทำการแก้ ให้ไป call funcion ใน package ของ Retrotranslator แทนที่จะ call จาก library ของ java 1.5</p>
<blockquote><p>Retrotranslator</p>
<p>Contents<br />
What is Retrotranslator?<br />
What Java 5 features are supported?<br />
How to use Retrotranslator from a command line?<br />
How to use Retrotranslator from Apache Ant or Maven?<br />
How to use Retrotranslator from IntelliJ IDEA?<br />
How to use Just-in-Time Retrotranslator?<br />
What Java 5 classes and methods are supported?<br />
How to write an extension for Retrotranslator?<br />
What are the limitations?<br />
Alternative tools<br />
Contact<br />
License<br />
What is Retrotranslator?<br />
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.<br />
What Java 5 features are supported?<br />
Generics (generic types)<br />
Annotations (metadata)<br />
Reflection on generics and annotations<br />
Typesafe enums (enumerated types)<br />
Autoboxing/unboxing<br />
Enhanced for loop (for-each loop)<br />
Varargs (variable arguments)<br />
Covariant return types<br />
Formatted output<br />
Static import<br />
Concurrency utilities<br />
Collections framework enhancements<br />
How to use Retrotranslator from a command line?<br />
Download and unzip the binary distribution file Retrotranslator-n.n.n-bin.zip, where n.n.n is the latest Retrotranslator release number.<br />
Compile your classes with JDK 5.0 and put them into some directory, e.g. myclasses.<br />
Go to the unzipped directory and execute:<br />
java -jar retrotranslator-transformer-n.n.n.jar -srcdir myclasses<br />
If you use Java 5 API put retrotranslator-runtime-n.n.n.jar and backport-util-concurrent-n.n.jar into the classpath of your application.<br />
Run or debug the application as usual on J2SE 1.4.x, preferably 1.4.2.<br />
The full command line syntax:<br />
java -jar retrotranslator-transformer-n.n.n.jar<br />
or<br />
java -cp retrotranslator-transformer-n.n.n.jar net.sf.retrotranslator.transformer.Retrotranslator Option Description Default<br />
-srcdir The directory with classes that should be translated (may be specified several times). -<br />
-srcjar The JAR file with classes that should be translated (may be specified several times). -<br />
-destdir The directory to place translated classes. Location of sources<br />
-destjar The JAR file to place translated classes. Location of sources<br />
-advanced Whether to use alternative implementations of Java 1.4 classes and methods for better Java 5 compatibility. Off<br />
-verify Asks the translator to examine translated bytecode for references to classes, methods, or fields that cannot be found in the provided classpath. Off<br />
-classpath The classpath for verification including rt.jar, jce.jar, jsse.jar (from JRE 1.4), retrotranslator-runtime-n.n.n.jar, and backport-util-concurrent-n.n.jar. Current classpath<br />
-srcmask The wildcard pattern specifying files that should be translated (either bytecode or UTF-8 text), e.g. &#8220;*.class;*.tld&#8221;. There are three special characters: &#8220;*?;&#8221;. *.class<br />
-embed Package name for a private copy of retrotranslator-runtime-n.n.n.jar and backport-util-concurrent-n.n.jar to be put into -destdir or -destjar. This makes your application independent of other versions of Retrotranslator present in the classpath. -<br />
-backport Informs the translator about user-defined backport packages. Package names should be separated by semicolons. -<br />
-target To make Java 6 classes compatible with Java 5 set this option to 1.5 and supply user-defined backport packages via the backport option. 1.4<br />
-lazy Asks the translator to only transform classes compiled with a target greater than the current one. Off<br />
-stripsign Asks the translator to strip signature (generics) information. Off<br />
-verbose Asks the translator for verbose output. Off<br />
-retainapi Asks 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<br />
-retainflags Asks the translator to keep Java 5 specific access modifiers. Off</p>
<p>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:</p>
<p>java -jar retrotranslator-transformer-n.n.n.jar -srcjar myapplication5.jar -destjar myapplication4.jar -embed com.mycompany.internal</p>
<p>How to use Retrotranslator from Apache Ant or Maven?<br />
The distribution contains an integrated Apache Ant task net.sf.retrotranslator.transformer.RetrotranslatorTask. It has the following syntax: Attribute Description Default<br />
srcdir The directory with classes that should be translated. -<br />
srcjar The JAR file with classes that should be translated. -<br />
destdir The directory to place translated classes. Location of sources<br />
destjar The JAR file to place translated classes. Location of sources<br />
advanced Whether to use alternative implementations of Java 1.4 classes and methods for better Java 5 compatibility. Off<br />
verify Asks the translator to examine translated bytecode for references to classes, methods, or fields that cannot be found in the provided classpath. Off<br />
classpath The classpath for the verification, including rt.jar, jce.jar, jsse.jar (from JRE 1.4), retrotranslator-runtime-n.n.n.jar, and backport-util-concurrent-n.n.jar. Current classpath<br />
classpathref The classpath for the verification, given as a reference to a path defined elsewhere. Current classpath<br />
srcmask The wildcard pattern specifying files that should be translated (either bytecode or UTF-8 text), e.g. &#8220;*.class;*.tld&#8221;. There are three special characters: &#8220;*?;&#8221;. *.class<br />
embed Package name for a private copy of retrotranslator-runtime-n.n.n.jar and backport-util-concurrent-n.n.jar to be put into -destdir or -destjar. This makes your application independent of other versions of Retrotranslator present in the classpath. -<br />
backport Informs the translator about user-defined backport packages. Package names should be separated by semicolons. -<br />
target Set this option to 1.5 and supply user-defined backport packages via the backport option to make Java 6 classes compatible with Java 5. 1.4<br />
lazy Asks the translator to only transform classes compiled with a target greater than the current one. Off<br />
stripsign Asks the translator to strip signature (generics) information. Off<br />
verbose Asks the translator for verbose output. Off<br />
retainapi Asks 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<br />
retainflags Asks the translator to keep Java 5 specific access modifiers. Off<br />
failonwarning Indicates whether the build will fail when there are verification warnings. On</p>
<p>You may use nested fileset, jarfileset, and dirset elements to specify source files and classpath elements to specify classpath. For example:</p>
<p>classname=&#8221;net.sf.retrotranslator.transformer.RetrotranslatorTask&#8221; /&gt;</p>
<p>The source directories specified by srcdir, dirset, and the dir attribute of fileset should contain the &#8220;root&#8221; package of your classes.</p>
<p>For Maven there is a Retrotranslator plugin from the Mojo Project.</p>
<p>How to use Retrotranslator from IntelliJ IDEA?<br />
There is a plugin to automatically translate and verify classes compiled by IntelliJ IDEA, so you can develop in Java 5 but run and debug on JRE 1.4.</p>
<p>How to use Just-in-Time Retrotranslator?<br />
JIT Retrotranslator is able to translate at runtime Java classes loaded with any classloader. It works on J2SE 1.4 from most JVM vendors like Sun, IBM, BEA, and Apple, but does nothing on J2SE 5.0. 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 &#8220;-target 1.4&#8243;.</p>
<p>If you want to run a JAR file with the JIT, execute:<br />
java -cp retrotranslator-transformer-n.n.n.jar net.sf.retrotranslator.transformer.JITRetrotranslator -jar []<br />
When the first option does not work or if you just want to run a class from your classpath, execute:<br />
java -cp retrotranslator-transformer-n.n.n.jar: net.sf.retrotranslator.transformer.JITRetrotranslator []<br />
Alternatively you may simply call new JITRetrotranslator().run() from some JVM 1.4 compatible class before Java 5 classes are loaded.<br />
JIT Retrotranslator can accept the advanced and backport options.</p>
<p>What Java 5 classes and methods are supported?<br />
Package Class Methods and fields Compatibility notes<br />
java.lang.annotation * (all classes) * (all methods)<br />
java.lang.instrument * (all classes) * (all methods) Bytecode instrumentation is not implemented.<br />
java.util.concurrent,<br />
java.util.concurrent.atomic,<br />
java.util.concurrent.locks almost all classes1 almost all methods The LockSupport class may be unusable due to poor efficiency. The Condition.awaitNanos(long) method has little accuracy guarantees.<br />
java.io Closeable2 *<br />
Flushable2 *<br />
PrintStream * (11 new methods and constructors)<br />
PrintWriter * (11 new methods and constructors) The PrintWriter.format and PrintWriter.printf methods always flush the output buffer.<br />
Reader read(CharBuffer)<br />
Writer append(CharSequence),<br />
append(CharSequence, int, int),<br />
append(char)<br />
java.lang Appendable2 *<br />
Boolean parseBoolean(String),<br />
compareTo(Boolean)<br />
Byte valueOf(byte)<br />
Character * New members of Character.UnicodeBlock are not supported. All supplementary code points are considered as unassigned.<br />
Class * (21 new methods) Class.getMethod(String, Class&#8230;) and Class.getDeclaredMethod(String, Class&#8230;) are intercepted to better support generics and covariant return types on several platforms3.<br />
Deprecated *<br />
Double valueOf(double)<br />
Enum *<br />
Float valueOf(float)<br />
IllegalArgumentException IllegalArgumentException(String, Throwable),<br />
IllegalArgumentException(Throwable)<br />
IllegalStateException IllegalStateException(String, Throwable),<br />
IllegalStateException(Throwable)<br />
Integer valueOf(int), signum(int)<br />
Iterable2 *<br />
Long valueOf(long), signum(long)<br />
Package * (4 new methods)<br />
Readable2 *<br />
Short valueOf(short)<br />
String *<br />
isEmpty()4<br />
StringBuffer StringBuffer(CharSequence),<br />
append(CharSequence),<br />
append(CharSequence, int, int),<br />
appendCodePoint(int),<br />
codePointAt(int),<br />
codePointBefore(int),<br />
codePointCount(int, int),<br />
insert(int, CharSequence),<br />
insert(int, CharSequence, int, int),<br />
offsetByCodePoints(int, int)<br />
StringBuilder All methods supported in StringBuffer StringBuilder is replaced with StringBuffer.<br />
SuppressWarnings *<br />
System nanoTime()1,<br />
clearProperty(String) The System.nanoTime() method precision may vary on different platforms.<br />
Thread getStackTrace(),<br />
getId() The Thread.getStackTrace() method returns non-empty stack trace only for the current thread.<br />
The Thread.getId() method does not reflect the order in which threads are created.<br />
Thread.State *<br />
ThreadLocal remove()3 ThreadLocal and InheritableThreadLocal are replaced by corresponding classes from the runtime library.3.<br />
TypeNotPresentException *<br />
java.lang.ref SoftReference * SoftReference(Object,ReferenceQueue) supports null for the second parameter on all platforms3.<br />
WeakReference * WeakReference(Object,ReferenceQueue) supports null for the second parameter on all platforms3.<br />
java.lang.reflect AccessibleObject *<br />
AnnotatedElement2 *<br />
Constructor * (11 new methods)<br />
Field * (8 new methods)<br />
GenericArrayType *<br />
GenericDeclaration2 *<br />
GenericSignatureFormatError *<br />
MalformedParameterizedTypeException *<br />
Method * (14 new methods)<br />
ParameterizedType *<br />
Type2 *<br />
TypeVariable *<br />
WildcardType *<br />
java.math BigDecimal BigDecimal(int),<br />
BigDecimal(long),<br />
ZERO, ONE, TEN,<br />
divideAndRemainder(BigDecimal),<br />
divideToIntegralValue(BigDecimal),<br />
pow(int),<br />
remainder(BigDecimal),<br />
toPlainString(),<br />
valueOf(double),<br />
valueOf(long) The BigDecimal.setScale(int, int) method supports negative scales3.<br />
java.net URL openConnection(Proxy),<br />
toURI() The Proxy is ignored by the openConnection(Proxy) method.<br />
Proxy *<br />
ProxySelector *<br />
java.nio CharBuffer append(CharSequence),<br />
append(CharSequence, int, int),<br />
append(char),<br />
read(CharBuffer)<br />
java.rmi.server RemoteObjectInvocationHandler *<br />
java.text DecimalFormat isParseBigDecimal()3,<br />
setParseBigDecimal(boolean)3 BigDecimal parsing and formatting precision is limited by java.lang.Double or java.lang.Long precision.<br />
java.util AbstractQueue1 *<br />
ArrayDeque1,4 *<br />
Arrays * (21 new methods)<br />
copyOf(&#8230;)4 (10 methods)<br />
copyOfRange(&#8230;)4 (10 methods)<br />
Collections1 * (13 new methods)<br />
newSetFromMap(Map)4<br />
Deque1,2,4 *<br />
EnumMap *<br />
EnumSet *<br />
Formatter *<br />
LinkedList * (5 new methods)<br />
PriorityQueue1 *<br />
Queue1,2 *<br />
UUID *<br />
java.util.regex Matcher quoteReplacement(String),<br />
toMatchResult()<br />
MatchResult2 *<br />
Pattern quote(String)</p>
<p>1 Supported via the Backport of JSR 166.<br />
2 In most cases this type is being replaced with it&#8217;s base type.<br />
3 Supported only in advanced mode, i.e. when the advanced option is specified.<br />
4 Introduced in Java 6, but available only for 1.4 target.</p>
<p>How to write an extension for Retrotranslator?<br />
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_ (optional 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):</p>
<p>For a static field there is a public static field with the same name and type.<br />
For a static method there is a public static method with the same signature.<br />
For an instance method there is a public static method with the same signature but with an additional first parameter representing the instance.<br />
For a constructor there is a public static convertConstructorArguments method that accepts constructor&#8217;s arguments an returns an argument for a Java 1.4 constuctor.<br />
Another approach for constructor backporting is used by net.sf.retrotranslator.runtime.java.io._PrintStream. There is a public static createInstanceBuilder method that accepts constructor&#8217;s arguments an returns an object with public argument1&#8230;argumentN methods and optional public void initialize method. All argumentX methods provide arguments for a Java 1.4 constuctor and should not have any parameters. The initialize method has a single parameter for the created instance and may be used for postprocessing.</p>
<p>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.</p>
<p>You can put your extensions into packages other than net.sf.retrotranslator.runtime. For example, specify the following at the command line to make Retrotranslator use com.mycompany.internal.java.lang._String and to rewrite all references to com.sun.org.apache.xerces.internal.* with org.apache.xerces.*:<br />
-backport com.mycompany.internal;com.sun.org.apache.xerces.internal:org.apache.xerces<br />
It is even possible to substitute specific classes. The following options can be used to replace StringBuilder with StringBuffer and disable use of backported Java 5 classes:<br />
-retainapi -backport java.lang.StringBuilder:java.lang.StringBuffer</p>
<p>If you have written an extension that does not contain copyrighted code, you may send a patch under the Retrotranslator license.</p>
<p>What are the limitations?<br />
Basically, only classes, methods, and fields listed above should work, and other features, like formatted input, are not supported. Known issues:</p>
<p>Reflection-based tools may be unable to discover additional classes and methods introduced in Java 5 when running on JRE 1.4.<br />
Translated code running on JRE 5.0 may be incompatible with other Java 5 code when Java 5 API is used.<br />
Reflection on generics and metadata may return incomplete information for dynamically generated classes.<br />
Constants inlined by a compiler and access modifiers are ignored during the verification.<br />
Inherited methods introduced in Java 5 may not work, however upcasting may help in some cases:<br />
((Writer) new FileWriter(&#8220;file.tmp&#8221;)).append(&#8220;Hello&#8221;).close();<br />
Serialized objects produced by translated code may be incompatible with JRE 5.0.<br />
Alternative tools<br />
Retroweaver<br />
Declawer<br />
JBossRetro<br />
Contact<br />
Latest documentation<br />
Open discussion<br />
Help<br />
Bugs<br />
Feature requests<br />
Author<br />
License<br />
Copyright (c) 2005 &#8211; 2007 Taras Puchko<br />
All rights reserved.</p>
<p>Redistribution and use in source and binary forms, with or without<br />
modification, are permitted provided that the following conditions<br />
are met:<br />
1. Redistributions of source code must retain the above copyright<br />
notice, this list of conditions and the following disclaimer.<br />
2. Redistributions in binary form must reproduce the above copyright<br />
notice, this list of conditions and the following disclaimer in the<br />
documentation and/or other materials provided with the distribution.<br />
3. Neither the name of the copyright holders nor the names of its<br />
contributors may be used to endorse or promote products derived from<br />
this software without specific prior written permission.</p>
<p>THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS &#8220;AS IS&#8221;<br />
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE<br />
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE<br />
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE<br />
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR<br />
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF<br />
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS<br />
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN<br />
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)<br />
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF<br />
THE POSSIBILITY OF SUCH DAMAGE.</p></blockquote>
<p>ที่มา http://retrotranslator.sourceforge.net/</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jiramot.info/cross-compile-java-15-to-java-14-with-retrotranslator/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
