[Jython-checkins] jython: Add an indy switch to the build process. Jython is build using invokedyanmic

frank.wierzbicki jython-checkins at python.org
Wed Mar 14 04:09:32 CET 2012


http://hg.python.org/jython/rev/e3e82ea6bc53
changeset:   6348:e3e82ea6bc53
user:        Shashank Bharadwaj <shanka.mns at gmail.com>
date:        Tue Mar 13 16:06:09 2012 -0700
summary:
  Add an indy switch to the build process. Jython is build using invokedyanmic support only if it's built on JDK 1.7. Anything else would cause it to build a non-indy version
The user can override this by passing "jython.use.invokedyanmic=true" to ant like so: "ant -Djython.use.invokedynamic=true" but the build will fail for all JDK's less than 1.7
Added a dummy indy compiler which does nothing just to test the build process.

files:
  build.xml                                              |  17 +++++-
  src/org/python/compiler/InvokedynamicCodeCompiler.java |  24 ++++++++++
  2 files changed, 37 insertions(+), 4 deletions(-)


diff --git a/build.xml b/build.xml
--- a/build.xml
+++ b/build.xml
@@ -130,7 +130,14 @@
         <property name="jython.micro_version" value="0"/>
         <property name="jython.release_level" value="${PY_RELEASE_LEVEL_ALPHA}"/>
         <property name="jython.release_serial" value="0"/>
-
+		
+    	<!--- Indy support -->
+    	<condition property="jython.use.invokedynamic">
+			<equals arg1="${java.specification.version}" arg2="1.7"/>
+    	</condition>
+    	<condition property="jython.java.version" value="1.7" else="1.6">
+    		<isset property="jython.use.invokedynamic"/>
+    	</condition>
         <condition property="do.snapshot.build">
             <isset property="snapshot.revision" />
         </condition>
@@ -145,8 +152,8 @@
             <os family="windows"/>
         </condition>
         <property name="build.compiler" value="modern" />
-        <property name="jdk.target.version" value="1.6" />
-        <property name="jdk.source.version" value="1.6" />
+        <property name="jdk.target.version" value="${jython.java.version}" />
+        <property name="jdk.source.version" value="${jython.java.version}" />
         <property name="deprecation" value="true" />
         <property name="debug" value="true" />
         <property name="nowarn" value="false" />
@@ -295,6 +302,7 @@
         <echo>templates.lazy     = '${templates.lazy}'</echo>
         <echo>python.lib         = '${python.lib}'</echo>
         <echo>build.compiler     = '${build.compiler}'</echo>
+    	<echo>jython.use.invokedynamic = '${jython.use.invokedynamic}'</echo>
         <echo>jdk.target.version = '${jdk.target.version}'</echo>
         <echo>jdk.source.version = '${jdk.source.version}'</echo>
         <echo>deprecation        = '${deprecation}'</echo>
@@ -528,7 +536,8 @@
             <compilerarg line="${javac.Xlint}"/>
             <src path="${source.dir}"/>
             <src path="${gensrc.dir}"/>
-
+        	<exclude name="org/python/compiler/InvokedynamicCodeCompiler.java" unless="jython.use.invokedynamic"/>
+        	<exclude name="org/python/compiler/indy/**" unless="jython.use.invokedynamic"/>
             <exclude name="**/handler/InformixDataHandler.java" unless="informix.present" />
             <exclude name="**/handler/OracleDataHandler.java" unless="oracle.present" />
             <classpath refid="main.classpath" />
diff --git a/src/org/python/compiler/InvokedynamicCodeCompiler.java b/src/org/python/compiler/InvokedynamicCodeCompiler.java
new file mode 100644
--- /dev/null
+++ b/src/org/python/compiler/InvokedynamicCodeCompiler.java
@@ -0,0 +1,24 @@
+package org.python.compiler;
+
+import java.lang.invoke.MethodHandles;
+import java.lang.invoke.MethodType;
+import java.lang.invoke.MutableCallSite;
+
+/**
+ * 
+ * @author shashank
+ */
+public class InvokedynamicCodeCompiler extends CodeCompiler {
+
+	public InvokedynamicCodeCompiler(Module module, boolean print_results) {
+		super(module, print_results);
+	}
+	
+	// just use indy functions to make sure the build process is proper.
+	public void foo(){
+		Class mhClazz = MethodHandles.class;
+		MethodType target = null;
+		new MutableCallSite(target);
+	}
+
+}

-- 
Repository URL: http://hg.python.org/jython


More information about the Jython-checkins mailing list