You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mt...@apache.org on 2009/09/24 07:00:39 UTC
svn commit: r818372 - in /commons/sandbox/runtime/trunk:
build.properties.default configure
src/main/java/org/apache/commons/runtime/Library.java
Author: mturk
Date: Thu Sep 24 05:00:39 2009
New Revision: 818372
URL: http://svn.apache.org/viewvc?rev=818372&view=rev
Log:
Call setExecutable using reflection so we can keep Java 5 binary compatibility
Modified:
commons/sandbox/runtime/trunk/build.properties.default
commons/sandbox/runtime/trunk/configure
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Library.java
Modified: commons/sandbox/runtime/trunk/build.properties.default
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/build.properties.default?rev=818372&r1=818371&r2=818372&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/build.properties.default (original)
+++ commons/sandbox/runtime/trunk/build.properties.default Thu Sep 24 05:00:39 2009
@@ -31,8 +31,8 @@
version.suffix=-dev
# ----- Default Compile options -----------------------------------------------
-compile.source=1.6
-compile.target=1.6
+compile.source=1.5
+compile.target=1.5
compile.debug=off
compile.optimize=on
compile.deprecation=on
Modified: commons/sandbox/runtime/trunk/configure
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/configure?rev=818372&r1=818371&r2=818372&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/configure (original)
+++ commons/sandbox/runtime/trunk/configure Thu Sep 24 05:00:39 2009
@@ -32,8 +32,8 @@
topdir="${TOPDIR:=.}"
java_home="`echo $JAVA_HOME | tr '\\' '/' 2>/dev/null`"
-compile_source=6
-compile_target=6
+compile_source=5
+compile_target=5
has_64_bit=no
has_maintainer_mode=off
has_debug=off
@@ -121,9 +121,9 @@
--with-java-home=DIR Path to the Java SDK
[\$JAVA_HOME environment variable]
--with-java-source=VER Compile for Java source VER
- [Default 6]
+ [Default 5]
--with-java-target=VER Compile for Java target VER
- [Default 6]
+ [Default 5]
--with-host=NAME Configure for native HOST
[Default current host]
--with-cpu=NAME Configure for native CPU
Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Library.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Library.java?rev=818372&r1=818371&r2=818372&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Library.java (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Library.java Thu Sep 24 05:00:39 2009
@@ -20,6 +20,7 @@
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.IOException;
+import java.lang.reflect.Method;
import org.apache.commons.runtime.exception.*;
import org.apache.commons.runtime.util.Utils;
@@ -67,6 +68,25 @@
return res.replace('.', '/') + name;
}
+ /**
+ * Call {@code java.io.File.setExecutable} using reflection.
+ * This allows to maintaing the Java 5 binary compatibility.
+ */
+ private static void setExecutable(File file)
+ {
+ try {
+ Class<?> paramTypes[] = new Class[1];
+ Object paramValues[] = new Object[1];
+ paramTypes[0] = boolean.class;
+ paramValues[0] = true;
+ Method method = file.getClass().getMethod("setExecutable",
+ paramTypes);
+ method.invoke(file, paramValues);
+ } catch (Throwable t) {
+ // Java < 6
+ }
+ }
+
private static File extractResource(InputStream is, String name)
throws IllegalArgumentException, IOException
{
@@ -84,10 +104,10 @@
}
os.close();
/* Some platforms like HP-UX require the library
- * to have rwx permissions set.
- * This mandates Java 6 API however
+ * to have executable permissions set.
+ * This requires Java 6 however
*/
- f.setExecutable(true);
+ setExecutable(f);
/* Mark the extracted file for delete on JVM exit.
* Although windows platform cannot delete this file
* if library is successfully loaded it will succeed if