rJava/0000755000176200001440000000000012256142140011312 5ustar liggesusersrJava/inst/0000755000176200001440000000000012256051770012277 5ustar liggesusersrJava/inst/java/0000755000176200001440000000000012256051770013220 5ustar liggesusersrJava/inst/java/FlatException.class0000644000176200001440000000042212256051770017012 0ustar liggesusers.   ()VCodeLineNumberTable SourceFileFlatException.java#Can only flatten rectangular arrays  FlatExceptionjava/lang/Exception(Ljava/lang/String;)V!#*   rJava/inst/java/RJavaTools_Test$TestException.class0000644000176200001440000000047012256051770022056 0ustar liggesusers.   (Ljava/lang/String;)VCodeLineNumberTable SourceFileRJavaTools_Test.java RJavaTools_Test$TestException TestException InnerClassesjava/lang/ExceptionRJavaTools_Test!"*+    rJava/inst/java/ObjectArrayException.java0000644000176200001440000000040112256051770020142 0ustar liggesusers/** * Generated when one tries to access an array of primitive * values as an array of Objects */ public class ObjectArrayException extends Exception{ public ObjectArrayException(String type){ super( "array is of primitive type : " + type ) ; } } rJava/inst/java/RJavaTools.java0000644000176200001440000005171312256051770016116 0ustar liggesusers// RJavaTools.java: rJava - low level R to java interface // // Copyright (C) 2009 - 2010 Simon Urbanek and Romain Francois // // This file is part of rJava. // // rJava is free software: you can redistribute it and/or modify it // under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 2 of the License, or // (at your option) any later version. // // rJava is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with rJava. If not, see . import java.lang.reflect.Method ; import java.lang.reflect.Field ; import java.lang.reflect.Constructor ; import java.lang.reflect.InvocationTargetException ; import java.lang.reflect.Modifier ; import java.lang.reflect.Member ; import java.util.Vector ; /** * Tools used internally by rJava. * * The method lookup code is heavily based on ReflectionTools * by Romain Francois licensed under GPL v2 or higher. */ public class RJavaTools { /** * Returns an inner class of the class with the given simple name * * @param cl class * @param name simple name of the inner class * @param staticRequired boolean, if true the inner class is required to be static */ public static Class getClass(Class cl, String name, boolean staticRequired){ Class[] clazzes = cl.getClasses(); for( int i=0; iFor fields, it just returns the name of the fields * *

For methods, this returns the name of the method * plus a suffix that depends on the number of arguments of the method. * *

The string "()" is added * if the method has no arguments, and the string "(" is added * if the method has one or more arguments. */ public static String getCompletionName(Member m){ if( m instanceof Field ) return m.getName(); if( m instanceof Method ){ String suffix = ( ((Method)m).getParameterTypes().length == 0 ) ? ")" : "" ; return m.getName() + "(" + suffix ; } return "" ; } /** * Indicates if a member of a Class (field, method ) is static * * @param member class member * @return true if the member is static */ public static boolean isStatic( Member member ){ return (member.getModifiers() & Modifier.STATIC) != 0 ; } /** * Checks if the class of the object has the given field. The * getFields method of Class is used so only public fields are * checked * * @param o object * @param name name of the field * * @return true if the class of o has the field name */ public static boolean hasField(Object o, String name) { return classHasField(o.getClass(), name, false); } /** * Checks if the class of the object has the given inner class. The * getClasses method of Class is used so only public classes are * checked * * @param o object * @param name (simple) name of the inner class * * @return true if the class of o has the class name */ public static boolean hasClass(Object o, String name) { return classHasClass(o.getClass(), name, false); } /** * Checks if the specified class has the given field. The * getFields method of Class is used so only public fields are * checked * * @param cl class object * @param name name of the field * @param staticRequired if true then the field is required to be static * * @return true if the class cl has the field name */ public static boolean classHasField(Class cl, String name, boolean staticRequired) { Field[] fields = cl.getFields(); for (int i = 0; i < fields.length; i++) if(name.equals(fields[i].getName()) && (!staticRequired || ((fields[i].getModifiers() & Modifier.STATIC) != 0))) return true; return false; } /** * Checks if the specified class has the given method. The * getMethods method of Class is used so only public methods are * checked * * @param cl class * @param name name of the method * @param staticRequired if true then the method is required to be static * * @return true if the class cl has the method name */ public static boolean classHasMethod(Class cl, String name, boolean staticRequired) { Method[] methodz = cl.getMethods(); for (int i = 0; i < methodz.length; i++) if (name.equals(methodz[i].getName()) && (!staticRequired || ((methodz[i].getModifiers() & Modifier.STATIC) != 0))) return true; return false; } /** * Checks if the specified class has the given inner class. The * getClasses method of Class is used so only public classes are * checked * * @param cl class * @param name name of the inner class * @param staticRequired if true then the method is required to be static * * @return true if the class cl has the field name */ public static boolean classHasClass(Class cl, String name, boolean staticRequired) { Class[] clazzes = cl.getClasses(); for (int i = 0; i < clazzes.length; i++) if (name.equals( getSimpleName(clazzes[i].getName()) ) && (!staticRequired || isStatic( clazzes[i] ) ) ) return true; return false; } /** * Checks if the class of the object has the given method. The * getMethods method of Class is used so only public methods are * checked * * @param o object * @param name name of the method * * @return true if the class of o has the field name */ public static boolean hasMethod(Object o, String name) { return classHasMethod(o.getClass(), name, false); } /** * Object creator. Find the best constructor based on the parameter classes * and invoke newInstance on the resolved constructor */ public static Object newInstance( Class o_clazz, Object[] args, Class[] clazzes ) throws Throwable { boolean[] is_null = new boolean[args.length]; for( int i=0; iFirst the appropriate method is resolved by getMethod and * then invokes the method */ public static Object invokeMethod( Class o_clazz, Object o, String name, Object[] args, Class[] clazzes) throws Throwable { Method m = getMethod( o_clazz, name, clazzes, arg_is_null(args) ); /* enforcing accessibility (workaround for bug 128) */ boolean access = m.isAccessible(); m.setAccessible( true ); Object out; try{ out = m.invoke( o, args ) ; } catch( InvocationTargetException e){ /* the target exception is much more useful than the reflection wrapper */ throw e.getTargetException() ; } finally{ m.setAccessible( access ); } return out ; } /** * Attempts to find the best-matching constructor of the class * o_clazz with the parameter types arg_clazz * * @param o_clazz Class to look for a constructor * @param arg_clazz parameter types * @param arg_is_null indicates if each argument is null * * @return null if no constructor is found, or the constructor * */ public static Constructor getConstructor( Class o_clazz, Class[] arg_clazz, boolean[] arg_is_null) throws SecurityException, NoSuchMethodException { if (o_clazz == null) return null; Constructor cons = null ; /* if there is no argument, try to find a direct match */ if (arg_clazz == null || arg_clazz.length == 0) { cons = o_clazz.getConstructor( (Class[] )null ); return cons ; } /* try to find an exact match */ try { cons = o_clazz.getConstructor(arg_clazz); if (cons != null) return cons ; } catch (NoSuchMethodException e) { /* we catch this one because we want to further search */ } /* ok, no exact match was found - we have to walk through all methods */ cons = null; Constructor[] candidates = o_clazz.getConstructors(); for (int k = 0; k < candidates.length; k++) { Constructor c = candidates[k]; Class[] param_clazz = c.getParameterTypes(); if (arg_clazz.length != param_clazz.length) // number of parameters must match continue; int n = arg_clazz.length; boolean ok = true; for (int i = 0; i < n; i++) { if( arg_is_null[i] ){ /* then the class must not be a primitive type */ if( isPrimitive(arg_clazz[i]) ){ ok = false ; break ; } } else{ if (arg_clazz[i] != null && !param_clazz[i].isAssignableFrom(arg_clazz[i])) { ok = false; break; } } } // it must be the only match so far or more specific than the current match if (ok && (cons == null || isMoreSpecific(c, cons))) cons = c; } if( cons == null ){ throw new NoSuchMethodException( "No constructor matching the given parameters" ) ; } return cons; } static boolean isPrimitive(Class cl){ return cl.equals(Boolean.TYPE) || cl.equals(Integer.TYPE) || cl.equals(Double.TYPE) || cl.equals(Float.TYPE) || cl.equals(Long.TYPE) || cl.equals(Short.TYPE) || cl.equals(Character.TYPE) ; } /** * Attempts to find the best-matching method of the class o_clazz with the method name name and arguments types defined by arg_clazz. * The lookup is performed by finding the most specific methods that matches the supplied arguments (see also {@link #isMoreSpecific}). * * @param o_clazz class in which to look for the method * @param name method name * @param arg_clazz an array of classes defining the types of arguments * @param arg_is_null indicates if each argument is null * * @return null if no matching method could be found or the best matching method. */ public static Method getMethod(Class o_clazz, String name, Class[] arg_clazz, boolean[] arg_is_null) throws SecurityException, NoSuchMethodException { if (o_clazz == null) return null; /* if there is no argument, try to find a direct match */ if (arg_clazz == null || arg_clazz.length == 0) { return o_clazz.getMethod(name, (Class[])null); } /* try to find an exact match */ Method met; try { met = o_clazz.getMethod(name, arg_clazz); if (met != null) return met; } catch (NoSuchMethodException e) { /* we want to search further */ } /* ok, no exact match was found - we have to walk through all methods */ met = null; Method[] ml = o_clazz.getMethods(); for (int k = 0; k < ml.length; k++) { Method m = ml[k]; if (!m.getName().equals(name)) // the name must match continue; Class[] param_clazz = m.getParameterTypes(); if (arg_clazz.length != param_clazz.length) // number of parameters must match continue; int n = arg_clazz.length; boolean ok = true; for (int i = 0; i < n; i++) { if( arg_is_null[i] ){ /* then the class must not be a primitive type */ if( isPrimitive(arg_clazz[i]) ){ ok = false ; break ; } } else{ if (arg_clazz[i] != null && !param_clazz[i].isAssignableFrom(arg_clazz[i])) { ok = false; break; } } } if (ok && (met == null || isMoreSpecific(m, met))) // it must be the only match so far or more specific than the current match met = m; } if( met == null ){ throw new NoSuchMethodException( "No suitable method for the given parameters" ) ; } return met; } /** * Returns true if m1 is more specific than m2. * The measure used is described in the isMoreSpecific( Class[], Class[] ) method * * @param m1 method to compare * @param m2 method to compare * * @return true if m1 is more specific (in arguments) than m2. */ private static boolean isMoreSpecific(Method m1, Method m2) { Class[] m1_param_clazz = m1.getParameterTypes(); Class[] m2_param_clazz = m2.getParameterTypes(); return isMoreSpecific( m1_param_clazz, m2_param_clazz ); } /** * Returns true if cons1 is more specific than cons2. * The measure used is described in the isMoreSpecific( Class[], Class[] ) method * * @param cons1 constructor to compare * @param cons2 constructor to compare * * @return true if cons1 is more specific (in arguments) than cons2. */ private static boolean isMoreSpecific(Constructor cons1, Constructor cons2) { Class[] cons1_param_clazz = cons1.getParameterTypes(); Class[] cons2_param_clazz = cons2.getParameterTypes(); return isMoreSpecific( cons1_param_clazz, cons2_param_clazz ); } /** * Returns true if c1 is more specific than c2. * * The measure used is the sum of more specific arguments minus the sum of less specific arguments * which in total must be positive to qualify as more specific. * (More specific means the argument is a subclass of the other argument). * * Both set of classes must have signatures fully compatible in the arguments * (more precisely incompatible arguments are ignored in the comparison). * * @param c1 set of classes to compare * @param c2 set of classes to compare */ private static boolean isMoreSpecific( Class[] c1, Class[] c2){ int n = c1.length ; int res = 0; for (int i = 0; i < n; i++) if( c1[i] != c2[i]) { if( c1[i].isAssignableFrom(c2[i])) res--; else if( c2[i].isAssignableFrom(c2[i]) ) res++; } return res > 0; } /** * Returns the list of classes of the object * * @param o an Object */ public static Class[] getClasses(Object o){ Vector/*>*/ vec = new Vector(); Class cl = o.getClass(); while( cl != null ){ vec.add( cl ) ; cl = cl.getSuperclass() ; } Class[] res = new Class[ vec.size() ] ; vec.toArray( res) ; return res ; } /** * Returns the list of class names of the object * * @param o an Object */ public static String[] getClassNames(Object o){ Vector/**/ vec = new Vector(); Class cl = o.getClass(); while( cl != null ){ vec.add( cl.getName() ) ; cl = cl.getSuperclass() ; } String[] res = new String[ vec.size() ] ; vec.toArray( res) ; return res ; } /** * Returns the list of simple class names of the object * * @param o an Object */ public static String[] getSimpleClassNames(Object o, boolean addConditionClasses){ boolean hasException = false ; Vector/**/ vec = new Vector(); Class cl = o.getClass(); String name ; while( cl != null ){ name = getSimpleName( cl.getName() ) ; if( "Exception".equals( name) ){ hasException = true ; } vec.add( name ) ; cl = cl.getSuperclass() ; } if( addConditionClasses ){ if( !hasException ){ vec.add( "Exception" ) ; } vec.add( "error" ) ; vec.add( "condition" ) ; } String[] res = new String[ vec.size() ] ; vec.toArray( res) ; return res ; } /* because Class.getSimpleName is java 5 API */ private static String getSimpleClassName( Object o ){ return getSimpleName( o.getClass().getName() ) ; } private static String getSimpleName( String s ){ int lastsquare = s.lastIndexOf( '[' ) ; if( lastsquare >= 0 ){ if( s.charAt( s.lastIndexOf( '[' ) + 1 ) == 'L' ){ s = s.substring( s.lastIndexOf( '[' ) + 2, s.lastIndexOf( ';' ) ) ; } else { char first = s.charAt( 0 ); if( first == 'I' ) { s = "int" ; } else if( first == 'D' ){ s = "double" ; } else if( first == 'Z' ){ s = "boolean" ; } else if( first == 'B' ){ s = "byte" ; } else if( first == 'J' ){ s = "long" ; } else if( first == 'F' ){ s = "float" ; } else if( first == 'S' ){ s = "short" ; } else if( first == 'C' ){ s = "char" ; } } } int lastdollar = s.lastIndexOf( '$' ) ; if( lastdollar >= 0 ){ s = s.substring( lastdollar + 1); } int lastdot = s.lastIndexOf( '.' ) ; if( lastdot >= 0 ){ s = s.substring( lastdot + 1); } if( lastsquare >= 0 ){ StringBuffer buf = new StringBuffer( s ); int i ; for( i=0; i<=lastsquare; i++){ buf.append( "[]" ); } return buf.toString(); } else { return s ; } } /** * @param cl class * @param field name of the field * * @return the class name of the field of the class (or null) * if the class does not have the given field) */ public static String getFieldTypeName( Class cl, String field){ String res = null ; try{ res = cl.getField( field ).getType().getName() ; } catch( NoSuchFieldException e){ /* just return null */ res = null ; } return res ; } } rJava/inst/java/FlatException.java0000644000176200001440000000032212256051770016625 0ustar liggesusers /** * Generated when one attemps to flatten an array that is not rectangular */ public class FlatException extends Exception{ public FlatException(){ super( "Can only flatten rectangular arrays" ); } } rJava/inst/java/ArrayDimensionException.class0000644000176200001440000000036612256051770021057 0ustar liggesusers.    (Ljava/lang/String;)VCodeLineNumberTable SourceFileArrayDimensionException.java ArrayDimensionExceptionjava/lang/Exception!"*+  rJava/inst/java/RJavaComparator.java0000644000176200001440000000313012256051770017113 0ustar liggesusersimport java.lang.Comparable ; /** * Utility class to compare two objects in the sense * of the java.lang.Comparable interface * */ public class RJavaComparator { /** * compares a and b in the sense of the java.lang.Comparable if possible * *

instances of the Number interface are treated specially, in order to * allow comparing Numbers of different classes, for example it is allowed * to compare a Double with an Integer. if the Numbers have the same class, * they are compared normally, otherwise they are first converted to Doubles * and then compared

* * @param a an object * @param b another object * * @return the result of a.compareTo(b) if this makes sense * @throws NotComparableException if the two objects are not comparable */ public static int compare( Object a, Object b ) throws NotComparableException{ int res ; if( a.equals( b ) ) return 0 ; // treat Number s separately if( a instanceof Number && b instanceof Number && !( a.getClass() == b.getClass() ) ){ Double _a = new Double( ((Number)a).doubleValue() ); Double _b = new Double( ((Number)b).doubleValue() ); return _a.compareTo( _b ); } if( ! ( a instanceof Comparable ) ) throw new NotComparableException( a ); if( ! ( b instanceof Comparable ) ) throw new NotComparableException( b ); try{ res = ( (Comparable)a ).compareTo( b ) ; } catch( ClassCastException e){ try{ res = - ((Comparable)b).compareTo( a ) ; } catch( ClassCastException f){ throw new NotComparableException( a, b ); } } return res ; } } rJava/inst/java/RJavaArrayTools_Test.class0000644000176200001440000005440512256051770020301 0ustar liggesusers.O                             Z              !"#$%&'()*+,-./01234567 89: ;<= >?@ ABC DEFGH IJK LMNOP QRSTUVWXYZ[\] ^_` abc def ghi jklmn opq rstuvw xyz {|} ~                     t  t@$()VCodeLineNumberTablemain([Ljava/lang/String;)Vruntests Exceptionsfails(LTestException;)Vsuccessisarray getdimlengthgetdims gettruelengthisrect gettypenameisprimrep SourceFileRJavaArrayTools_Test.java  Test suite for RJavaArrayTools  !  TestException  "#Testing RJavaArrayTools.isArray  *Testing RJavaArrayTools.isRectangularArray *Testing RJavaArrayTools.getDimensionLength %Testing RJavaArrayTools.getDimensions %Testing RJavaArrayTools.getTrueLength )Testing RJavaArrayTools.getObjectTypeName +Testing RJavaArrayTools.isPrimitiveTypeName Testing RJavaTools.rep  $ %FAILEDPASSED isArray( int ) &!' () isArray( int ) ! false : ok isArray( boolean ) (* isArray( boolean )  isArray( byte ) (+ isArray( byte )  isArray( long ) (, isArray( long )  isArray( short ) (- isArray( short )  isArray( double ) isArray( double )  isArray( char ) (. isArray( char )  isArray( float ) (/ isArray( float )  isArray( String )dd (0 isArray( String )  isArray( int[] ) !isArray( int[] )  true : ok/ isArray( double[] (but declared as 0bject) )' !isArray( Object o = new double[2]; )  isArray( null ) isArray( null)  >> actual arrays int[] o = new int[10] ; 12"getDimensionLength( int[10] ) != 1NotAnArrayExceptionnot an array int[10] 1 : ok  int[] o = new int[0] ;!getDimensionLength( int[0] ) != 1not an array int[0][[Ljava/lang/Object; new Object[10][10]-getDimensionLength( new Object[10][10] ) != 2not an array Object[10][10] 2 : ok [[[Ljava/lang/Object; new Object[10][10][10]0getDimensionLength( new Object[10][10][3] ) != 3not an array Object[10][10][3] 3 : ok  >> Object new Double('10.2') java/lang/Double10.3 !2getDimensionLength(Double) did not throw exception -> NotAnArrayException : ok  >> Testing primitive types getDimensionLength( int ) 131 getDimensionLength( int ) not throwing exception ok getDimensionLength( boolean ) 145 getDimensionLength( boolean ) not throwing exception : ok getDimensionLength( byte ) 152 getDimensionLength( byte ) not throwing exception getDimensionLength( long ) 162 getDimensionLength( long ) not throwing exception getDimensionLength( short ) 173 getDimensionLength( short ) not throwing exception : ok getDimensionLength( double )4 getDimensionLength( double ) not throwing exception getDimensionLength( char ) 183 getDimensionLength( char ) not throwing exception  getDimensionLength( float ) 194 getDimensionLength( float ) not throwing exception  getDimensionLength( null )java/lang/NullPointerException;getDimensionLength( null ) throwing wrong kind of exception3 getDimensionLength( null ) not throwing exception :;#getDimensions( int[10]).length != 1 getDimensions( int[10])[0] != 10 c( 10 ) : ok +getDimensions( Object[10][10] ).length != 2(getDimensions( Object[10][10] )[0] != 10(getDimensions( Object[10][10] )[1] != 10 c(10,10) : ok /getDimensions( Object[10][10][10] ).length != 3,getDimensions( Object[10][10][10] )[0] != 10,getDimensions( Object[10][10][10] )[1] != 10not an array Object[10][10][10] c(10,10,10) : ok  >> zeroes "getDimensions( int[0]).length != 1getDimensions( int[0])[0] != 0 c(0) : ok  new Object[10][10][0].getDimensions( Object[10][10][0] ).length != 3+getDimensions( Object[10][10][0] )[0] != 10+getDimensions( Object[10][10][0] )[1] != 10*getDimensions( Object[10][10][0] )[1] != 0not an array Object[10][10][0] c(10,10,0) : ok  new Object[10][0][10]-getDimensions( Object[10][0][0] ).length != 3*getDimensions( Object[10][0][0] )[0] != 10)getDimensions( Object[10][0][0] )[1] != 0not an array Object[10][0][10] c(10,0,0) : ok -getDimensions(Double) did not throw exception getDimensions( int ) :<, getDimensions( int ) not throwing exception getDimensions( boolean ) :=0 getDimensions( boolean ) not throwing exception getDimensions( byte ) :>- getDimensions( byte ) not throwing exception getDimensions( long ) :?- getDimensions( long ) not throwing exception getDimensions( short ) :@. getDimensions( short ) not throwing exception getDimensions( double )/ getDimensions( double ) not throwing exception getDimensions( char ) :A. getDimensions( char ) not throwing exception  getDimensions( float ) :B/ getDimensions( float ) not throwing exception  getDimensions( null )6getDimensions( null ) throwing wrong kind of exception. getDimensions( null ) not throwing exception C2getTrueLength( int[10]) != 10 10 : ok &getTrueLength( Object[10][10] ) != 100 100 : ok +getTrueLength( Object[10][10][10] ) != 1000 1000 : ok getTrueLength( int[0]) != 0'getTrueLength( Object[10][10][0] ) != 0 0 : ok &getTrueLength( Object[10][0][0] ) != 0-getTrueLength(Double) did not throw exception getTrueLength( int ) C3, getTrueLength( int ) not throwing exception getTrueLength( boolean ) C40 getTrueLength( boolean ) not throwing exception getTrueLength( byte ) C5- getTrueLength( byte ) not throwing exception getTrueLength( long ) C6- getTrueLength( long ) not throwing exception getTrueLength( short ) C7. getTrueLength( short ) not throwing exception getTrueLength( double )/ getTrueLength( double ) not throwing exception getTrueLength( char ) C8. getTrueLength( char ) not throwing exception  getTrueLength( float ) C9/ getTrueLength( float ) not throwing exception  getTrueLength( null )6getTrueLength( null ) throwing wrong kind of exception. getTrueLength( null ) not throwing exception  isRectangularArray( int ) D) isRectangularArray( int )  isRectangularArray( boolean ) D* isRectangularArray( boolean )  isRectangularArray( byte ) D+ isRectangularArray( byte )  isRectangularArray( long ) D, isRectangularArray( long )  isRectangularArray( short ) D- isRectangularArray( short )  isRectangularArray( double ) isRectangularArray( double )  isRectangularArray( char ) D. isRectangularArray( char )  isRectangularArray( float ) D/ isRectangularArray( float )  isRectangularArray( String ) D0 isRectangularArray( String )  isRectangularArray( int[] ) !isRectangularArray( int[] ) : isRectangularArray( double[] (but declared as 0bject) )2 !isRectangularArray( Object o = new double[2]; )  isRectangularArray( null ) isRectangularArray( null) [[I$ isRectangularArray( new int[3][4] )& !isRectangularArray( new int[3][4] ) [I& isRectangularArray( new int[2][2,4] )( !isRectangularArray( new int[2][2,4] ) + isRectangularArray( new int[2][2][10,25] )- !isRectangularArray( new int[2][2][10,25] ) EFIG H0 getObjectTypeName(int[]) != 'I'  I : ok  boolean[]Z$getObjectTypeName(boolean[]) != 'Z' not an array boolean[10] Z : ok  byte[]B!getObjectTypeName(byte[]) != 'B' not an array byte[10] B : ok  long[]J!getObjectTypeName(long[]) != 'J' not an array long[10] J : ok  short[]S"getObjectTypeName(short[]) != 'S' not an array short[10] S : ok  double[]D#getObjectTypeName(double[]) != 'D' not an array double[10] D : ok  char[]C!getObjectTypeName(char[]) != 'C' not an array char[10] C : ok  float[]F"getObjectTypeName(float[]) != 'F' not an array float[10] F : ok  >> multi dim primitive arrays int[][] ; boolean[][][[Z byte[][][[B long[][][[J short[][][[S double[][][[D char[][][[C float[][][[Fjava.lang.Object4getObjectTypeName(Object[][]) != 'java.lang.Object'  : ok >getObjectTypeName( Object[10][10][10] ) != 'java.lang.Object' !getObjectTypeName(int[0]) != 'I' =getObjectTypeName( Object[10][10][0] ) != 'java.lang.Object' ? %  DE w ! Y"#$% & Y'#$( ) Y*#$+ , Y-#$. / Y0#$1 / Y2#$3 a4 Y5#$6 7 Y8#$9 :; Y<#$ K= *; Y>#?L@ +; YA#?B ; YC#$3LMNP!T)U0V:XB\J]Q^[`cdkerf|hlmnptuvx|}~ #+/7>HPT\cmu} 2ƲD KE *F YG#LYI#J KK *F YL#LYM#J  NLO +F YP#MYQ#R   SMT ,F YU#NYV#WXY >ZY[\FW:> Y]#^_` >aW:> Yb#cd >eW:> Yf#gh >iW:> Yj#gk > lW:> Ym#cn >oW:> Yp#qr >oW:> Ys#gt >auW:> Yv#gw > xW:> Yy#gz >FW:>:Y|# Y}#g'*HI[^HHHH38;H_dgHHHHH;ADHhmpH{Hx '*+5=AIQ[^_iqz  !)138;=?MU ] _ dgiky"#%(&')*./142356: ;=@>?A)B1F9G;IALDJFKHMVN^RfShUmXpVrWtYZ`achdehfgijm RK LE +~K* Y#*. Y#MYI#  NMO ,~K* Y#*. Y#*. Y#NYQ#   SNT -~K* Y#*. Y#*. Y#*. Y#:Y# LK +~K* Y#*. Y#:YM#  SN -~K* Y#*. Y#*. Y#*. Y#:Y#  SN -~K* Y#*. Y#*. Y#*. Y#:Y#XY 6ZY[\~K:6 Y#^_ 6W:6 Y#c 6W:6 Y#g 6W:6 Y#g 6 W:6 Y#c 6W:6 Y#q 6W:6 Y#g 6aW:6 Y#g 6 W:6 Y#g 6~W:6:Y# Y#g69H]H  H5Z]HH<?HfsvHHH H27:HafiHHHH#&{#.Hrvwyz{$},~69:DLU]bhrz  !)-5:@JPZ]_iq{ ",2<?AKS[cfsvx{   "#%( & ')*'.//2174:2<3?5N6V:^;a=f@i>k?nA}BFGILJKMNRSUXVWYZ^_adbce flmo#t&p(q+t.r0s:uIvQz Ck; LE +; Y#MYI#  NMO ,;d Y#NYQ#   SNT -; Y#:Y# LK +; Y#:YM#  SN -; Y#:Y#  SN -; Y#:Y#XY 6ZY[\;:6 Y·#^_ö 6W:6 Yŷ#cƶ 6W:6 Yȷ#gɶ 6W:6 Y˷#g̶ 6 W:6 Yη#c϶ 6W:6 Yѷ#qҶ 6W:6 Yӷ#gԶ 6aW:6 Yַ#g׶ 6 W:6 Yٷ#gڶ 6W:6:Y۷# Yܷ#g$'HK`cHHHHBUXHHHH!$HKPSHzHHH H7<?{7<GH>$'(2:CKPV`cdnv (0:BGKUXZdlt|    !$&)8@HKPSUXgo"w#z%(&')*./142356:;=@>?ABFGI LJKM$N,T4U7W<\?XAYD\GZI[S]b^jb g7ݶ ޙ Y߷#$  Y#$  Y#$ Y#$  Y#$  Y#$ a Y#$ Y#$ : Y#$ K * Y#?L + Y#?  Y#$M , Y#?N- S- S -Y#$:S2 S2 S Y#$Gijkm!q)r0s:uByJzQ{[}ckr| #+/7>HPT\cmu} #.6  SE  K*Y#LYI#  K* Y #LY # K*Y#LY#  K*Y#LY#  K*Y#LY# K*Y #LY!#"# K*$Y%#LY&#'( K*)Y*#LY+#,-. K*Y#LYI# / 0K* Y #LY #1 2K*Y#LY#3 4K*Y#LY#5 6K*Y#LY#7 8K*Y #LY!#"9 :K*$Y%#LY&#'; <K*)Y*#LY+#,  NLO +K*=Y>#MYQ#?   SMT ,K*=Y@#NY# NK -K*YA#:YM#?  SM ,K*=YB#:Y#?  SM ,K*=YC#:Y#XY 6ZY[\K:6YD#^_E 6FW:6YG#cH 6IW:6YJ#gK 6LW:6YM#gN 6 OW:6YP#cQ 6RW:6YS#qT 6RW:6YU#gV 6aWW:6YX#gY 6 ZW:6Y[#g\ 6W:6:Y]#Y^#g $'HD`cHHHH8TWHuHHH7VYHwHHH7VYHwHHHC]`HHH),HS`cHHHH',/HX]`HHHH"%{"-H$'(2;DKU` cdo x#!"$(*+ ,0./&1/587?8I9T=W;X<c>lBuD|EFJHIKOQRSWUVX[^`a bfde%g.k7mAnKoVsYqZretnxwz{|~ %.7AKVYZenw'0;CHR]`aks{  ), . 8@HPS`cehmx!%()+.,-/0457:89;<@ACFDEGHL$M'O,R/P1Q4SDTLXUYX[]^`\b]e_u`}degjhiklpqsvtuwx|} "%'*-/:JR W_ `Ya#bc  `Yd#be `Yf#bg `Yh#bi `Yj#bk `Yl#bm $`Yn#bo )`Yp#bq =`Yr#s2 &Lr 09MV gtY  uKLv * wxxLMYz#+ Y{#+2|}Y#$'y6  $'(3:ER]frJava/inst/java/NotAnArrayException.java0000644000176200001440000000043612256051770017763 0ustar liggesusers/** * Exception indicating that an object is not a java array */ public class NotAnArrayException extends Exception{ public NotAnArrayException(Class clazz){ super( "not an array : " + clazz.getName() ) ; } public NotAnArrayException(String message){ super( message ) ; } } rJava/inst/java/RectangularArrayBuilder_Test.class0000644000176200001440000003343712256051770022035 0ustar liggesusers.                              ! "# $% &' () *+ ,- ./ 01 2 3 J456 789 J:; U< U= U>? U@ ABC UD EFG HIJ KLM NOP QRS TUV WXYZ [ \]^ _ `a bcdefghijklmn opqrstuvwxyz{|}~ dim1d[Idim2ddim3d()VCodeLineNumberTablemain([Ljava/lang/String;)Vruntests Exceptions fill_int_1fill_boolean_1 fill_byte_1 fill_long_1 fill_short_1 fill_double_1 fill_char_1 fill_float_1 fill_String_1 fill_Point_1 fill_int_2fill_boolean_2 fill_byte_2 fill_long_2 fill_short_2 fill_double_2 fill_char_2 fill_float_2 fill_String_2 fill_Point_2 fill_int_3fill_boolean_3 fill_byte_3 fill_long_3 fill_short_3 fill_double_3 fill_char_3 fill_float_3 fill_String_3 fill_Point_3ints(I)[Ibooleans(I)[Zbytes(I)[Blongs(I)[Jshorts(I)[Sdoubles(I)[Dchars(I)[Cfloats(I)[Fstrings(I)[Ljava/lang/String;points(I)[LDummyPoint; SourceFile!RectangularArrayBuilder_Test.java  TestException    ALL PASSED   >> 1 d fill int[]   : okfill boolean[]  fill byte[]  fill long[]  fill short[]  fill double[]  fill char[]  fill float[]  fill String[]  fill Point[]  >> 2 d fill int[][] fill boolean[][]  fill byte[][]  fill long[][] fill short[][] fill double[][]  fill char[][] fill float[][] fill String[][] fill Point[][]  >> 3 dfill int[][][] fill boolean[][][] fill byte[][][] fill long[][][] fill short[][][] fill double[][][] fill char[][][] fill float[][][] fill String[][][] fill Point[][][] RectangularArrayBuilder NotAnArrayExceptionnot an array int[10] ArrayDimensionExceptionarray dimensionexception java/lang/StringBufferdata[  ] !=  not an array boolean[10][Z  not an array byte[10][B not an array long[10][J not an array short[10][S not an array double[10][D not an array char[10][C not an array float[10][F not an array String[10][Ljava/lang/String;  not an array DummyPoint[10] [LDummyPoint;  ].x != [[I][[[Z[[B[[J[[S[[D[[C[[F[[Ljava/lang/String;not an array Point[10][[LDummyPoint; not an array int[30][[[I] != not an array boolean[30][[[Znot an array byte[30][[[Bnot an array long[30][[[Jnot an array short[30][[[Snot an array double[30][[[Dnot an array char[30][[[Cnot an array float[30][[[Fnot an array String[30][[[Ljava/lang/String;not an array Point[30][[[LDummyPoint;java/lang/String DummyPoint RectangularArrayBuilder_Testjava/lang/ObjectprintStackTracejava/lang/Systemexit(I)VoutLjava/io/PrintStream;java/io/PrintStreamprintln(Ljava/lang/String;)Vprint(Ljava/lang/Object;[I)VgetArray()Ljava/lang/Object;append,(Ljava/lang/String;)Ljava/lang/StringBuffer;(I)Ljava/lang/StringBuffer;toString()Ljava/lang/String;(Z)Ljava/lang/StringBuffer;equals(Ljava/lang/Object;)ZxIy(II)V! ,* X L+"  S                      ! " # $ % & ' ( ) * + , - . / 0 1 2 3 4 56 7 8 9 : ; < = > ? @ A B C D E F G H I ". A!T"g#z$%&'+,-./0-1@2S3f4y59:;<=>?@A,B?CRF xKJY KLMKLYOPLYRP*STTL=>L.7+.'YUYVWXYZXY[PƱN Q:KMRNO P!Q+T6U8VCWJXnVw\ KJY \LMKLY]PLYRP*S^^L=>L.>+3'YUYVWXYZX_[P=N Q:_afbc d!e+h6i8kClJmnk~q xKJY `LMKLYaPLYRP*SbbL=>L.7+3'YUYVWXYZXY[PƱN Q:tv{wx y!z+}6~8CJnw zKJY cLMKLYdPLYRP*SeeL=>L.9+/'YUYVWXYZXY[PıN Q: !+68CLpy xKJY fLMKLYgPLYRP*ShhL=>L.7+5'YUYVWXYZXY[PƱN Q: !+68CJnw zKJY iLMKLYjPLYRP*SkkL=>L.9+1'YUYVWXYZXY[PıN Q: !+68CLpy xKJY lLMKLYmPLYRP*SnnL=>L.7+4'YUYVWXYZXY[PƱN Q: !+68CJnw zKJY oLMKLYpPLYRP*SqqL=>L.9+0'YUYVWXYZXY[PıN Q: !+68CLpy KJY rLMKLYsPLYRP*SttL=>L.L+2UYVYuX[v'YUYVWXYZXY[PN Q: !+68C_ KJY wLMKLYxPLYRP*SyyL=>L.G+2:z {'YUYVWXY|XY[PN Q> !+ 6 8 C H Z~  KJY K}MKLYOPLYRP*S~~L=>}.W6}.D+2.1YUYVWXYXYZXY[PN QB !+!6"8#C$P%Z&$#+ KJY \}MKLY]PLYRP*SL=>}.^6}.K+231YUYVWXYXYZX_[P=N QB.0512 3!4+76889C:P;Z<:9A KJY `}MKLYaPLYRP*SL=>}.W6}.D+231YUYVWXYXYZXY[PN QBDFKGH I!J+M6N8OCPPQZRPOW KJY c}MKLYdPLYRP*SL=>}.Y6}.F+2/1YUYVWXYXYZXY[PN QBZ\a]^ _!`+c6d8eCfPg\hfem KJY f}MKLYgPLYRP*SL=>}.W6}.D+251YUYVWXYXYZXY[PN QBprwst u!v+y6z8{C|P}Z~|{ KJY i}MKLYjPLYRP*SL=>}.Y6}.F+211YUYVWXYXYZXY[PN QB !+68CP\ KJY l}MKLYmPLYRP*SL=>}.W6}.D+241YUYVWXYXYZXY[PN QB !+68CPZ KJY o}MKLYpPLYRP*SL=>}.Y6}.F+201YUYVWXYXYZXY[PN QB !+68CP\ KJY r}MKLYsPLYRP*SL=>}.l6}.Y+22UYVYuX[v1YUYVWXYXYZXY[PN QB !+68CPo KJY w}MKLYPLYRP*SL=>}.g6}.T+22:z {1YUYVWXYXY|XY[PN QF !+68CPXj $KJYKMKLYPLYRP*SL=>.w6.d6.Q+22.;YUYVWXYXYXYXY[PN QJ !+68CP]j  +KJY\MKLYPLYRP*SL=>.~6.k6.X+223;YUYVWXYXYXYX_[P=N QJ !+68CP]j$ $KJY`MKLYPLYRP*SL=>.w6.d6.Q+223;YUYVWXYXYXYXY[PN QJ').*+ ,!-+06182C3P4]5j6432; &KJYcMKLYPLYRP*SL=>.y6.f6.S+22/;YUYVWXYXYXYXY[PN QJ>@EAB C!D+G6H8ICJPK]LlMKJIR $KJYfMKLYPLYRP*SL=>.w6.d6.Q+225;YUYVWXYXYXYXY[PN QJUW\XY Z![+^6_8`CaPb]cjdba`i &KJYiMKLYPLYRP*SL=>.y6.f6.S+221;YUYVWXYXYXYXY[PN QJlnsop q!r+u6v8wCxPy]zl{yxw $KJYlMKLYPLYRP*SL=>.w6.d6.Q+224;YUYVWXYXYXYXY[PN QJ !+68CP]j &KJYoMKLYPLYRP*SL=>.y6.f6.S+220;YUYVWXYXYXYXY[PN QJ !+68CP]l 9KJYrMKLYPLYRP*SL=>.6.y6.f+222UYVYuX[v;YUYVWXYXYXYXY[PqN QJ !+68CP] 8KJYwMKLYPLYRP*SL=>.6.t6.a+222:z {;YUYVWXYXYXY|XY[PvN QN !+68CP]hz ? L= +O+  O#L=>+T=+ ! @L=+T+  @ L=+P+  @ L=+V+  BL=+cR+     @L=+U+  BL=+ bQ+  R*L=+UYVuXY[S+#$ %"$(' H L=+YS++, -,/L, Y OL YOYO} YOYOYO  rJava/inst/java/RJavaTools_Test.java0000644000176200001440000006423012256051770017113 0ustar liggesusers // :tabSize=2:indentSize=2:noTabs=false:folding=explicit:collapseFolds=1: import java.lang.reflect.Constructor ; import java.lang.reflect.* ; import java.util.Map ; import java.util.Set ; import java.util.HashMap; public class RJavaTools_Test { private static class ExampleClass { public ExampleClass( Object o1, String o2, boolean o3, boolean o4){} public ExampleClass( Object o1, String o2, boolean o3){} public ExampleClass(){} } /* so that we can check about access to private fields and methods */ private int bogus = 0 ; private int getBogus(){ return bogus ; } private static int staticbogus ; private static int getStaticBogus(){ return staticbogus ; } public int x = 0 ; public static int static_x = 0; public int getX(){ return x ; } public static int getStaticX(){ return static_x ; } public void setX( Integer x ){ this.x = x.intValue(); } // {{{ main public static void main( String[] args){ try{ runtests() ; } catch( TestException e){ fails( e ) ; System.exit(1); } } public static void runtests() throws TestException { System.out.println( "Testing RJavaTools.getConstructor" ) ; constructors() ; success() ; System.out.println( "Testing RJavaTools.classHasField" ) ; classhasfield() ; success(); System.out.println( "Testing RJavaTools.classHasMethod" ) ; classhasmethod() ; success() ; System.out.println( "Testing RJavaTools.classHasClass" ) ; classhasclass() ; success(); System.out.println( "Testing RJavaTools.hasField" ) ; hasfield() ; success(); System.out.println( "Testing RJavaTools.hasClass" ) ; hasclass() ; success(); System.out.println( "Testing RJavaTools.getClass" ) ; getclass() ; success() ; System.out.println( "Testing RJavaTools.hasMethod" ) ; hasmethod() ; success() ; System.out.println( "Testing RJavaTools.isStatic" ) ; isstatic() ; success() ; System.out.println( "Testing RJavaTools.getCompletionName" ) ; getcompletionname() ; success(); System.out.println( "Testing RJavaTools.getFieldNames" ) ; getfieldnames() ; success() ; System.out.println( "Testing RJavaTools.getMethodNames" ) ; getmethodnames() ; success() ; System.out.println( "Testing RJavaTools.getStaticFields" ) ; getstaticfields() ; success() ; System.out.println( "Testing RJavaTools.getStaticMethods" ) ; getstaticmethods() ; success() ; System.out.println( "Testing RJavaTools.getStaticClasses" ) ; getstaticclasses() ; success() ; System.out.println( "Testing RJavaTools.invokeMethod" ) ; invokemethod() ; success() ; System.out.println( "Testing RJavaTools.getFieldTypeName" ) ; getfieldtypename(); success() ; System.out.println( "Testing RJavaTools.getMethod" ) ; System.out.println( "NOT YET AVAILABLE" ) ; System.out.println( "Testing RJavaTools.newInstance" ) ; System.out.println( "NOT YET AVAILABLE" ) ; } // }}} // {{{ fails private static void fails( TestException e ){ System.err.println( "\n" ) ; e.printStackTrace() ; System.err.println( "FAILED" ) ; } // }}} // {{{ success private static void success(){ System.out.println( "PASSED" ) ; } // }}} // {{{ @Test getFieldNames private static void getfieldnames() throws TestException{ String[] names; // {{{ getFieldNames(DummyPoint, false) -> c('x', 'y' ) System.out.print( " * getFieldNames(DummyPoint, false)" ) ; names = RJavaTools.getFieldNames( DummyPoint.class, false ) ; if( names.length != 2 ){ throw new TestException( "getFieldNames(DummyPoint, false).length != 2" ) ; } for( int i=0; i<2; i++){ if( !( "x".equals(names[i]) || "y".equals(names[i] ) ) ){ throw new TestException( "getFieldNames(DummyPoint, false).length != c('x','y') " ) ; } } System.out.println( " : ok " ) ; // }}} // {{{ getFieldNames(Point, true ) --> character(0) System.out.print( " * getFieldNames(DummyPoint, true )" ) ; names = RJavaTools.getFieldNames( DummyPoint.class, true ) ; if( names.length != 0 ){ throw new TestException( "getFieldNames(DummyPoint, true ) != character(0)" ); } System.out.println( " : ok " ) ; // }}} // {{{ getFieldNames(RJavaTools_Test, true ) --> static_x System.out.print( " * getFieldNames(RJavaTools_Test, true )" ) ; names = RJavaTools.getFieldNames( RJavaTools_Test.class, true ) ; if( names.length != 1 ){ throw new TestException( "getFieldNames(RJavaTools_Test, true ).length != 1" ); } if( ! "static_x".equals( names[0] ) ){ throw new TestException( "getFieldNames(RJavaTools_Test, true )[0] != 'static_x' " ); } System.out.println( " : ok " ) ; // }}} // {{{ getFieldNames(RJavaTools_Test, false ) --> c('x', 'static_x') System.out.print( " * getFieldNames(RJavaTools_Test, false )" ) ; names = RJavaTools.getFieldNames( RJavaTools_Test.class, false ) ; if( names.length != 2 ){ throw new TestException( "getFieldNames(RJavaTools_Test, false ).length != 2" ); } for( int i=0; i<2; i++){ if( ! ( "x".equals( names[i] ) || "static_x".equals(names[i]) ) ){ throw new TestException( "getFieldNames(RJavaTools_Test, false ) != c('x', 'static_x') " ); } } System.out.println( " : ok " ) ; // }}} } // }}} // {{{ @Test getMethodNames private static void getmethodnames() throws TestException{ String[] names ; String[] expected ; int cpt = 0; // {{{ getMethodNames(RJavaTools_Test, true) -> c('getStaticX()', 'main(', 'runtests' ) System.out.print( " * getMethodNames(RJavaTools_Test, true)" ) ; names = RJavaTools.getMethodNames( RJavaTools_Test.class, true ) ; if( names.length != 3 ){ throw new TestException( "getMethodNames(RJavaTools_Test, true).length != 3 (" + names.length + ")" ) ; } expected= new String[]{ "getStaticX()", "main(", "runtests()" }; cpt = 0; for( int i=0; i character(0) ) System.out.print( " * getMethodNames(Object, true)" ) ; names = RJavaTools.getMethodNames( Object.class, true ) ; if( names.length != 0 ){ throw new TestException( "getMethodNames(Object, true).length != 0 (" + names.length + ")" ) ; } System.out.println( " : ok " ) ; // }}} // {{{ getMethodNames(RJavaTools_Test, false) %contains% { "getX()", "getStaticX()", "setX(", "main(" } System.out.print( " * getMethodNames(RJavaTools_Test, false)" ) ; names = RJavaTools.getMethodNames( RJavaTools_Test.class, false ) ; cpt = 0; expected = new String[]{ "getX()", "getStaticX()", "setX(", "main(" }; for( int i=0; i false try{ System.out.print( " * isStatic(RJavaTools_Test.x)" ) ; f = RJavaTools_Test.class.getField("x") ; if( RJavaTools.isStatic( f) ){ throw new TestException( "isStatic(RJavaTools_Test.x) == true" ) ; } System.out.println( " = false : ok " ) ; } catch( NoSuchFieldException e){ throw new TestException( e.getMessage() ) ; } // }}} // {{{ isStatic(RJavaTools_Test.getX) -> true try{ System.out.print( " * isStatic(RJavaTools_Test.getX() )" ) ; m = RJavaTools_Test.class.getMethod("getX", (Class[])null ) ; if( RJavaTools.isStatic( m ) ){ throw new TestException( "isStatic(RJavaTools_Test.getX() ) == false" ) ; } System.out.println( " = false : ok " ) ; } catch( NoSuchMethodException e){ throw new TestException( e.getMessage() ) ; } // }}} // {{{ isStatic(RJavaTools_Test.static_x) -> true try{ System.out.print( " * isStatic(RJavaTools_Test.static_x)" ) ; f = RJavaTools_Test.class.getField("static_x") ; if( ! RJavaTools.isStatic( f) ){ throw new TestException( "isStatic(RJavaTools_Test.static_x) == false" ) ; } System.out.println( " = true : ok " ) ; } catch( NoSuchFieldException e){ throw new TestException( e.getMessage() ) ; } // }}} // {{{ isStatic(RJavaTools_Test.getStaticX) -> true try{ System.out.print( " * isStatic(RJavaTools_Test.getStaticX() )" ) ; m = RJavaTools_Test.class.getMethod("getStaticX", (Class[])null ) ; if( ! RJavaTools.isStatic( m ) ){ throw new TestException( "isStatic(RJavaTools_Test.getStaticX() ) == false" ) ; } System.out.println( " = true : ok " ) ; } catch( NoSuchMethodException e){ throw new TestException( e.getMessage() ) ; } // }}} /* classes */ // {{{ isStatic(RJavaTools_Test.TestException) -> true System.out.print( " * isStatic(RJavaTools_Test.TestException )" ) ; Class cl = RJavaTools_Test.TestException.class ; if( ! RJavaTools.isStatic( cl ) ){ throw new TestException( "isStatic(RJavaTools_Test.TestException) == false" ) ; } System.out.println( " = true : ok " ) ; // }}} // {{{ isStatic(RJavaTools_Test.DummyNonStaticClass) -> false System.out.print( " * isStatic(RJavaTools_Test.DummyNonStaticClass )" ) ; cl = RJavaTools_Test.DummyNonStaticClass.class ; if( RJavaTools.isStatic( cl ) ){ throw new TestException( "isStatic(RJavaTools_Test.DummyNonStaticClass) == true" ) ; } System.out.println( " = false : ok " ) ; // }}} } // }}} // {{{ @Test constructors private static void constructors() throws TestException { /* constructors */ Constructor cons ; boolean error ; // {{{ getConstructor( String, null ) System.out.print( " * getConstructor( String, null )" ) ; try{ cons = RJavaTools.getConstructor( String.class, (Class[])null, (boolean[])null ) ; } catch( Exception e ){ throw new TestException( "getConstructor( String, null )" ) ; } System.out.println( " : ok " ) ; // }}} // {{{ getConstructor( Integer, { String.class } ) System.out.print( " * getConstructor( Integer, { String.class } )" ) ; try{ cons = RJavaTools.getConstructor( Integer.class, new Class[]{ String.class }, new boolean[]{false} ) ; } catch( Exception e){ throw new TestException( "getConstructor( Integer, { String.class } )" ) ; } System.out.println( " : ok " ) ; // }}} // disabled for now // // {{{ getConstructor( JButton, { String.class, ImageIcon.class } ) // System.out.print( " * getConstructor( JButton, { String.class, ImageIcon.class } )" ) ; // try{ // cons = RJavaTools.getConstructor( JButton.class, // new Class[]{ String.class, ImageIcon.class }, // new boolean[]{ false, false} ) ; // } catch( Exception e){ // throw new TestException( "getConstructor( JButton, { String.class, ImageIcon.class } )" ) ; // } // System.out.println( " : ok " ) ; // // }}} // {{{ getConstructor( Integer, null ) -> exception error = false ; System.out.print( " * getConstructor( Integer, null )" ) ; try{ cons = RJavaTools.getConstructor( Integer.class, (Class[])null, (boolean[])null ) ; } catch( Exception e){ error = true ; } if( !error ){ throw new TestException( "getConstructor( Integer, null ) did not generate error" ) ; } System.out.println( " -> exception : ok " ) ; // }}} // disabled for now // // {{{ getConstructor( JButton, { String.class, JButton.class } ) -> exception // error = false ; // System.out.print( " * getConstructor( JButton, { String.class, JButton.class } )" ) ; // try{ // cons = RJavaTools.getConstructor( JButton.class, // new Class[]{ String.class, JButton.class }, // new boolean[]{ false, false } ) ; // } catch( Exception e){ // error = true ; // } // if( !error ){ // throw new TestException( "getConstructor( JButton, { String.class, JButton.class } ) did not generate error" ) ; // } // System.out.println( " -> exception : ok " ) ; // // }}} Object o1 = null ; Object o2 = null ; ExampleClass foo = new ExampleClass(o1,(String)o2,false) ; // {{{ getConstructor( ExampleClass, { null, null, false } error = false ; System.out.print( " * getConstructor( ExampleClass, {Object.class, Object.class, boolean}) : " ) ; try{ cons = RJavaTools.getConstructor( ExampleClass.class, new Class[]{ Object.class, Object.class, Boolean.TYPE}, new boolean[]{ true, true, false} ); } catch(Exception e){ error = true ; e.printStackTrace() ; } if( error ){ throw new TestException( "getConstructor( ExampleClass, {Object.class, Object.class, boolean}) : exception " ) ; } System.out.println( " ok" ) ; // }}} } // }}} // {{{ @Test methods private static void methods() throws TestException{ } // }}} // {{{ @Test hasfields private static void hasfield() throws TestException{ DummyPoint p = new DummyPoint() ; System.out.println( " java> DummyPoint p = new DummyPoint()" ) ; System.out.print( " * hasField( p, 'x' ) " ) ; if( !RJavaTools.hasField( p, "x" ) ){ throw new TestException( " hasField( DummyPoint, 'x' ) == false" ) ; } System.out.println( " true : ok" ) ; System.out.print( " * hasField( p, 'iiiiiiiiiiiii' ) " ) ; if( RJavaTools.hasField( p, "iiiiiiiiiiiii" ) ){ throw new TestException( " hasField( DummyPoint, 'iiiiiiiiiiiii' ) == true" ) ; } System.out.println( " false : ok" ) ; /* testing a private field */ RJavaTools_Test ob = new RJavaTools_Test(); System.out.print( " * testing a private field " ) ; if( RJavaTools.hasField( ob, "bogus" ) ){ throw new TestException( " hasField returned true on private field" ) ; } System.out.println( " false : ok" ) ; } // }}} // {{{ @Test hasmethod private static void hasmethod() throws TestException{ DummyPoint p = new DummyPoint() ; System.out.println( " java> DummyPoint p = new DummyPoint()" ) ; System.out.print( " * hasMethod( p, 'move' ) " ) ; if( !RJavaTools.hasMethod( p, "move" ) ){ throw new TestException( " hasField( DummyPoint, 'move' ) == false" ) ; } System.out.println( " true : ok" ) ; System.out.print( " * hasMethod( p, 'iiiiiiiiiiiii' ) " ) ; if( RJavaTools.hasMethod( p, "iiiiiiiiiiiii" ) ){ throw new TestException( " hasMethod( Point, 'iiiiiiiiiiiii' ) == true" ) ; } System.out.println( " false : ok" ) ; /* testing a private method */ RJavaTools_Test ob = new RJavaTools_Test(); System.out.print( " * testing a private method " ) ; if( RJavaTools.hasField( ob, "getBogus" ) ){ throw new TestException( " hasMethod returned true on private method" ) ; } System.out.println( " false : ok" ) ; } // }}} // {{{ @Test hasclass private static void hasclass() throws TestException{ RJavaTools_Test ob = new RJavaTools_Test(); System.out.print( " * hasClass( RJavaTools_Test, 'TestException' ) " ) ; if( ! RJavaTools.hasClass( ob, "TestException" ) ){ throw new TestException( " hasClass( RJavaTools_Test, 'TestException' ) == false" ) ; } System.out.println( " true : ok" ) ; System.out.print( " * hasClass( RJavaTools_Test, 'DummyNonStaticClass' ) " ) ; if( ! RJavaTools.hasClass( ob, "DummyNonStaticClass" ) ){ throw new TestException( " hasClass( RJavaTools_Test, 'DummyNonStaticClass' ) == false" ) ; } System.out.println( " true : ok" ) ; } // }}} // {{{ @Test hasclass private static void getclass() throws TestException{ Class cl ; System.out.print( " * getClass( RJavaTools_Test, 'TestException', true ) " ) ; cl = RJavaTools.getClass( RJavaTools_Test.class, "TestException", true ); if( cl != RJavaTools_Test.TestException.class ){ throw new TestException( " getClass( RJavaTools_Test, 'TestException', true ) != TestException" ) ; } System.out.println( " : ok" ) ; System.out.print( " * getClass( RJavaTools_Test, 'DummyNonStaticClass', true ) " ) ; cl = RJavaTools.getClass( RJavaTools_Test.class, "DummyNonStaticClass", true ); if( cl != null ){ throw new TestException( " getClass( RJavaTools_Test, 'DummyNonStaticClass', true ) != null" ) ; } System.out.println( " : ok" ) ; System.out.print( " * getClass( RJavaTools_Test, 'DummyNonStaticClass', false ) " ) ; cl = RJavaTools.getClass( RJavaTools_Test.class, "DummyNonStaticClass", false ); if( cl != RJavaTools_Test.DummyNonStaticClass.class ){ throw new TestException( " getClass( RJavaTools_Test, 'DummyNonStaticClass', true ) != null" ) ; } System.out.println( " : ok" ) ; } // }}} // {{{ @Test classhasfield private static void classhasfield() throws TestException{ } // }}} // {{{ @Test classhasclass private static void classhasclass() throws TestException{ System.out.print( " * classHasClass( RJavaTools_Test, 'TestException', true ) " ) ; if( ! RJavaTools.classHasClass( RJavaTools_Test.class , "TestException", true ) ){ throw new TestException( " classHasClass( RJavaTools_Test, 'TestException', true ) == false" ) ; } System.out.println( " true : ok" ) ; System.out.print( " * classHasClass( RJavaTools_Test, 'DummyNonStaticClass', true ) " ) ; if( RJavaTools.classHasClass( RJavaTools_Test.class , "DummyNonStaticClass", true ) ){ throw new TestException( " classHasClass( RJavaTools_Test, 'DummyNonStaticClass', true ) == true" ) ; } System.out.println( " false : ok" ) ; System.out.print( " * classHasClass( RJavaTools_Test, 'DummyNonStaticClass', false ) " ) ; if( ! RJavaTools.classHasClass( RJavaTools_Test.class , "DummyNonStaticClass", false ) ){ throw new TestException( " classHasClass( RJavaTools_Test, 'DummyNonStaticClass', false ) == false" ) ; } System.out.println( " true : ok" ) ; } // }}} // {{{ @Test classhasmethod private static void classhasmethod() throws TestException{ System.out.print( " * classHasMethod( RJavaTools_Test, 'getX', false ) " ) ; if( ! RJavaTools.classHasMethod( RJavaTools_Test.class, "getX", false ) ){ throw new TestException( " classHasMethod( RJavaTools_Test, 'getX', false ) == false" ) ; } System.out.println( " true : ok" ) ; System.out.print( " * classHasMethod( RJavaTools_Test, 'getStaticX', false ) " ) ; if( ! RJavaTools.classHasMethod( RJavaTools_Test.class, "getStaticX", false ) ){ throw new TestException( " classHasMethod( RJavaTools_Test, 'getStaticX', false ) == false" ) ; } System.out.println( " true : ok" ) ; System.out.print( " * classHasMethod( RJavaTools_Test, 'getX', true ) " ) ; if( RJavaTools.classHasMethod( RJavaTools_Test.class, "getX", true ) ){ throw new TestException( " classHasMethod( RJavaTools_Test, 'getX', true ) == true (non static method)" ) ; } System.out.println( " false : ok" ) ; System.out.print( " * classHasMethod( RJavaTools_Test, 'getStaticX', true ) " ) ; if( ! RJavaTools.classHasMethod( RJavaTools_Test.class, "getStaticX", true ) ){ throw new TestException( " classHasMethod( RJavaTools_Test, 'getStaticX', true ) == false (static)" ) ; } System.out.println( " true : ok" ) ; System.out.print( " * classHasMethod( RJavaTools_Test, 'getBogus', false ) " ) ; if( RJavaTools.classHasMethod( RJavaTools_Test.class, "getBogus", false ) ){ throw new TestException( " classHasMethod( RJavaTools_Test, 'getBogus', false ) == true (private method)" ) ; } System.out.println( " false : ok" ) ; System.out.print( " * classHasMethod( RJavaTools_Test, 'getStaticBogus', true ) " ) ; if( RJavaTools.classHasMethod( RJavaTools_Test.class, "getStaticBogus", true ) ){ throw new TestException( " classHasMethod( RJavaTools_Test, 'getBogus', true ) == true (private method)" ) ; } System.out.println( " false : ok" ) ; } // }}} // {{{ @Test getstaticfields private static void getstaticfields() throws TestException{ Field[] f ; System.out.print( " * getStaticFields( RJavaTools_Test ) " ) ; f = RJavaTools.getStaticFields( RJavaTools_Test.class ) ; if( f.length != 1 ){ throw new TestException( " getStaticFields( RJavaTools_Test ).length != 1" ) ; } if( ! "static_x".equals( f[0].getName() ) ){ throw new TestException( " getStaticFields( RJavaTools_Test )[0] != 'static_x'" ) ; } System.out.println( " : ok" ) ; System.out.print( " * getStaticFields( Object ) " ) ; f = RJavaTools.getStaticFields( Object.class ) ; if( f != null ){ throw new TestException( " getStaticFields( Object ) != null" ) ; } System.out.println( " : ok" ) ; } // }}} // {{{ @Test getstaticmethods private static void getstaticmethods() throws TestException{ Method[] m ; // {{{ getStaticMethods( RJavaTools_Test ) System.out.print( " * getStaticMethods( RJavaTools_Test ) " ) ; m = RJavaTools.getStaticMethods( RJavaTools_Test.class ) ; String[] expected = new String[]{ "getStaticX" , "main", "runtests" }; int count = 0; if( m.length != expected.length ){ throw new TestException( " getStaticMethods( RJavaTools_Test ).length != 2" ) ; } for( int i=0; i 0 ) { smallest = current ; } } } return smallest ; } /** * returns the minimum (in the sense of Comparable) of the * objects in the one dimensioned array */ private static Object max( Object[] x, boolean narm ){ int n = x.length ; Object biggest = null ; Object current ; boolean found_min = false; // find somewhere to start from () for( int i=0; i 0 ) { range[0] = current ; } } } } return range ; } public void checkComparableObjects() throws NotComparableException { if( ! containsComparableObjects() ) throw new NotComparableException( typeName ) ; } public boolean containsComparableObjects(){ return Comparable.class.isAssignableFrom( componentType ) ; } // TODO : use these private static boolean smaller( Object x, Object y){ return ( (Comparable)x ).compareTo(y) < 0 ; } private static boolean bigger( Object x, Object y){ return ( (Comparable)x ).compareTo(y) > 0 ; } } rJava/inst/java/RJavaImport.java0000644000176200001440000001032212256051770016257 0ustar liggesusers import java.util.regex.Pattern ; import java.util.regex.Matcher ; import java.util.Vector; import java.util.HashMap; import java.util.Map; import java.util.Collection; import java.util.Set ; import java.util.Iterator ; import java.io.Serializable; /** * Utilities to manage java packages and how they are "imported" to R * databases. This is the back door of the javaImport * system in the R side * * @author Romain Francois */ public class RJavaImport implements Serializable { /** * Debug flag. Prints some messages if it is set to TRUE */ public static boolean DEBUG = false ; /** * list of imported packages */ /* TODO: vector is not good enough, we need to control the order in which the packages appear */ private Vector/**/ importedPackages ; /** * maps a simple name to a fully qualified name */ /* String -> java.lang.String */ /* should we cache the Class instead ? */ private Map/**/ cache ; /** * associated class loader */ public ClassLoader loader ; /** * Constructor. Initializes the imported package vector and the cache */ public RJavaImport( ClassLoader loader ){ this.loader = loader ; importedPackages = new Vector/**/(); cache = new HashMap/**/() ; } /** * Look for the class in the set of packages * * @param clazz the simple class name * * @return an instance of Class representing the actual class */ public Class lookup( String clazz){ Class res = lookup_(clazz) ; if( DEBUG ) System.out.println( " [J] lookup( '" + clazz + "' ) = " + (res == null ? " " : ("'" + res.getName() + "'" ) ) ) ; return res ; } private Class lookup_( String clazz ){ Class res = null ; if( cache.containsKey( clazz ) ){ try{ String fullname = (String)cache.get( clazz ) ; Class cl = Class.forName( fullname ) ; return cl ; } catch( Exception e ){ /* does not happen */ } } /* first try to see if the class does not exist verbatim */ try{ res = Class.forName( clazz ) ; } catch( Exception e){} if( res != null ) { cache.put( clazz, clazz ) ; return res; } int npacks = importedPackages.size() ; if( DEBUG ) System.out.println( " [J] " + npacks + " packages" ) ; if( npacks > 0 ){ for( int i=0; i*/ set = cache.keySet() ; int size = set.size() ; String[] res = new String[size]; set.toArray( res ); if( DEBUG ) System.out.println( " [J] getKnownClasses().length = " + res.length ) ; return res ; } public static Class lookup( String clazz , Set importers ){ Class res ; Iterator iterator = importers.iterator() ; while( iterator.hasNext()){ RJavaImport importer = (RJavaImport)iterator.next() ; res = importer.lookup( clazz ) ; if( res != null ) return res ; } return null ; } } rJava/inst/java/RJavaArrayIterator.java0000644000176200001440000000321712256051770017602 0ustar liggesusersimport java.lang.reflect.Array ; public abstract class RJavaArrayIterator { protected int[] dimensions; protected int nd ; protected int[] index ; protected int[] dimprod ; protected Object array ; protected int increment; protected int position ; protected int start ; public Object getArray(){ return array ; } /** * @return the class name of the array */ public String getArrayClassName(){ return array.getClass().getName(); } public int[] getDimensions(){ return dimensions; } public RJavaArrayIterator(){ dimensions = null; index = null ; dimprod = null ; array = null ; } public RJavaArrayIterator(int[] dimensions){ this.dimensions = dimensions ; nd = dimensions.length ; if( nd > 1){ index = new int[ nd-1 ] ; dimprod = new int[ nd-1 ] ; for( int i=0; i<(nd-1); i++){ index[i] = 0 ; dimprod[i] = (i==0) ? dimensions[i] : ( dimensions[i]*dimprod[i-1] ); increment = dimprod[i] ; } } position = 0 ; start = 0; } public RJavaArrayIterator(int d1){ this( new int[]{ d1} ) ; } protected Object next( ){ /* get the next array and the position of the first elemtn in the flat array */ Object o = array ; for( int i=0; i=0; i--){ if( (index[i] + 1) == dimensions[i] ){ index[i] = 0 ; } else{ index[i] = index[i] + 1 ; } } position++ ; return o; } protected boolean hasNext( ){ return position < increment ; } } rJava/inst/java/TestException.java0000644000176200001440000000025312256051770016661 0ustar liggesusers/** * Generated as part of testing rjava internal java tools */ public class TestException extends Exception{ public TestException(String message){super(message);} } rJava/inst/java/RJavaArrayIterator.class0000644000176200001440000000274412256051770017772 0ustar liggesusers.D , - ./ 0 1 2 3 4 5 6 7 8 9:;< dimensions[IndIindexdimprodarrayLjava/lang/Object; incrementpositionstartgetArray()Ljava/lang/Object;CodeLineNumberTablegetArrayClassName()Ljava/lang/String; getDimensions()[I()V([I)V(I)VnexthasNext()Z SourceFileRJavaArrayIterator.java  =>? @  #$       #%A BCRJavaArrayIteratorjava/lang/ObjectgetClass()Ljava/lang/Class;java/lang/ClassgetNamejava/lang/reflect/Arrayget'(Ljava/lang/Object;I)Ljava/lang/Object;!* # *!"*#$E*****  !"#%y**+*+*Z**d **d =*d6*O* +.+.*d.hO**. * * :$% &'(#)/*;+B,^-h*n0s1x2#&( * YO  4 5'*L=*=+*. L**. *Y *.*d.h` *d=2*.`*. *O**.`O*Y ` +::;<=>,@D;JEVFgGqIEMN())* * R*+rJava/inst/java/RJavaTools_Test$ExampleClass.class0000644000176200001440000000071112256051770021637 0ustar liggesusers.  )(Ljava/lang/Object;Ljava/lang/String;ZZ)VCodeLineNumberTable((Ljava/lang/Object;Ljava/lang/String;Z)V()V SourceFileRJavaTools_Test.java  RJavaTools_Test$ExampleClass ExampleClass InnerClassesjava/lang/ObjectRJavaTools_Test * *  *     rJava/inst/java/RectangularArrayBuilder.class0000644000176200001440000001133012256051770021022 0ustar liggesusers. @k lmn op q lrst uv w x y z ?{ l| }~ l   ? ? ? ? ? ? ? ? ? ? @u z ? ? ? ?(Ljava/lang/Object;[I)VCodeLineNumberTable Exceptions(Ljava/lang/Object;I)V(I[I)V(Z[I)V(B[I)V(J[I)V(S[I)V(D[I)V(C[I)V(F[I)V(II)V(ZI)V(BI)V(JI)V(SI)V(DI)V(CI)V(FI)Vfill_int([I)V fill_boolean([Z)V fill_byte([B)V fill_long([J)V fill_short([S)V fill_double([D)V fill_char([C)V fill_float([F)V fill_Object([Ljava/lang/Object;)V SourceFileRectangularArrayBuilder.java AX NotAnArrayException A ArrayDimensionExceptionjava/lang/StringBuffer Anot a single dimension array : A   java/lang/ClassNotFoundException I [I WXZ[Z YZB[B [\J[J ]^S[S _`D[D abC[C cdF[F ef[Ljava/lang/Object; gh ABprimitive type : int primitive type : boolean primitive type : byte primitive type : long primitive type : short primitive type : double primitive type : char primitive type : float RectangularArrayBuilderRJavaArrayIteratorRJavaArrayToolsisArray(Ljava/lang/Object;)Zjava/lang/ObjectgetClass()Ljava/lang/Class;(Ljava/lang/Class;)VisSingleDimensionArray()Vappend,(Ljava/lang/String;)Ljava/lang/StringBuffer;,(Ljava/lang/Object;)Ljava/lang/StringBuffer;toString()Ljava/lang/String;(Ljava/lang/String;)VarrayLjava/lang/Object;getObjectTypeName&(Ljava/lang/Object;)Ljava/lang/String;java/lang/ClassgetClassLoader()Ljava/lang/ClassLoader;getClassForSignature<(Ljava/lang/String;Ljava/lang/ClassLoader;)Ljava/lang/Class;java/lang/reflect/Array newInstance'(Ljava/lang/Class;[I)Ljava/lang/Object;java/lang/StringequalshasNext()Znext()Ljava/lang/Object;start increment!?@ABC3*,+Y++!YY  + , *++N:-+::*,-*+-*+-*+-*+ !j-"*+##$S-%*+&&'<-(*+))*%-+*+,,-*+../S`cDz =CK P!S#`$e&o'x()*+,-./0123456'82<EAFC) *+ YO0D > ?EAGC&*1Y23DBEAHC&*1Y43DCEAIC&*1Y53DDEAJC&*1Y63DEEAKC&*1Y73DFEALC&*1Y83DGEAMC&*1Y93DHEANC&*1Y:3DIEAOC&*1Y23DKEAPC&*1Y43DLEAQC&*1Y53DMEARC&*1Y63DNEASC&*1Y73DOEATC&*1Y83DPEAUC&*1Y93DQEAVC&*1Y:3DREWXCm9*;4*<N*==6--+.O*>`=˱D"XYZ[!\([5^8_YZCm9*;4*<N*==6--+3T*>`=˱D"cdef!g(f5i8j[\Cm9*;4*<N*==6--+3T*>`=˱D"nopq!r(q5t8u]^Cm9*;4*< N*==6--+/P*>`=˱D"yz{|!}(|58_`Cm9*;4*<##N*==6--+5V*>`=˱D"!(58abCm9*;4*<&&N*==6--+1R*>`=˱D"!(58cdCm9*;4*<))N*==6--+4U*>`=˱D"!(58efCm9*;4*<,,N*==6--+0Q*>`=˱D"!(58ghCm9*;4*<..N*==6--+2S*>`=˱D"!(58ijrJava/inst/java/RJavaArrayTools.java0000644000176200001440000007064012256051770017115 0ustar liggesusers// RJavaTools.java: rJava - low level R to java interface // // :tabSize=2:indentSize=2:noTabs=false:folding=explicit:collapseFolds=1: // // Copyright (C) 2009 - 2010 Simon Urbanek and Romain Francois // // This file is part of rJava. // // rJava is free software: you can redistribute it and/or modify it // under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 2 of the License, or // (at your option) any later version. // // rJava is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with rJava. If not, see . import java.lang.reflect.Array ; import java.util.Map; import java.util.HashMap; import java.util.Vector ; import java.util.Arrays ; import java.util.Iterator; import java.lang.reflect.Method ; import java.lang.reflect.InvocationTargetException ; public class RJavaArrayTools { // TODO: maybe factor this out of this class private static Map primitiveClasses = initPrimitiveClasses() ; private static Map initPrimitiveClasses(){ Map primitives = new HashMap(); primitives.put( "I", Integer.TYPE ); primitives.put( "Z", Boolean.TYPE ); primitives.put( "B", Byte.TYPE ); primitives.put( "J", Long.TYPE ); primitives.put( "S", Short.TYPE ); primitives.put( "D", Double.TYPE ); primitives.put( "C", Character.TYPE ); primitives.put( "F", Float.TYPE ); return primitives; } // {{{ getObjectTypeName /** * Get the object type name of an multi dimensional array. * * @param o object * @throws NotAnArrayException if the object is not an array */ public static String getObjectTypeName(Object o) throws NotAnArrayException { Class o_clazz = o.getClass(); if( !o_clazz.isArray() ) throw new NotAnArrayException( o_clazz ); String cl = o_clazz.getName(); return cl.replaceFirst("\\[+L?", "").replace(";", "") ; } public static int getObjectTypeName(int x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : int ") ; } public static int getObjectTypeName(boolean x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : boolean ") ; } public static int getObjectTypeName(byte x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : byte ") ; } public static int getObjectTypeName(long x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : long ") ; } public static int getObjectTypeName(short x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : short ") ; } public static int getObjectTypeName(double x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : double ") ; } public static int getObjectTypeName(char x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : char ") ; } public static int getObjectTypeName(float x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : float ") ; } // }}} // {{{ makeArraySignature // TODO: test public static String makeArraySignature( String typeName, int depth ){ StringBuffer buffer = new StringBuffer() ; for( int i=0; i 1 ) return false; if( name.equals("I") ) return true ; if( name.equals("Z") ) return true ; if( name.equals("B") ) return true ; if( name.equals("J") ) return true ; if( name.equals("S") ) return true ; if( name.equals("D") ) return true ; if( name.equals("C") ) return true ; if( name.equals("F") ) return true ; return false; } // }}} // {{{ isRectangularArray /** * Indicates if o is a rectangular array * * @param o an array * @throws NotAnArrayException if o is not an array * @deprecated use new ArrayWrapper(o).isRectangular() instead */ public static boolean isRectangularArray(Object o) { if( !isArray(o) ) return false; boolean res = false; try{ if( getDimensionLength( o ) == 1 ) return true ; res = ( new ArrayWrapper(o) ).isRectangular() ; } catch( NotAnArrayException e){ res = false; } return res ; } // thoose below make java < 1.5 happy and me unhappy ;-) public static boolean isRectangularArray(int x) { return false ; } public static boolean isRectangularArray(boolean x) { return false ; } public static boolean isRectangularArray(byte x) { return false ; } public static boolean isRectangularArray(long x) { return false ; } public static boolean isRectangularArray(short x) { return false ; } public static boolean isRectangularArray(double x) { return false ; } public static boolean isRectangularArray(char x) { return false ; } public static boolean isRectangularArray(float x) { return false ; } // }}} // {{{ getDimensionLength /** * Returns the number of dimensions of an array * * @param o an array * @throws NotAnArrayException if this is not an array */ public static int getDimensionLength( Object o) throws NotAnArrayException, NullPointerException { if( o == null ) throw new NullPointerException( "array is null" ) ; Class clazz = o.getClass(); if( !clazz.isArray() ) throw new NotAnArrayException(clazz) ; int n = 0; while( clazz.isArray() ){ n++ ; clazz = clazz.getComponentType() ; } return n ; } // thoose below make java < 1.5 happy and me unhappy ;-) public static int getDimensionLength(int x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : int ") ; } public static int getDimensionLength(boolean x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : boolean ") ; } public static int getDimensionLength(byte x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : byte ") ; } public static int getDimensionLength(long x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : long ") ; } public static int getDimensionLength(short x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : short ") ; } public static int getDimensionLength(double x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : double ") ; } public static int getDimensionLength(char x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : char ") ; } public static int getDimensionLength(float x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : float ") ; } // }}} // {{{ getDimensions /** * Returns the dimensions of an array * * @param o an array * @throws NotAnArrayException if this is not an array * @return the dimensions of the array or null if the object is null */ public static int[] getDimensions( Object o) throws NotAnArrayException, NullPointerException { if( o == null ) throw new NullPointerException( "array is null" ) ; Class clazz = o.getClass(); if( !clazz.isArray() ) throw new NotAnArrayException(clazz) ; Object a = o ; int n = getDimensionLength( o ) ; int[] dims = new int[n] ; int i=0; int current ; while( clazz.isArray() ){ current = Array.getLength( a ) ; dims[i] = current ; i++; if( current == 0 ){ break ; // the while loop } else { a = Array.get( a, 0 ) ; clazz = clazz.getComponentType() ; } } /* in case of premature stop, we fill the rest of the array with 0 */ // this might not be true: // Object[][] = new Object[0][10] will return c(0,0) while( i < dims.length){ dims[i] = 0 ; i++ ; } return dims ; } // thoose below make java < 1.5 happy and me unhappy ;-) public static int[] getDimensions(int x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : int ") ; } public static int[] getDimensions(boolean x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : boolean ") ; } public static int[] getDimensions(byte x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : byte ") ; } public static int[] getDimensions(long x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : long ") ; } public static int[] getDimensions(short x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : short ") ; } public static int[] getDimensions(double x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : double ") ; } public static int[] getDimensions(char x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : char ") ; } public static int[] getDimensions(float x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : float ") ; } // }}} // {{{ getTrueLength /** * Returns the true length of an array (the product of its dimensions) * * @param o an array * @throws NotAnArrayException if this is not an array * @return the number of objects in the array (the product of its dimensions). */ public static int getTrueLength( Object o) throws NotAnArrayException, NullPointerException { if( o == null ) throw new NullPointerException( "array is null" ) ; Class clazz = o.getClass(); if( !clazz.isArray() ) throw new NotAnArrayException(clazz) ; Object a = o ; int len = 1 ; int i = 0; while( clazz.isArray() ){ len = len * Array.getLength( a ) ; if( len == 0 ) return 0 ; /* no need to go further */ i++; a = Array.get( a, 0 ) ; clazz = clazz.getComponentType() ; } return len ; } // thoose below make java < 1.5 happy and me unhappy ;-) public static int getTrueLength(int x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : int ") ; } public static int getTrueLength(boolean x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : boolean ") ; } public static int getTrueLength(byte x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : byte ") ; } public static int getTrueLength(long x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : long ") ; } public static int getTrueLength(short x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : short ") ; } public static int getTrueLength(double x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : double ") ; } public static int getTrueLength(char x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : char ") ; } public static int getTrueLength(float x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : float ") ; } // }}} // {{{ isArray /** * Indicates if a java object is an array * * @param o object * @return true if the object is an array * @deprecated use RJavaArrayTools#isArray */ public static boolean isArray(Object o){ if( o == null) return false ; return o.getClass().isArray() ; } // thoose below make java < 1.5 happy and me unhappy ;-) public static boolean isArray(int x){ return false ; } public static boolean isArray(boolean x){ return false ; } public static boolean isArray(byte x){ return false ; } public static boolean isArray(long x){ return false ; } public static boolean isArray(short x){ return false ; } public static boolean isArray(double x){ return false ; } public static boolean isArray(char x){ return false ; } public static boolean isArray(float x){ return false ; } // }}} // {{{ ArrayDimensionMismatchException public static class ArrayDimensionMismatchException extends Exception { public ArrayDimensionMismatchException( int index_dim, int actual_dim ){ super( "dimension of indexer (" + index_dim + ") too large for array (depth ="+ actual_dim+ ")") ; } } // }}} // {{{ get /** * Gets a single object from a multi dimensional array * * @param array java array * @param position */ public static Object get( Object array, int[] position ) throws NotAnArrayException, ArrayDimensionMismatchException { return Array.get( getArray( array, position ), position[ position.length -1] ); } public static int getInt( Object array, int[] position ) throws NotAnArrayException, ArrayDimensionMismatchException { return Array.getInt( getArray( array, position ), position[ position.length -1] ); } public static boolean getBoolean( Object array, int[] position ) throws NotAnArrayException, ArrayDimensionMismatchException { return Array.getBoolean( getArray( array, position ), position[ position.length -1] ); } public static byte getByte( Object array, int[] position ) throws NotAnArrayException, ArrayDimensionMismatchException { return Array.getByte( getArray( array, position ), position[ position.length -1] ); } public static long getLong( Object array, int[] position ) throws NotAnArrayException, ArrayDimensionMismatchException { return Array.getLong( getArray( array, position ), position[ position.length -1] ); } public static short getShort( Object array, int[] position ) throws NotAnArrayException, ArrayDimensionMismatchException { return Array.getShort( getArray( array, position ), position[ position.length -1] ); } public static double getDouble( Object array, int[] position ) throws NotAnArrayException, ArrayDimensionMismatchException { return Array.getDouble( getArray( array, position ), position[ position.length -1] ); } public static char getChar( Object array, int[] position ) throws NotAnArrayException, ArrayDimensionMismatchException { return Array.getChar( getArray( array, position ), position[ position.length -1] ); } public static float getFloat( Object array, int[] position ) throws NotAnArrayException, ArrayDimensionMismatchException { return Array.getFloat( getArray( array, position ), position[ position.length -1] ); } public static Object get( Object array, int position ) throws NotAnArrayException, ArrayDimensionMismatchException { return get( array, new int[]{position} ) ; } public static int getInt( Object array, int position ) throws NotAnArrayException, ArrayDimensionMismatchException { return getInt( array, new int[]{position} ) ; } public static boolean getBoolean( Object array, int position ) throws NotAnArrayException, ArrayDimensionMismatchException { return getBoolean( array, new int[]{position} ) ; } public static byte getByte( Object array, int position ) throws NotAnArrayException, ArrayDimensionMismatchException { return getByte( array, new int[]{position} ) ; } public static long getLong( Object array, int position ) throws NotAnArrayException, ArrayDimensionMismatchException { return getLong( array, new int[]{position} ) ; } public static short getShort( Object array, int position ) throws NotAnArrayException, ArrayDimensionMismatchException { return getShort( array, new int[]{position} ) ; } public static double getDouble( Object array, int position ) throws NotAnArrayException, ArrayDimensionMismatchException { return getDouble( array, new int[]{position} ) ; } public static char getChar( Object array, int position ) throws NotAnArrayException, ArrayDimensionMismatchException { return getChar( array, new int[]{position} ) ; } public static float getFloat( Object array, int position ) throws NotAnArrayException, ArrayDimensionMismatchException { return getFloat( array, new int[]{position} ) ; } private static void checkDimensions(Object array, int[] position) throws NotAnArrayException, ArrayDimensionMismatchException { int poslength = position.length ; int actuallength = getDimensionLength(array); if( poslength > actuallength ){ throw new ArrayDimensionMismatchException( poslength, actuallength ) ; } } // }}} // {{{ set /** * Replaces a single value of the array * * @param array array * @param position index * @param value the new value * * @throws NotAnArrayException if array is not an array * @throws ArrayDimensionMismatchException if the length of position is too big */ public static void set( Object array, int[] position, Object value ) throws NotAnArrayException, ArrayDimensionMismatchException{ Array.set( getArray( array, position ), position[ position.length - 1], value ) ; } /* primitive versions */ public static void set( Object array, int[] position, int value ) throws NotAnArrayException, ArrayDimensionMismatchException{ Array.setInt( getArray( array, position ), position[ position.length - 1], value ) ; } public static void set( Object array, int[] position, boolean value ) throws NotAnArrayException, ArrayDimensionMismatchException{ Array.setBoolean( getArray( array, position ), position[ position.length - 1], value ) ; } public static void set( Object array, int[] position, byte value ) throws NotAnArrayException, ArrayDimensionMismatchException{ Array.setByte( getArray( array, position ), position[ position.length - 1], value ) ; } public static void set( Object array, int[] position, long value ) throws NotAnArrayException, ArrayDimensionMismatchException{ Array.setLong( getArray( array, position ), position[ position.length - 1], value ) ; } public static void set( Object array, int[] position, short value ) throws NotAnArrayException, ArrayDimensionMismatchException{ Array.setShort( getArray( array, position ), position[ position.length - 1], value ) ; } public static void set( Object array, int[] position, double value ) throws NotAnArrayException, ArrayDimensionMismatchException{ Array.setDouble( getArray( array, position ), position[ position.length - 1], value ) ; } public static void set( Object array, int[] position, char value ) throws NotAnArrayException, ArrayDimensionMismatchException{ Array.setChar( getArray( array, position ), position[ position.length - 1], value ) ; } public static void set( Object array, int[] position, float value ) throws NotAnArrayException, ArrayDimensionMismatchException{ Array.setFloat( getArray( array, position ), position[ position.length - 1], value ) ; } public static void set( Object array, int position, Object value ) throws NotAnArrayException, ArrayDimensionMismatchException{ set( array, new int[]{ position }, value ); } public static void set( Object array, int position, int value ) throws NotAnArrayException, ArrayDimensionMismatchException{ set( array, new int[]{ position }, value ); } public static void set( Object array, int position, boolean value ) throws NotAnArrayException, ArrayDimensionMismatchException{ set( array, new int[]{ position }, value ); } public static void set( Object array, int position, byte value ) throws NotAnArrayException, ArrayDimensionMismatchException{ set( array, new int[]{ position }, value ); } public static void set( Object array, int position, long value ) throws NotAnArrayException, ArrayDimensionMismatchException{ set( array, new int[]{ position }, value ); } public static void set( Object array, int position, short value ) throws NotAnArrayException, ArrayDimensionMismatchException{ set( array, new int[]{ position }, value ); } public static void set( Object array, int position, double value ) throws NotAnArrayException, ArrayDimensionMismatchException{ set( array, new int[]{ position }, value ); } public static void set( Object array, int position, char value ) throws NotAnArrayException, ArrayDimensionMismatchException{ set( array, new int[]{ position }, value ); } public static void set( Object array, int position, float value ) throws NotAnArrayException, ArrayDimensionMismatchException{ set( array, new int[]{ position }, value ); } private static Object getArray( Object array, int[] position ) throws NotAnArrayException, ArrayDimensionMismatchException{ checkDimensions( array, position ) ; int poslength = position.length ; Object o = array ; int i=0 ; if( poslength > 1 ){ while( i< (poslength-1) ){ o = Array.get( o, position[i] ) ; i++ ; } } return o ; } // TODO: also have primitive types in value // }}} // {{{ unique // TODO: cannot use LinkedHashSet because it first was introduced in 1.4 // and code in this area needs to work on 1.2 jvm public static Object[] unique( Object[] array ){ int n = array.length ; boolean[] unique = new boolean[ array.length ]; for( int i=0; i> new ArrayWrapper( int[] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(int[]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(int[]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("I") ){ throw new TestException( "ArrayWrapper(int[]).getObjectTypeName() != 'I'" ) ; } System.out.println( " I : ok" ); System.out.print( " >> flat_int()" ) ; int[] flat; try{ flat = wrapper.flat_int() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(int[]) >> FlatException") ; } for( int i=0; i<5; i++){ if( flat[i] != i ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_int_2 private static void flatten_int_2() throws TestException{ int[][] o = RectangularArrayExamples.getIntDoubleRectangularArrayExample(); ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( int[][] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(int[][]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(int[][]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("I") ){ throw new TestException( "ArrayWrapper(int[][]).getObjectTypeName() != 'I'" ) ; } System.out.println( " I : ok" ); System.out.print( " >> flat_int()" ) ; int[] flat; try{ flat = wrapper.flat_int() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(int[][]) >> FlatException") ; } for( int i=0; i<10; i++){ if( flat[i] != i ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_int_3 private static void flatten_int_3() throws TestException{ int[][][] o = RectangularArrayExamples.getIntTripleRectangularArrayExample(); ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( int[][][] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(int[][][]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(int[][][]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("I") ){ throw new TestException( "ArrayWrapper(int[][][]).getObjectTypeName() != 'I'" ) ; } System.out.println( " I : ok" ); System.out.print( " >> flat_int()" ) ; int[] flat; try{ flat = wrapper.flat_int() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(int[][][]) >> FlatException") ; } for( int i=0; i<30; i++){ if( flat[i] != i ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_boolean_1 private static void flatten_boolean_1() throws TestException{ boolean[] o = new boolean[5] ; boolean current = false; for( int i=0;i<5;i++){ o[i] = current ; current = !current ; } ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( boolean[] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(boolean[]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(boolean[]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("Z") ){ throw new TestException( "ArrayWrapper(boolean[]).getObjectTypeName() != 'Z'" ) ; } System.out.println( " Z : ok" ); System.out.print( " >> flat_boolean()" ) ; boolean[] flat; try{ flat = wrapper.flat_boolean() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(int[]) >> FlatException") ; } current = false ; for( int i=0; i<5; i++){ if( flat[i] != current ) throw new TestException( "flat[" + i + "] = " + flat [i] ); current = !current ; } System.out.println( " ok" ) ; } // }}} // {{{ flatten_boolean_2 private static void flatten_boolean_2() throws TestException{ boolean[][] o = RectangularArrayExamples.getBooleanDoubleRectangularArrayExample(); ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( boolean[][] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(boolean[][]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(boolean[][]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("Z") ){ throw new TestException( "ArrayWrapper(boolean[][]).getObjectTypeName() != 'Z'" ) ; } System.out.println( " Z : ok" ); System.out.print( " >> flat_boolean()" ) ; boolean[] flat; try{ flat = wrapper.flat_boolean() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(boolean[][]) >> FlatException") ; } boolean current = false ; for( int i=0; i<10; i++){ if( flat[i] != current ) throw new TestException( "flat[" + i + "] = " + flat [i] ); current = !current ; } System.out.println( " ok" ) ; } // }}} // {{{ flatten_boolean_3 private static void flatten_boolean_3() throws TestException{ boolean[][][] o = RectangularArrayExamples.getBooleanTripleRectangularArrayExample(); ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( boolean[][][] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(boolean[][][]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(boolean[][][]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("Z") ){ throw new TestException( "ArrayWrapper(int[][][]).getObjectTypeName() != 'Z'" ) ; } System.out.println( " Z : ok" ); System.out.print( " >> flat_boolean()" ) ; boolean[] flat; try{ flat = wrapper.flat_boolean() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(boolean[][][]) >> FlatException") ; } boolean current = false ; for( int i=0; i<30; i++){ if( flat[i] != current ) throw new TestException( "flat[" + i + "] = " + flat [i] ); current = !current ; } System.out.println( " ok" ) ; } // }}} // {{{ flatten_byte_1 private static void flatten_byte_1() throws TestException{ byte[] o = new byte[5] ; for( int i=0;i<5;i++) o[i] = (byte)i ; ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( byte[] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(byte[]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(byte[]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("B") ){ throw new TestException( "ArrayWrapper(byte[]).getObjectTypeName() != 'I'" ) ; } System.out.println( " B : ok" ); System.out.print( " >> flat_byte()" ) ; byte[] flat; try{ flat = wrapper.flat_byte() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(byte[]) >> FlatException") ; } for( int i=0; i<5; i++){ if( flat[i] != (byte)i ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_byte_2 private static void flatten_byte_2() throws TestException{ byte[][] o = RectangularArrayExamples.getByteDoubleRectangularArrayExample(); ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( byte[][] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(byte[][]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(byte[][]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("B") ){ throw new TestException( "ArrayWrapper(byte[][]).getObjectTypeName() != 'B'" ) ; } System.out.println( " B : ok" ); System.out.print( " >> flat_byte()" ) ; byte[] flat; try{ flat = wrapper.flat_byte() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(byte[][]) >> FlatException") ; } for( int i=0; i<10; i++){ if( flat[i] != (byte)i ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_byte_3 private static void flatten_byte_3() throws TestException{ byte[][][] o = RectangularArrayExamples.getByteTripleRectangularArrayExample(); ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( byte[][][] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(byte[][][]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(byte[][][]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("B") ){ throw new TestException( "ArrayWrapper(int[][][]).getObjectTypeName() != 'B'" ) ; } System.out.println( " B : ok" ); System.out.print( " >> flat_byte()" ) ; byte[] flat; try{ flat = wrapper.flat_byte() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(byte[][][]) >> FlatException") ; } for( int i=0; i<30; i++){ if( flat[i] != (byte)i ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_long_1 private static void flatten_long_1() throws TestException{ long[] o = new long[5] ; for( int i=0;i<5;i++) o[i] = (long)i ; ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( long[] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(long[]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(long[]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("J") ){ throw new TestException( "ArrayWrapper(long[]).getObjectTypeName() != 'J'" ) ; } System.out.println( " J : ok" ); System.out.print( " >> flat_long()" ) ; long[] flat; try{ flat = wrapper.flat_long() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(long[]) >> FlatException") ; } for( int i=0; i<5; i++){ if( flat[i] != (long)i ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_long_2 private static void flatten_long_2() throws TestException{ long[][] o = RectangularArrayExamples.getLongDoubleRectangularArrayExample(); ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( long[][] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(long[][]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(long[][]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("J") ){ throw new TestException( "ArrayWrapper(long[][]).getObjectTypeName() != 'J'" ) ; } System.out.println( " J : ok" ); System.out.print( " >> flat_long()" ) ; long[] flat; try{ flat = wrapper.flat_long() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(long[][]) >> FlatException") ; } for( int i=0; i<10; i++){ if( flat[i] != (long)i ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_long_3 private static void flatten_long_3() throws TestException{ long[][][] o = RectangularArrayExamples.getLongTripleRectangularArrayExample(); ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( long[][][] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(long[][][]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(long[][][]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("J") ){ throw new TestException( "ArrayWrapper(long[][][]).getObjectTypeName() != 'J'" ) ; } System.out.println( " J : ok" ); System.out.print( " >> flat_long()" ) ; long[] flat; try{ flat = wrapper.flat_long() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(long[][][]) >> FlatException") ; } for( int i=0; i<30; i++){ if( flat[i] != (long)i ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_short_1 private static void flatten_short_1() throws TestException{ short[] o = new short[5] ; for( int i=0;i<5;i++) o[i] = (short)i ; ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( short[] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(short[]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(short[]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("S") ){ throw new TestException( "ArrayWrapper(long[]).getObjectTypeName() != 'S'" ) ; } System.out.println( " S : ok" ); System.out.print( " >> flat_short()" ) ; short[] flat; try{ flat = wrapper.flat_short() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(short[]) >> FlatException") ; } for( int i=0; i<5; i++){ if( flat[i] != (double)i ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_short_2 private static void flatten_short_2() throws TestException{ short[][] o = RectangularArrayExamples.getShortDoubleRectangularArrayExample(); ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( short[][] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(short[][]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(short[][]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("S") ){ throw new TestException( "ArrayWrapper(short[][]).getObjectTypeName() != 'S'" ) ; } System.out.println( " S : ok" ); System.out.print( " >> flat_short()" ) ; short[] flat; try{ flat = wrapper.flat_short() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(short[][]) >> FlatException") ; } for( int i=0; i<10; i++){ if( flat[i] != (double)i ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_short_3 private static void flatten_short_3() throws TestException{ short[][][] o = RectangularArrayExamples.getShortTripleRectangularArrayExample(); ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( short[][][] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(short[][][]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(short[][][]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("S") ){ throw new TestException( "ArrayWrapper(short[][][]).getObjectTypeName() != 'S'" ) ; } System.out.println( " S : ok" ); System.out.print( " >> flat_short()" ) ; short[] flat; try{ flat = wrapper.flat_short() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(short[][][]) >> FlatException") ; } for( int i=0; i<30; i++){ if( flat[i] != (double)i ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_double_1 private static void flatten_double_1() throws TestException{ double[] o = new double[5] ; for( int i=0;i<5;i++) o[i] = i+0.0 ; ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( double[] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(double[]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(double[]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("D") ){ throw new TestException( "ArrayWrapper(double[]).getObjectTypeName() != 'D'" ) ; } System.out.println( " D : ok" ); System.out.print( " >> flat_double()" ) ; double[] flat; try{ flat = wrapper.flat_double() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(double[]) >> FlatException") ; } for( int i=0; i<5; i++){ if( flat[i] != (i+0.0) ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_double_2 private static void flatten_double_2() throws TestException{ double[][] o = RectangularArrayExamples.getDoubleDoubleRectangularArrayExample(); ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( double[][] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(double[][]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(double[][]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("D") ){ throw new TestException( "ArrayWrapper(double[][]).getObjectTypeName() != 'D'" ) ; } System.out.println( " D : ok" ); System.out.print( " >> flat_double()" ) ; double[] flat; try{ flat = wrapper.flat_double() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(double[][]) >> FlatException") ; } for( int i=0; i<10; i++){ if( flat[i] != (i+0.0) ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_double_3 private static void flatten_double_3() throws TestException{ double[][][] o = RectangularArrayExamples.getDoubleTripleRectangularArrayExample(); ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( double[][][] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(double[][][]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(double[][][]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("D") ){ throw new TestException( "ArrayWrapper(double[][][]).getObjectTypeName() != 'D'" ) ; } System.out.println( " D : ok" ); System.out.print( " >> flat_double()" ) ; double[] flat; try{ flat = wrapper.flat_double() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(double[][][]) >> FlatException") ; } for( int i=0; i<30; i++){ if( flat[i] != (i+0.0) ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_char_1 private static void flatten_char_1() throws TestException{ char[] o = new char[5] ; for( int i=0;i<5;i++) o[i] = (char)i ; ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( char[] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(char[]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(char[]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("C") ){ throw new TestException( "ArrayWrapper(char[]).getObjectTypeName() != 'C'" ) ; } System.out.println( " C : ok" ); System.out.print( " >> flat_char()" ) ; char[] flat; try{ flat = wrapper.flat_char() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(char[]) >> FlatException") ; } for( int i=0; i<5; i++){ if( flat[i] != (char)i ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_char_2 private static void flatten_char_2() throws TestException{ char[][] o = RectangularArrayExamples.getCharDoubleRectangularArrayExample(); ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( char[][] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(char[][]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(char[][]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("C") ){ throw new TestException( "ArrayWrapper(char[][]).getObjectTypeName() != 'C'" ) ; } System.out.println( " C : ok" ); System.out.print( " >> flat_char()" ) ; char[] flat; try{ flat = wrapper.flat_char() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(char[][]) >> FlatException") ; } for( int i=0; i<10; i++){ if( flat[i] != (i+0.0) ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_char_3 private static void flatten_char_3() throws TestException{ char[][][] o = RectangularArrayExamples.getCharTripleRectangularArrayExample(); ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( char[][][] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(char[][][]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(char[][][]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("C") ){ throw new TestException( "ArrayWrapper(char[][][]).getObjectTypeName() != 'C'" ) ; } System.out.println( " C : ok" ); System.out.print( " >> flat_char()" ) ; char[] flat; try{ flat = wrapper.flat_char() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(char[][][]) >> FlatException") ; } for( int i=0; i<30; i++){ if( flat[i] != (char)i ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_float_1 private static void flatten_float_1() throws TestException{ float[] o = new float[5] ; for( int i=0;i<5;i++) o[i] = (float)(i+0.0) ; ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( float[] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(float[]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(float[]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("F") ){ throw new TestException( "ArrayWrapper(float[]).getObjectTypeName() != 'F'" ) ; } System.out.println( " F : ok" ); System.out.print( " >> flat_float()" ) ; float[] flat; try{ flat = wrapper.flat_float() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(float[]) >> FlatException") ; } for( int i=0; i<5; i++){ if( flat[i] != (i+0.0) ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_float_2 private static void flatten_float_2() throws TestException{ float[][] o = RectangularArrayExamples.getFloatDoubleRectangularArrayExample(); ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( float[][] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(float[][]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(float[][]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("F") ){ throw new TestException( "ArrayWrapper(float[][]).getObjectTypeName() != 'F'" ) ; } System.out.println( " F : ok" ); System.out.print( " >> flat_float()" ) ; float[] flat; try{ flat = wrapper.flat_float() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(float[][]) >> FlatException") ; } for( int i=0; i<10; i++){ if( flat[i] != (i+0.0) ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_float_3 private static void flatten_float_3() throws TestException{ float[][][] o = RectangularArrayExamples.getFloatTripleRectangularArrayExample(); ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( float[][][] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(float[][][]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(float[][][]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("F") ){ throw new TestException( "ArrayWrapper(float[][][]).getObjectTypeName() != 'F'" ) ; } System.out.println( " F : ok" ); System.out.print( " >> flat_float()" ) ; float[] flat; try{ flat = wrapper.flat_float() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(float[][][]) >> FlatException") ; } for( int i=0; i<30; i++){ if( flat[i] != (float)(i+0.0) ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // }}} // {{{ flat array of String // {{{ flatten_String_1 private static void flatten_String_1() throws TestException{ String[] o = new String[5] ; for( int i=0;i<5;i++) o[i] = ""+i ; ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( String[] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(String[]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(String[]) is primitive" ) ; } System.out.println( " false : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("java.lang.String") ){ throw new TestException( "ArrayWrapper(float[]).getObjectTypeName() != 'java.lang.String'" ) ; } System.out.println( " java.lang.String : ok" ); System.out.print( " >> flat_String()" ) ; String[] flat; try{ flat = wrapper.flat_String() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(String[]) >> FlatException") ; } for( int i=0; i<5; i++){ if( ! flat[i].equals(""+i) ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_String_2 private static void flatten_String_2() throws TestException{ String[][] o = RectangularArrayExamples.getStringDoubleRectangularArrayExample(); ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( String[][] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(String[][]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(String[][]) is primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("java.lang.String") ){ throw new TestException( "ArrayWrapper(float[][]).getObjectTypeName() != 'java.lang.String'" ) ; } System.out.println( " java.lang.String : ok" ); System.out.print( " >> flat_String()" ) ; String[] flat; try{ flat = wrapper.flat_String() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(String[][]) >> FlatException") ; } for( int i=0; i<10; i++){ if( ! flat[i].equals( ""+i) ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_String_3 private static void flatten_String_3() throws TestException{ String[][][] o = RectangularArrayExamples.getStringTripleRectangularArrayExample(); ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( String[][][] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(String[][][]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(String[][][]) is primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("java.lang.String") ){ throw new TestException( "ArrayWrapper(String[][][]).getObjectTypeName() != 'java.lang.String'" ) ; } System.out.println( " java.lang.String : ok" ); System.out.print( " >> flat_String()" ) ; String[] flat; try{ flat = wrapper.flat_String() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(String[][][]) >> FlatException") ; } for( int i=0; i<30; i++){ if( !flat[i].equals( ""+i) ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // }}} // {{{ flat array of Point // {{{ flatten_Point_1 private static void flatten_Point_1() throws TestException{ DummyPoint[] o = new DummyPoint[5] ; for( int i=0;i<5;i++) o[i] = new DummyPoint(i,i) ; ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( DummyPoint[] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(DummyPoint[]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(DummyPoint[]) is primitive" ) ; } System.out.println( " false : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("DummyPoint") ){ throw new TestException( "ArrayWrapper(DummyPoint[]).getObjectTypeName() != 'DummyPoint'" ) ; } System.out.println( " DummyPoint : ok" ); System.out.print( " >> flat_Object()" ) ; DummyPoint[] flat ; try{ flat = (DummyPoint[])wrapper.flat_Object() ; } catch( ObjectArrayException e){ throw new TestException( "ObjectArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(DummyPoint[]) >> FlatException") ; } DummyPoint p ; for( int i=0; i<5; i++){ p = flat[i] ; if( p.x != i || p.y != i) throw new TestException( "flat[" + i + "].x = " + p.x + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_Point_2 private static void flatten_Point_2() throws TestException{ DummyPoint[][] o = RectangularArrayExamples.getDummyPointDoubleRectangularArrayExample(); ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( DummyPoint[][] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(DummyPoint[][]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(DummyPoint[][]) is primitive" ) ; } System.out.println( " false : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("DummyPoint") ){ throw new TestException( "ArrayWrapper(DummyPoint[][]).getObjectTypeName() != 'DummyPoint'" ) ; } System.out.println( " DummyPoint : ok" ); System.out.print( " >> flat_Object()" ) ; DummyPoint[] flat; try{ flat = (DummyPoint[])wrapper.flat_Object() ; } catch( ObjectArrayException e){ throw new TestException( "ObjectArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(DummyPoint[][]) >> FlatException") ; } DummyPoint p; for( int i=0; i<10; i++){ p = flat[i] ; if( p.x != i || p.y != i) throw new TestException( "flat[" + i + "].x = " + p.x + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_Point_3 private static void flatten_Point_3() throws TestException{ DummyPoint[][][] o = RectangularArrayExamples.getDummyPointTripleRectangularArrayExample(); ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( DummyPoint[][][] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(DummyPoint[][][]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(DummyPoint[][][]) is primitive" ) ; } System.out.println( " false : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("DummyPoint") ){ throw new TestException( "ArrayWrapper(DummyPoint[][][]).getObjectTypeName() != 'DummyPoint'" ) ; } System.out.println( " DummyPoint : ok" ); System.out.print( " >> flat_Object()" ) ; DummyPoint[] flat; try{ flat = (DummyPoint[])wrapper.flat_Object() ; } catch( ObjectArrayException e){ throw new TestException( "ObjectArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(Object[][][]) >> FlatException") ; } DummyPoint p; for( int i=0; i<30; i++){ p = flat[i]; if( p.x != i || p.y != i ) throw new TestException( "flat[" + i + "].x = " + p.x + "!=" + i); } System.out.println( " ok" ) ; } // }}} // }}} } rJava/inst/java/RJavaTools.class0000644000176200001440000002103412256051770016273 0ustar liggesusers.. _ ^  ^     ^  ^ ^     _ ^ ^     ^ ^  , ^ ^     ^ ^ 5 _ ^ ^       ()VCodeLineNumberTablegetClass7(Ljava/lang/Class;Ljava/lang/String;Z)Ljava/lang/Class;getStaticClasses%(Ljava/lang/Class;)[Ljava/lang/Class;isStatic(Ljava/lang/Class;)ZgetStaticFields-(Ljava/lang/Class;)[Ljava/lang/reflect/Field;getStaticMethods.(Ljava/lang/Class;)[Ljava/lang/reflect/Method; getFieldNames'(Ljava/lang/Class;Z)[Ljava/lang/String;getMethodNamesgetMemberNames1([Ljava/lang/reflect/Member;Z)[Ljava/lang/String;getCompletionName.(Ljava/lang/reflect/Member;)Ljava/lang/String;(Ljava/lang/reflect/Member;)ZhasField'(Ljava/lang/Object;Ljava/lang/String;)ZhasClass classHasField'(Ljava/lang/Class;Ljava/lang/String;Z)ZclassHasMethod classHasClass hasMethod newInstanceJ(Ljava/lang/Class;[Ljava/lang/Object;[Ljava/lang/Class;)Ljava/lang/Object; Exceptions arg_is_null([Ljava/lang/Object;)[Z invokeMethodn(Ljava/lang/Class;Ljava/lang/Object;Ljava/lang/String;[Ljava/lang/Object;[Ljava/lang/Class;)Ljava/lang/Object;getConstructorF(Ljava/lang/Class;[Ljava/lang/Class;[Z)Ljava/lang/reflect/Constructor; isPrimitive getMethodS(Ljava/lang/Class;Ljava/lang/String;[Ljava/lang/Class;[Z)Ljava/lang/reflect/Method;isMoreSpecific7(Ljava/lang/reflect/Method;Ljava/lang/reflect/Method;)ZA(Ljava/lang/reflect/Constructor;Ljava/lang/reflect/Constructor;)Z'([Ljava/lang/Class;[Ljava/lang/Class;)Z getClasses&(Ljava/lang/Object;)[Ljava/lang/Class; getClassNames'(Ljava/lang/Object;)[Ljava/lang/String;getSimpleClassNames((Ljava/lang/Object;Z)[Ljava/lang/String;getSimpleClassName&(Ljava/lang/Object;)Ljava/lang/String; getSimpleName&(Ljava/lang/String;)Ljava/lang/String;getFieldTypeName7(Ljava/lang/Class;Ljava/lang/String;)Ljava/lang/String; SourceFileRJavaTools.java `a hijava/util/Vector java/lang/Class  hujava/lang/reflect/Field java/lang/reflect/Method qrjava/lang/String st )java/lang/StringBuffer (  d yz |z {z      ~+java/lang/reflect/InvocationTargetException  [Ljava/lang/Class; java/lang/NoSuchMethodException  i i ,No constructor matching the given parameters `  ! " +No suitable method for the given parameters #  Exceptionerror condition $% &' ()intdoublebooleanbytelongfloatshortchar (*[] +, - java/lang/NoSuchFieldException RJavaToolsjava/lang/Objectjava/lang/Throwablejava/lang/SecurityException()[Ljava/lang/Class;getName()Ljava/lang/String;equals(Ljava/lang/Object;)Zaddsize()ItoArray(([Ljava/lang/Object;)[Ljava/lang/Object; getModifiers getFields()[Ljava/lang/reflect/Field; getMethods()[Ljava/lang/reflect/Method;java/lang/reflect/MembergetParameterTypesappend,(Ljava/lang/String;)Ljava/lang/StringBuffer;toString()Ljava/lang/Class;java/lang/reflect/Constructor isAccessible()Z setAccessible(Z)V'([Ljava/lang/Object;)Ljava/lang/Object;getTargetException()Ljava/lang/Throwable;invoke9(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;3([Ljava/lang/Class;)Ljava/lang/reflect/Constructor;getConstructors"()[Ljava/lang/reflect/Constructor;isAssignableFrom(Ljava/lang/String;)Vjava/lang/BooleanTYPELjava/lang/Class;java/lang/Integerjava/lang/Doublejava/lang/Floatjava/lang/Longjava/lang/Shortjava/lang/Character@(Ljava/lang/String;[Ljava/lang/Class;)Ljava/lang/reflect/Method; getSuperclass lastIndexOf(I)IcharAt(I)C substring(II)Ljava/lang/String;(I)Ljava/lang/String;getField-(Ljava/lang/String;)Ljava/lang/reflect/Field;getType!^_ `ab*c$ debg;*N6---2+ -2-2c./0.13/94 fgbV*L+YM+>6+2: , W, , :, Wc:?@ BCDE%F-G4D:JAKCMLNSO hib(* ~cY jkbW*L+YM+>6+2: , W, , :, Wc>cd e ghi j&k.l5i;oBpDrMsTt lmbW*LYM++>6+2: , W, , :, Wc>~  &.5;BDMT nob! *c pob! *c qrbM*>TY:6"*2: W  M, W"M6,*2S,cV $*2=CKPY`chq| stbpH* **3*LY*+c(E hub**~c vwb" * +!c xwb" * +"c yzbd8*N6-*+-2#-2$~c.06 {zbd8*N6-*+-2%-2&~c#$%.&0$6' |zbd8*N6-*+-2 -2c678.9076: }wb" * +'cH ~b c+N6+-+2T*,-(:)6*++:*:-:*:BL,:BTLVTc:STUT%X-[4\:`BeIfLaNcTe`gbU)**L=*+*2T+ckl mn!m'p b D*,-./:061+-2:1:-: 1 #-,#5-75c* z }~#*-/5A bv *N++*34N-*+4N--:N*6:62:7:+b+66 6  <, 3+ 28%6 %+ 2 2+ 29 6  - -:N}- 5Y;<-'+5c#"&(+-/5@GNVY]`jq{~5ibdL*=>?*?>5*@>+*A>!*B>*C> *D>c b *,, *+3E*+,E:::*:62:%+w:,e,6 6 6   <- 3, 28%6 %, 2 2, 29 6   F:k 5YG<(,5c#!&),.17BIUX_gjnq{   5 b0*M+N,-Hc)* + b0*7M+7N,-Hc89 : bN*=>69*2+2(*2+29 +2+29c* KLMNO'P-Q;R>MDT bc/YL* M,+, W,IM+ N+- W-c"]^ _`ac'd-e bf2YL* M,+, W,IM+ N+- W-c"no pqr"t*u0v bl=YN* :*:J=- WI: -J W-K W-L W- :- WcF )+2<@DKRYbi b# * c b*[M<**[M`NL**[M`*;MOKf*N=I PKTD QKHZ RK<B SK0J TK$F UKS VK CWK*$M= *`XK*.M> *`XK*Y*Y:6ZW*c" 28>DJPV\bhntz bJM*+[\MNM,]crJava/inst/java/RectangularArrayBuilder_Test.java0000644000176200001440000005766112256051770021656 0ustar liggesusers// :tabSize=2:indentSize=2:noTabs=false:folding=explicit:collapseFolds=1: /** * Test suite for RectangularArrayBuilder */ public class RectangularArrayBuilder_Test { private static int[] dim1d = {10} ; private static int[] dim2d = {5,2} ; private static int[] dim3d = {5,3,2} ; // {{{ main public static void main(String[] args ){ try{ runtests() ; } catch( TestException e){ e.printStackTrace(); System.exit(1); } System.out.println( "\nALL PASSED\n" ) ; System.exit( 0 ); } // }}} // {{{ runtests public static void runtests() throws TestException { // {{{ 1d System.out.println( " >> 1 d" ); System.out.print( "fill int[]" ); fill_int_1(); System.out.println( " : ok" ); System.out.print( "fill boolean[]" ); fill_boolean_1(); System.out.println( " : ok" ); System.out.print( "fill byte[]" ); fill_byte_1(); System.out.println( " : ok" ); System.out.print( "fill long[]" ); fill_long_1(); System.out.println( " : ok" ); System.out.print( "fill short[]" ); fill_short_1(); System.out.println( " : ok" ); System.out.print( "fill double[]" ); fill_double_1(); System.out.println( " : ok" ); System.out.print( "fill char[]" ); fill_char_1(); System.out.println( " : ok" ); System.out.print( "fill float[]" ); fill_float_1(); System.out.println( " : ok" ); System.out.print( "fill String[]" ); fill_String_1(); System.out.println( " : ok" ); System.out.print( "fill Point[]" ); fill_Point_1(); System.out.println( " : ok" ); // }}} // {{{ 2d System.out.println( " >> 2 d" ); System.out.print( "fill int[][]" ); fill_int_2(); System.out.println( " : ok" ); System.out.print( "fill boolean[][]" ); fill_boolean_2(); System.out.println( " : ok" ); System.out.print( "fill byte[][]" ); fill_byte_2(); System.out.println( " : ok" ); System.out.print( "fill long[][]" ); fill_long_2(); System.out.println( " : ok" ); System.out.print( "fill short[][]" ); fill_short_2(); System.out.println( " : ok" ); System.out.print( "fill double[][]" ); fill_double_2(); System.out.println( " : ok" ); System.out.print( "fill char[][]" ); fill_char_2(); System.out.println( " : ok" ); System.out.print( "fill float[][]" ); fill_float_2(); System.out.println( " : ok" ); System.out.print( "fill String[][]" ); fill_String_2(); System.out.println( " : ok" ); System.out.print( "fill Point[][]" ); fill_Point_2(); System.out.println( " : ok" ); // }}} // {{{ 3d System.out.println( " >> 3 d" ); System.out.print( "fill int[][][]" ); fill_int_3(); System.out.println( " : ok" ); System.out.print( "fill boolean[][][]" ); fill_boolean_3(); System.out.println( " : ok" ); System.out.print( "fill byte[][][]" ); fill_byte_3(); System.out.println( " : ok" ); System.out.print( "fill long[][][]" ); fill_long_3(); System.out.println( " : ok" ); System.out.print( "fill short[][][]" ); fill_short_3(); System.out.println( " : ok" ); System.out.print( "fill double[][][]" ); fill_double_3(); System.out.println( " : ok" ); System.out.print( "fill char[][][]" ); fill_char_3(); System.out.println( " : ok" ); System.out.print( "fill float[][][]" ); fill_float_3(); System.out.println( " : ok" ); System.out.print( "fill String[][][]" ); fill_String_3(); System.out.println( " : ok" ); System.out.print( "fill Point[][][]" ); fill_Point_3(); System.out.println( " : ok" ); // }}} } //}}} // {{{ 1d private static void fill_int_1() throws TestException{ RectangularArrayBuilder builder = null; try{ builder = new RectangularArrayBuilder( ints(10), dim1d ); } catch( NotAnArrayException e){ throw new TestException( "not an array int[10]" ) ; } catch( ArrayDimensionException e){ throw new TestException( "array dimensionexception" ) ; } int[] data = (int[])builder.getArray(); int current = 0; for( int i=0; i(Ljava/lang/String;)VCodeLineNumberTable SourceFileTestException.java  TestExceptionjava/lang/Exception!*+ rJava/inst/java/ArrayWrapper_Test.class0000644000176200001440000006360412256051770017676 0ustar liggesusers. @i ?jk l mn mop qrs ?tuv ?wx ?yz ?{| ?}~ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? q H  H H   H ^i ^ ^ ^   H ^   H      H  ^   !" H#$ %&'()* +,-./01234567 H89 ^: ;<=>?@ ABCDEFGHIJKLM HNO ^P QRSTUV WXYZ[\]^_`abc Hde ^f ghijkl mnopqrstuvwxyz{| H}~   " H " "  ()VCodeLineNumberTablemain([Ljava/lang/String;)Vruntests Exceptions flatten_int_1 flatten_int_2 flatten_int_3flatten_boolean_1flatten_boolean_2flatten_boolean_3flatten_byte_1flatten_byte_2flatten_byte_3flatten_long_1flatten_long_2flatten_long_3flatten_short_1flatten_short_2flatten_short_3flatten_double_1flatten_double_2flatten_double_3flatten_char_1flatten_char_2flatten_char_3flatten_float_1flatten_float_2flatten_float_3flatten_String_1flatten_String_2flatten_String_3flatten_Point_1flatten_Point_2flatten_Point_3 SourceFileArrayWrapper_Test.java AB GB TestException B   ALL PASSED   flatten int[] IBPASSEDflatten int[][] JBflatten int[][][] KBflatten boolean[] LBflatten boolean[][] MBflatten boolean[][][] NBflatten byte[] OBflatten byte[][] PBflatten byte[][][] QBflatten long[] RBflatten long[][] SBflatten long[][][] TBflatten short[] UBflatten short[][] VBflatten short[][][] WBflatten double[] XBflatten double[][] YBflatten double[][][] ZBflatten char[] [Bflatten char[][] \Bflatten char[][][] ]Bflatten float[] ^Bflatten float[][] _Bflatten float[][][] `Bflatten String[] aBflatten String[][] bBflatten String[][][] cBflatten Point[] dBflatten Point[][] eBflatten Point[][][] fB >> new ArrayWrapper( int[] )  ArrayWrapper ANotAnArrayException/new ArrayWrapper(int[]) >> NotAnArrayException Aok >> isPrimitive() !ArrayWrapper(int[]) not primitive true : ok >> getObjectTypeName() I .ArrayWrapper(int[]).getObjectTypeName() != 'I' I : ok >> flat_int() PrimitiveArrayException FlatException(new ArrayWrapper(int[]) >> FlatExceptionjava/lang/StringBufferflat[  ] = !=  ok ! >> new ArrayWrapper( int[][] ) 1new ArrayWrapper(int[][]) >> NotAnArrayException #ArrayWrapper(int[][]) not primitive0ArrayWrapper(int[][]).getObjectTypeName() != 'I'*new ArrayWrapper(int[][]) >> FlatException # >> new ArrayWrapper( int[][][] ) 3new ArrayWrapper(int[][][]) >> NotAnArrayException %ArrayWrapper(int[][][]) not primitive2ArrayWrapper(int[][][]).getObjectTypeName() != 'I',new ArrayWrapper(int[][][]) >> FlatException# >> new ArrayWrapper( boolean[] ) 3new ArrayWrapper(boolean[]) >> NotAnArrayException %ArrayWrapper(boolean[]) not primitiveZ2ArrayWrapper(boolean[]).getObjectTypeName() != 'Z' Z : ok >> flat_boolean()   % >> new ArrayWrapper( boolean[][] ) 5new ArrayWrapper(boolean[][]) >> NotAnArrayException 'ArrayWrapper(boolean[][]) not primitive4ArrayWrapper(boolean[][]).getObjectTypeName() != 'Z'.new ArrayWrapper(boolean[][]) >> FlatException ' >> new ArrayWrapper( boolean[][][] ) 7new ArrayWrapper(boolean[][][]) >> NotAnArrayException )ArrayWrapper(boolean[][][]) not primitive2ArrayWrapper(int[][][]).getObjectTypeName() != 'Z'0new ArrayWrapper(boolean[][][]) >> FlatException >> new ArrayWrapper( byte[] ) 0new ArrayWrapper(byte[]) >> NotAnArrayException "ArrayWrapper(byte[]) not primitiveB/ArrayWrapper(byte[]).getObjectTypeName() != 'I' B : ok >> flat_byte() )new ArrayWrapper(byte[]) >> FlatException " >> new ArrayWrapper( byte[][] ) 2new ArrayWrapper(byte[][]) >> NotAnArrayException $ArrayWrapper(byte[][]) not primitive1ArrayWrapper(byte[][]).getObjectTypeName() != 'B'+new ArrayWrapper(byte[][]) >> FlatException $ >> new ArrayWrapper( byte[][][] ) 4new ArrayWrapper(byte[][][]) >> NotAnArrayException &ArrayWrapper(byte[][][]) not primitive2ArrayWrapper(int[][][]).getObjectTypeName() != 'B'-new ArrayWrapper(byte[][][]) >> FlatException >> new ArrayWrapper( long[] ) 0new ArrayWrapper(long[]) >> NotAnArrayException "ArrayWrapper(long[]) not primitiveJ/ArrayWrapper(long[]).getObjectTypeName() != 'J' J : ok >> flat_long() )new ArrayWrapper(long[]) >> FlatException  " >> new ArrayWrapper( long[][] ) 2new ArrayWrapper(long[][]) >> NotAnArrayException $ArrayWrapper(long[][]) not primitive1ArrayWrapper(long[][]).getObjectTypeName() != 'J'+new ArrayWrapper(long[][]) >> FlatException $ >> new ArrayWrapper( long[][][] ) 4new ArrayWrapper(long[][][]) >> NotAnArrayException &ArrayWrapper(long[][][]) not primitive3ArrayWrapper(long[][][]).getObjectTypeName() != 'J'-new ArrayWrapper(long[][][]) >> FlatException! >> new ArrayWrapper( short[] ) 1new ArrayWrapper(short[]) >> NotAnArrayException #ArrayWrapper(short[]) not primitiveS/ArrayWrapper(long[]).getObjectTypeName() != 'S' S : ok >> flat_short() *new ArrayWrapper(short[]) >> FlatException # >> new ArrayWrapper( short[][] ) 3new ArrayWrapper(short[][]) >> NotAnArrayException %ArrayWrapper(short[][]) not primitive2ArrayWrapper(short[][]).getObjectTypeName() != 'S',new ArrayWrapper(short[][]) >> FlatException % >> new ArrayWrapper( short[][][] ) 5new ArrayWrapper(short[][][]) >> NotAnArrayException 'ArrayWrapper(short[][][]) not primitive4ArrayWrapper(short[][][]).getObjectTypeName() != 'S'.new ArrayWrapper(short[][][]) >> FlatException" >> new ArrayWrapper( double[] ) 2new ArrayWrapper(double[]) >> NotAnArrayException $ArrayWrapper(double[]) not primitiveD1ArrayWrapper(double[]).getObjectTypeName() != 'D' D : ok >> flat_double() +new ArrayWrapper(double[]) >> FlatException  $ >> new ArrayWrapper( double[][] ) 4new ArrayWrapper(double[][]) >> NotAnArrayException &ArrayWrapper(double[][]) not primitive3ArrayWrapper(double[][]).getObjectTypeName() != 'D'-new ArrayWrapper(double[][]) >> FlatException & >> new ArrayWrapper( double[][][] ) 6new ArrayWrapper(double[][][]) >> NotAnArrayException (ArrayWrapper(double[][][]) not primitive5ArrayWrapper(double[][][]).getObjectTypeName() != 'D'/new ArrayWrapper(double[][][]) >> FlatException >> new ArrayWrapper( char[] ) 0new ArrayWrapper(char[]) >> NotAnArrayException "ArrayWrapper(char[]) not primitiveC/ArrayWrapper(char[]).getObjectTypeName() != 'C' C : ok >> flat_char() )new ArrayWrapper(char[]) >> FlatException  " >> new ArrayWrapper( char[][] ) 2new ArrayWrapper(char[][]) >> NotAnArrayException $ArrayWrapper(char[][]) not primitive1ArrayWrapper(char[][]).getObjectTypeName() != 'C'+new ArrayWrapper(char[][]) >> FlatException $ >> new ArrayWrapper( char[][][] ) 4new ArrayWrapper(char[][][]) >> NotAnArrayException &ArrayWrapper(char[][][]) not primitive3ArrayWrapper(char[][][]).getObjectTypeName() != 'C'-new ArrayWrapper(char[][][]) >> FlatException! >> new ArrayWrapper( float[] ) 1new ArrayWrapper(float[]) >> NotAnArrayException #ArrayWrapper(float[]) not primitiveF0ArrayWrapper(float[]).getObjectTypeName() != 'F' F : ok >> flat_float() *new ArrayWrapper(float[]) >> FlatException  # >> new ArrayWrapper( float[][] ) 3new ArrayWrapper(float[][]) >> NotAnArrayException %ArrayWrapper(float[][]) not primitive2ArrayWrapper(float[][]).getObjectTypeName() != 'F',new ArrayWrapper(float[][]) >> FlatException % >> new ArrayWrapper( float[][][] ) 5new ArrayWrapper(float[][][]) >> NotAnArrayException 'ArrayWrapper(float[][][]) not primitive4ArrayWrapper(float[][][]).getObjectTypeName() != 'F'.new ArrayWrapper(float[][][]) >> FlatExceptionjava/lang/String" >> new ArrayWrapper( String[] ) 2new ArrayWrapper(String[]) >> NotAnArrayException #ArrayWrapper(String[]) is primitive false : okjava.lang.String?ArrayWrapper(float[]).getObjectTypeName() != 'java.lang.String' java.lang.String : ok >> flat_String() +new ArrayWrapper(String[]) >> FlatException $ >> new ArrayWrapper( String[][] ) 4new ArrayWrapper(String[][]) >> NotAnArrayException %ArrayWrapper(String[][]) is primitiveAArrayWrapper(float[][]).getObjectTypeName() != 'java.lang.String'-new ArrayWrapper(String[][]) >> FlatException & >> new ArrayWrapper( String[][][] ) 6new ArrayWrapper(String[][][]) >> NotAnArrayException 'ArrayWrapper(String[][][]) is primitiveDArrayWrapper(String[][][]).getObjectTypeName() != 'java.lang.String'/new ArrayWrapper(String[][][]) >> FlatException DummyPoint A& >> new ArrayWrapper( DummyPoint[] ) 6new ArrayWrapper(DummyPoint[]) >> NotAnArrayException 'ArrayWrapper(DummyPoint[]) is primitive>ArrayWrapper(DummyPoint[]).getObjectTypeName() != 'DummyPoint' DummyPoint : ok >> flat_Object()  [LDummyPoint;ObjectArrayException/new ArrayWrapper(DummyPoint[]) >> FlatException  ].x = ( >> new ArrayWrapper( DummyPoint[][] ) 8new ArrayWrapper(DummyPoint[][]) >> NotAnArrayException )ArrayWrapper(DummyPoint[][]) is primitive@ArrayWrapper(DummyPoint[][]).getObjectTypeName() != 'DummyPoint'1new ArrayWrapper(DummyPoint[][]) >> FlatException * >> new ArrayWrapper( DummyPoint[][][] ) :new ArrayWrapper(DummyPoint[][][]) >> NotAnArrayException +ArrayWrapper(DummyPoint[][][]) is primitiveBArrayWrapper(DummyPoint[][][]).getObjectTypeName() != 'DummyPoint'/new ArrayWrapper(Object[][][]) >> FlatExceptionArrayWrapper_Testjava/lang/ObjectprintStackTracejava/lang/Systemexit(I)VoutLjava/io/PrintStream;java/io/PrintStreamprintln(Ljava/lang/String;)Vprint(Ljava/lang/Object;)V isPrimitive()ZgetObjectTypeName()Ljava/lang/String;equals(Ljava/lang/Object;)Zflat_int()[Iappend,(Ljava/lang/String;)Ljava/lang/StringBuffer;(I)Ljava/lang/StringBuffer;toStringRectangularArrayExamples#getIntDoubleRectangularArrayExample()[[I#getIntTripleRectangularArrayExample()[[[I flat_boolean()[Z(Z)Ljava/lang/StringBuffer;'getBooleanDoubleRectangularArrayExample()[[Z'getBooleanTripleRectangularArrayExample()[[[Z flat_byte()[B$getByteDoubleRectangularArrayExample()[[B$getByteTripleRectangularArrayExample()[[[B flat_long()[J(J)Ljava/lang/StringBuffer;$getLongDoubleRectangularArrayExample()[[J$getLongTripleRectangularArrayExample()[[[J flat_short()[S%getShortDoubleRectangularArrayExample()[[S%getShortTripleRectangularArrayExample()[[[S flat_double()[D(D)Ljava/lang/StringBuffer;&getDoubleDoubleRectangularArrayExample()[[D&getDoubleTripleRectangularArrayExample()[[[D flat_char()[C(C)Ljava/lang/StringBuffer;$getCharDoubleRectangularArrayExample()[[C$getCharTripleRectangularArrayExample()[[[C flat_float()[F(F)Ljava/lang/StringBuffer;%getFloatDoubleRectangularArrayExample()[[F%getFloatTripleRectangularArrayExample()[[[F flat_String()[Ljava/lang/String;&getStringDoubleRectangularArrayExample()[[Ljava/lang/String;&getStringTripleRectangularArrayExample()[[[Ljava/lang/String;(II)V flat_Object()[Ljava/lang/Object;xy*getDummyPointDoubleRectangularArrayExample()[[LDummyPoint;*getDummyPointTripleRectangularArrayExample()[[[LDummyPoint;!?@!ABC*D EFCX L+D"    GBC;                ! "# $% &' () *+ ,- ./ 01 23 45 67 89 :; <= >? @A BC DE Dn[  !&#.$1%9)A*D+L-T.W/_1g2j3r7z8}9;<=?@AEFGIJKMNOSTUWXY [\]a%b(c0e8f;gCiKjNkVo^paqisqttu|wxy}~  '/2:H IBC K< *OLFGHY*ILMYKLMNG+O YPLQRG+STU YVLWXG+YMNY[LNY]L>?,.2Y^Y_`abca,.bdabeL²f(+JZ\Dv(+,6>FMW_gs}H JBCgKLhGHY*ILMYiLMNG+O YjLQRG+STU YkLWXG+YMNY[LNYlL> ?,.2Y^Y_`abca,.bdabeLfJ|Z|\Dr%-5<FNVblt|H KBCmKLnGHY*ILMYoLMNG+O YpLQRG+STU YqLWXG+YMNY[LNYrL>?,.2Y^Y_`abca,.bdabeLfJ|Z|\Dr  %-5<FNVbl t"|%*&'(),-,/1H LBC K<=*T<MsGHY*IMNYtLMNG,O YuLQRG,SvU YwLxyG,zN:Y[L:Y]L<6C-3+Y^Y_`abca-3{eL<f+47JZ\D#:;< =><!A#B+D4G7E8FBHJJRKYLcNkPsQRTVY^Z[\]`abcae gH MBC|KL}GHY*ILMY~LMNG+O YLQRG+SvU YLxyG+zMNY[LNYL>6 C,3+Y^Y_`abca,3{eL>fJ|Z|\Dzmoprust%v-x5y<zF|N~Vblt|H NBCKLGHY*ILMYLMNG+O YLQRG+SvU YLxyG+zMNY[LNYL>6C,3+Y^Y_`abca,3{eL>fJ|Z|\Dz%-5<FNVblt|H OBCK<*TLGHY*ILMYLMNG+O YLQRG+SU YLG+MNY[LNYL>@,32Y^Y_`abca,3bdabeLf ),JZ\Dv ),-7?GNX`ht~H PBCKLGHY*ILMYLMNG+O YLQRG+SU YLG+MNY[LNYL> @,32Y^Y_`abca,3bdabeLfJ|Z|\Dr%-5<F N V b lt|!H QBCKLGHY*ILMYLMNG+O YLQRG+SU YLG+MNY[LNYL>@,32Y^Y_`abca,3bdabeLfJ|Z|\Dr')*,/-.%0-253<4F6N8V9b:l<t>|AFBCDEIJILNH RBC K<*PLGHY*ILMYLMNG+O YLQRG+SU YLG+MNY[LNYL>A,/2Y^Y_`abca,/dabeLf ),JZ\DvUVXY [)^,\-]7_?aGbNcXe`ghhti~kmpuqrstwxwz|H SBCKLGHY*ILMYLMNG+O YLQRG+SU YLG+MNY[LNYL> A,/2Y^Y_`abca,/dabeLfJ|Z|\Dr%-5<FNVblt|H TBCKLGHY*ILMYLMNG+O YLQRG+SU YLG+MNY[LNYL>A,/2Y^Y_`abca,/dabeLfJ|Z|\Dr%-5<FNVblt|H UBC K<*VLGHY*ILMYLMNG+O YLQRG+SU YLG+MNY[LNYL>B,52Y^Y_`abca,5bdabeLf ),JZ\Dv ),-7?GNX`ht~H VBCKLGHY*ILMYLMNG+O YLQRG+SU YLG+MNY[LNYL> B,52Y^Y_`abca,5bdabeLfJ|Z|\Dr %-5<FNVb l"t$|',()*+/0/24H WBCKLöGHY*ILMYķLMNG+O YŷLQRG+SU YƷLG+MNY[LNYǷL>B,52Y^Y_`abca,5bdabeLfJ|Z|\Dr:<=?B@A%C-E5F<GFINKVLbMlOtQ|TYUVWX\]\_aH XBCK<*cRLȶGHY*ILMYɷLMNG+O YʷLQRG+S˶U Y̷LͶζG+MNY[LNYзL>C,1c2Y^Y_`abca,1dabeLf"+.JZ\Dvijlm"o+r.p/q9sAuIvPwZyb{j|v}H YBCKLӶGHY*ILMYԷLMNG+O YշLQRG+S˶U YַLͶζG+MNY[LNY׷L> C,1c2Y^Y_`abca,1dabeLfJ|Z|\Dr%-5<FNVblt|H ZBCKLٶGHY*ILMYڷLMNG+O Y۷LQRG+S˶U YܷLͶζG+MNY[LNYݷL>C,1c2Y^Y_`abca,1dabeLfJ|Z|\Dr%-5<FNVblt|H [BCK<*UL޶GHY*ILMY߷LMNG+O YLQRG+SU YLG+MNY[LNYL>@,42Y^Y_`abca,4dabeLf ),JZ\Dv ),-7?GNX`ht~   H \BCKLGHY*ILMYLMNG+O YLQRG+SU YLG+MNY[LNYL> D,4c2Y^Y_`abca,4dabeLfJ|Z|\Dr!"$'%&%(-*5+<,F.N0V1b2l4t6|9>:;<=ABADFH ]BCKLGHY*ILMYLMNG+O YLQRG+SU YLG+MNY[LNYL>@,42Y^Y_`abca,4dabeLfJ|Z|\DrLNOQTRS%U-W5X<YF[N]V^b_latc|fkghijnonqsH ^BCK<*cQLGHY*ILMYLMNG+O YLQRG+SU YLG+MNY[LNYL>D,0c2Y^Y_`abca,0dabeLf#,/JZ\Dv{|~#,/0:BJQ[ckwH _BCKLGHY*ILMYLMNG+OYLQRG+SUYLG+MNY[LNYL> D,0c2Y^Y_`abca,0dabeLfJZ\Dr&.6=HPXdowH `BCKLGHY*ILMYLMNG+OYLQRG+SUYLG+MNY[LNY L>D,0c2Y^Y_`abca,0dabeLfJZ\Dr'/7>IQYepxH aBC* K< *^Y_ abeSL GHY*ILMY LMNG+OYLRG+SUYLG+MNY[LNYL>U,2^Y_ abeU2Y^Y_`abca,2adabeLf4=@JZ\Dv) + 4 =@ ALT\cnw!&"#$%()(!+)-H bBCKLGHY*ILMYLMNG+OYLQRG+SUYLG+MNY[LNYL> U,2^Y_ abeU2Y^Y_`abca,2adabeLfJZ\Dr3568;9:'</>7?>@IBQDYEfFqHzJMRNOPQUVUXZH cBCKLGHY*ILMYLMNG+OYLQRG+SUY LG+MNY[LNY!L>U,2^Y_ abeU2Y^Y_`abca,2adabeLfJZ\Dr`bcehfg'i/k7l>mIoQqYrfsquzwz{|}~H dBC&"K<*"Y#SL$GHY*ILMY%LMNG+OY&LRG+S'UY(L)*G++,,MNY.LNY/L6S,2N-0 -16Y^Y_`ab2a-0bdabeLf)25J-\Dz )256AIQXclt%H eBC 3KL4GHY*ILMY5LMNG+OY6LRG+S'UY7L)*G++,,MNY.LNY8L6 S,2N-0 -16Y^Y_`ab2a-0bdabeLfJ-\Dv'/7>IRZgr{ H fBC 9KL:GHY*ILMY;LMNG+OY<LRG+S'UY=L)*G++,,MNY.LNY>L6S,2N-0 -16Y^Y_`ab2a-0bdabeLfJ-\Dv'/7>IRZgr{    HghrJava/inst/java/RJavaTools_Test$DummyNonStaticClass.class0000644000176200001440000000060712256051770023166 0ustar liggesusers.  this$0LRJavaTools_Test; Synthetic(LRJavaTools_Test;)VCodeLineNumberTable SourceFileRJavaTools_Test.java  #RJavaTools_Test$DummyNonStaticClassDummyNonStaticClass InnerClassesjava/lang/Object()VRJavaTools_Test!  " **+    rJava/inst/java/RJavaArrayTools_Test.java0000644000176200001440000012401312256051770020106 0ustar liggesusers// :tabSize=2:indentSize=2:noTabs=false:folding=explicit:collapseFolds=1: public class RJavaArrayTools_Test { // {{{ main public static void main(String[] args){ System.out.println( "Test suite for RJavaArrayTools" ) ; try{ runtests() ; } catch( TestException e){ fails( e ) ; System.exit(1); } System.exit(0); } // }}} // {{{ runtests public static void runtests() throws TestException { System.out.println( "Test suite for RJavaArrayTools" ) ; System.out.println( "Testing RJavaArrayTools.isArray" ) ; isarray(); success() ; System.out.println( "Testing RJavaArrayTools.isRectangularArray" ) ; isrect(); success() ; System.out.println( "Testing RJavaArrayTools.getDimensionLength" ) ; getdimlength(); success() ; System.out.println( "Testing RJavaArrayTools.getDimensions" ) ; getdims(); success() ; System.out.println( "Testing RJavaArrayTools.getTrueLength" ) ; gettruelength(); success() ; System.out.println( "Testing RJavaArrayTools.getObjectTypeName" ) ; gettypename(); success() ; System.out.println( "Testing RJavaArrayTools.isPrimitiveTypeName" ) ; isprim(); success() ; System.out.println( "Testing RJavaTools.rep" ) ; rep(); success() ; } // }}} // {{{ fails private static void fails( TestException e ){ System.err.println( "\n" ) ; e.printStackTrace() ; System.err.println( "FAILED" ) ; } // }}} // {{{ success private static void success(){ System.out.println( "PASSED" ) ; } // }}} // {{{ isarray private static void isarray() throws TestException { // {{{ int System.out.print( " isArray( int )" ) ; if( RJavaArrayTools.isArray( 0 ) ){ throw new TestException( " isArray( int ) " ); } System.out.println( " false : ok" ) ; // }}} // {{{ boolean System.out.print( " isArray( boolean )" ) ; if( RJavaArrayTools.isArray( true ) ){ throw new TestException( " isArray( boolean ) " ); } System.out.println( " false : ok" ) ; // }}} // {{{ byte System.out.print( " isArray( byte )" ) ; if( RJavaArrayTools.isArray( (byte)0 ) ){ throw new TestException( " isArray( byte ) " ); } System.out.println( " false : ok" ) ; // }}} // {{{ long System.out.print( " isArray( long )" ) ; if( RJavaArrayTools.isArray( (long)0 ) ){ throw new TestException( " isArray( long ) " ); } System.out.println( " false : ok" ) ; // }}} // {{{ short System.out.print( " isArray( short )" ) ; if( RJavaArrayTools.isArray( (double)0 ) ){ throw new TestException( " isArray( short ) " ); } System.out.println( " false : ok" ) ; // }}} // {{{ double System.out.print( " isArray( double )" ) ; if( RJavaArrayTools.isArray( 0.0 ) ){ throw new TestException( " isArray( double ) " ); } System.out.println( " false : ok" ) ; // }}} // {{{ char System.out.print( " isArray( char )" ) ; if( RJavaArrayTools.isArray( 'a' ) ){ throw new TestException( " isArray( char ) " ); } System.out.println( " false : ok" ) ; // }}} // {{{ float System.out.print( " isArray( float )" ) ; if( RJavaArrayTools.isArray( 0.0f ) ){ throw new TestException( " isArray( float ) " ) ; } System.out.println( " false : ok" ) ; // }}} // {{{ String System.out.print( " isArray( String )" ) ; if( RJavaArrayTools.isArray( "dd" ) ){ throw new TestException( " isArray( String ) " ) ; } System.out.println( " false : ok" ) ; // }}} // {{{ int[] int[] x = new int[2] ; System.out.print( " isArray( int[] )" ) ; if( ! RJavaArrayTools.isArray( x ) ){ throw new TestException( " !isArray( int[] ) " ) ; } System.out.println( " true : ok" ) ; // }}} // {{{ Object o = new double[2] Object o = new double[2]; System.out.print( " isArray( double[] (but declared as 0bject) )" ) ; if( ! RJavaArrayTools.isArray( o ) ){ throw new TestException( " !isArray( Object o = new double[2]; ) " ) ; } System.out.println( " true : ok" ) ; // }}} // {{{ null System.out.print( " isArray( null )" ) ; if( RJavaArrayTools.isArray( null ) ){ throw new TestException( " isArray( null) " ) ; } System.out.println( " false : ok" ) ; // }}} } // }}} // {{{ getdimlength private static void getdimlength() throws TestException{ System.out.println( " >> actual arrays" ) ; // {{{ int[] o = new int[10] ; int[] o = new int[10] ; System.out.print( " int[] o = new int[10] ;" ) ; try{ if( RJavaArrayTools.getDimensionLength( o ) != 1 ){ throw new TestException( "getDimensionLength( int[10] ) != 1" ); } } catch( NotAnArrayException e){ throw new TestException( "not an array int[10]" ) ; } System.out.println( " 1 : ok " ); // }}} // {{{ int[] o = new int[0] ; o = new int[0] ; System.out.print( " int[] o = new int[0] ;" ) ; try{ if( RJavaArrayTools.getDimensionLength( o ) != 1 ){ throw new TestException( "getDimensionLength( int[0] ) != 1" ); } } catch( NotAnArrayException e){ throw new TestException( "not an array int[0]" ) ; } System.out.println( " 1 : ok " ); // }}} // {{{ Object[][] = new Object[10][10] ; Object[][] ob = new Object[10][10] ; System.out.print( " new Object[10][10]" ) ; try{ if( RJavaArrayTools.getDimensionLength( ob ) != 2 ){ throw new TestException( "getDimensionLength( new Object[10][10] ) != 2" ); } } catch( NotAnArrayException e){ throw new TestException( "not an array Object[10][10]" ) ; } System.out.println( " 2 : ok " ); // }}} // {{{ Object[][] = new Object[10][10][10] ; Object[][][] obj = new Object[10][10][10] ; System.out.print( " new Object[10][10][10]" ) ; try{ if( RJavaArrayTools.getDimensionLength( obj ) != 3 ){ throw new TestException( "getDimensionLength( new Object[10][10][3] ) != 3" ); } } catch( NotAnArrayException e){ throw new TestException( "not an array Object[10][10][3]" ) ; } System.out.println( " 3 : ok " ); // }}} // {{{ Object System.out.println( " >> Object" ) ; System.out.print( " new Double('10.2') " ) ; boolean ok = false; try{ RJavaArrayTools.getDimensionLength( new Double("10.3") ) ; } catch( NotAnArrayException e){ ok = true ; } if( !ok ){ throw new TestException( "getDimensionLength(Double) did not throw exception" ); } System.out.println( " -> NotAnArrayException : ok " ); // }}} // {{{ primitives System.out.println( " >> Testing primitive types" ) ; // {{{ int System.out.print( " getDimensionLength( int )" ) ; ok = false; try{ RJavaArrayTools.getDimensionLength( 0 ) ; } catch( NotAnArrayException e){ ok = true; } if( !ok ) throw new TestException( " getDimensionLength( int ) not throwing exception" ); System.out.println( " ok" ) ; // }}} // {{{ boolean System.out.print( " getDimensionLength( boolean )" ) ; ok = false; try{ RJavaArrayTools.getDimensionLength( true ) ; } catch( NotAnArrayException e){ ok = true; } if( !ok ) throw new TestException( " getDimensionLength( boolean ) not throwing exception" ); System.out.println( " : ok" ) ; // }}} // {{{ byte System.out.print( " getDimensionLength( byte )" ) ; ok = false; try{ RJavaArrayTools.getDimensionLength( (byte)0 ) ; } catch( NotAnArrayException e){ ok = true; } if( !ok ) throw new TestException( " getDimensionLength( byte ) not throwing exception" ); System.out.println( " : ok" ) ; // }}} // {{{ long System.out.print( " getDimensionLength( long )" ) ; ok = false; try{ RJavaArrayTools.getDimensionLength( (long)0 ); } catch( NotAnArrayException e){ ok = true; } if( !ok) throw new TestException( " getDimensionLength( long ) not throwing exception" ); System.out.println( " ok" ) ; // }}} // {{{ short System.out.print( " getDimensionLength( short )" ) ; ok = false; try{ RJavaArrayTools.getDimensionLength( (double)0 ) ; } catch( NotAnArrayException e ){ ok = true; } if( !ok ) throw new TestException( " getDimensionLength( short ) not throwing exception" ); System.out.println( " : ok" ) ; // }}} // {{{ double System.out.print( " getDimensionLength( double )" ) ; ok = false; try{ RJavaArrayTools.getDimensionLength( 0.0 ); } catch( NotAnArrayException e ){ ok = true; } if( !ok ) throw new TestException( " getDimensionLength( double ) not throwing exception" ); System.out.println( " : ok" ) ; // }}} // {{{ char System.out.print( " getDimensionLength( char )" ) ; ok = false; try{ RJavaArrayTools.getDimensionLength( 'a' ) ; } catch( NotAnArrayException e ){ ok = true; } if( !ok ) throw new TestException( " getDimensionLength( char ) not throwing exception " ); System.out.println( " : ok" ) ; // }}} // {{{ float System.out.print( " getDimensionLength( float )" ) ; ok = false; try{ RJavaArrayTools.getDimensionLength( 0.0f ) ; } catch( NotAnArrayException e ){ ok = true; } if( !ok ) throw new TestException( " getDimensionLength( float ) not throwing exception " ) ; System.out.println( " : ok" ) ; // }}} // }}} // {{{ null System.out.print( " getDimensionLength( null )" ) ; ok = false; try{ RJavaArrayTools.getDimensionLength( null ) ; } catch( NullPointerException e ){ ok = true; } catch( NotAnArrayException e ){ throw new TestException("getDimensionLength( null ) throwing wrong kind of exception") ; } if( !ok ) throw new TestException( " getDimensionLength( null ) not throwing exception " ) ; System.out.println( " : ok" ) ; // }}} } // }}} // {{{ getdims private static void getdims() throws TestException{ int[] res = null ; // {{{ actual arrays // {{{ int[] o = new int[10] ; int[] o = new int[10] ; System.out.print( " int[] o = new int[10] ;" ) ; try{ res = RJavaArrayTools.getDimensions( o ); if( res.length != 1 ){ throw new TestException( "getDimensions( int[10]).length != 1" ); } if( res[0] != 10 ){ throw new TestException( "getDimensions( int[10])[0] != 10" ); } } catch( NotAnArrayException e){ throw new TestException( "not an array int[10]" ) ; } System.out.println( " c( 10 ) : ok " ); // }}} // {{{ Object[][] = new Object[10][10] ; Object[][] ob = new Object[10][10] ; System.out.print( " new Object[10][10]" ) ; try{ res = RJavaArrayTools.getDimensions( ob ) ; if( res.length != 2 ){ throw new TestException( "getDimensions( Object[10][10] ).length != 2" ); } if( res[0] != 10 ){ throw new TestException( "getDimensions( Object[10][10] )[0] != 10" ); } if( res[1] != 10 ){ throw new TestException( "getDimensions( Object[10][10] )[1] != 10" ); } } catch( NotAnArrayException e){ throw new TestException( "not an array Object[10][10]" ) ; } System.out.println( " c(10,10) : ok " ); // }}} // {{{ Object[][] = new Object[10][10][10] ; Object[][][] obj = new Object[10][10][10] ; System.out.print( " new Object[10][10][10]" ) ; try{ res = RJavaArrayTools.getDimensions( obj ) ; if( res.length != 3 ){ throw new TestException( "getDimensions( Object[10][10][10] ).length != 3" ); } if( res[0] != 10 ){ throw new TestException( "getDimensions( Object[10][10][10] )[0] != 10" ); } if( res[1] != 10 ){ throw new TestException( "getDimensions( Object[10][10][10] )[1] != 10" ); } if( res[2] != 10 ){ throw new TestException( "getDimensions( Object[10][10][10] )[1] != 10" ); } } catch( NotAnArrayException e){ throw new TestException( "not an array Object[10][10][10]" ) ; } System.out.println( " c(10,10,10) : ok " ); // }}} // }}} // {{{ zeroes System.out.println( " >> zeroes " ) ; // {{{ int[] o = new int[0] ; o = new int[0] ; System.out.print( " int[] o = new int[0] ;" ) ; try{ res = RJavaArrayTools.getDimensions( o ) ; if( res.length != 1 ){ throw new TestException( "getDimensions( int[0]).length != 1" ); } if( res[0] != 0){ throw new TestException( "getDimensions( int[0])[0] != 0" ); } } catch( NotAnArrayException e){ throw new TestException( "not an array int[0]" ) ; } System.out.println( " c(0) : ok " ); // }}} // {{{ Object[][] = new Object[10][10][0] ; obj = new Object[10][10][0] ; System.out.print( " new Object[10][10][0]" ) ; try{ res = RJavaArrayTools.getDimensions( obj ) ; if( res.length != 3 ){ throw new TestException( "getDimensions( Object[10][10][0] ).length != 3" ); } if( res[0] != 10 ){ throw new TestException( "getDimensions( Object[10][10][0] )[0] != 10" ); } if( res[1] != 10 ){ throw new TestException( "getDimensions( Object[10][10][0] )[1] != 10" ); } if( res[2] != 0 ){ throw new TestException( "getDimensions( Object[10][10][0] )[1] != 0" ); } } catch( NotAnArrayException e){ throw new TestException( "not an array Object[10][10][0]" ) ; } System.out.println( " c(10,10,0) : ok " ); // }}} // {{{ Object[][] = new Object[10][0][10] ; obj = new Object[10][0][10] ; System.out.print( " new Object[10][0][10]" ) ; try{ res = RJavaArrayTools.getDimensions( obj ) ; if( res.length != 3 ){ throw new TestException( "getDimensions( Object[10][0][0] ).length != 3" ); } if( res[0] != 10 ){ throw new TestException( "getDimensions( Object[10][0][0] )[0] != 10" ); } if( res[1] != 0 ){ throw new TestException( "getDimensions( Object[10][0][0] )[1] != 0" ); } if( res[2] != 0 ){ throw new TestException( "getDimensions( Object[10][0][0] )[1] != 0" ); } } catch( NotAnArrayException e){ throw new TestException( "not an array Object[10][0][10]" ) ; } System.out.println( " c(10,0,0) : ok " ); // }}} // }}} // {{{ Object System.out.println( " >> Object" ) ; System.out.print( " new Double('10.2') " ) ; boolean ok = false; try{ res = RJavaArrayTools.getDimensions( new Double("10.3") ) ; } catch( NotAnArrayException e){ ok = true ; } if( !ok ){ throw new TestException( "getDimensions(Double) did not throw exception" ); } System.out.println( " -> NotAnArrayException : ok " ); // }}} // {{{ primitives System.out.println( " >> Testing primitive types" ) ; // {{{ int System.out.print( " getDimensions( int )" ) ; ok = false; try{ RJavaArrayTools.getDimensions( 0 ) ; } catch( NotAnArrayException e){ ok = true; } if( !ok ) throw new TestException( " getDimensions( int ) not throwing exception" ); System.out.println( " ok" ) ; // }}} // {{{ boolean System.out.print( " getDimensions( boolean )" ) ; ok = false; try{ RJavaArrayTools.getDimensions( true ) ; } catch( NotAnArrayException e){ ok = true; } if( !ok ) throw new TestException( " getDimensions( boolean ) not throwing exception" ); System.out.println( " : ok" ) ; // }}} // {{{ byte System.out.print( " getDimensions( byte )" ) ; ok = false; try{ RJavaArrayTools.getDimensions( (byte)0 ) ; } catch( NotAnArrayException e){ ok = true; } if( !ok ) throw new TestException( " getDimensions( byte ) not throwing exception" ); System.out.println( " : ok" ) ; // }}} // {{{ long System.out.print( " getDimensions( long )" ) ; ok = false; try{ RJavaArrayTools.getDimensions( (long)0 ); } catch( NotAnArrayException e){ ok = true; } if( !ok) throw new TestException( " getDimensions( long ) not throwing exception" ); System.out.println( " ok" ) ; // }}} // {{{ short System.out.print( " getDimensions( short )" ) ; ok = false; try{ RJavaArrayTools.getDimensions( (double)0 ) ; } catch( NotAnArrayException e ){ ok = true; } if( !ok ) throw new TestException( " getDimensions( short ) not throwing exception" ); System.out.println( " : ok" ) ; // }}} // {{{ double System.out.print( " getDimensions( double )" ) ; ok = false; try{ RJavaArrayTools.getDimensions( 0.0 ); } catch( NotAnArrayException e ){ ok = true; } if( !ok ) throw new TestException( " getDimensions( double ) not throwing exception" ); System.out.println( " : ok" ) ; // }}} // {{{ char System.out.print( " getDimensions( char )" ) ; ok = false; try{ RJavaArrayTools.getDimensions( 'a' ) ; } catch( NotAnArrayException e ){ ok = true; } if( !ok ) throw new TestException( " getDimensions( char ) not throwing exception " ); System.out.println( " : ok" ) ; // }}} // {{{ float System.out.print( " getDimensions( float )" ) ; ok = false; try{ RJavaArrayTools.getDimensions( 0.0f ) ; } catch( NotAnArrayException e ){ ok = true; } if( !ok ) throw new TestException( " getDimensions( float ) not throwing exception " ) ; System.out.println( " : ok" ) ; // }}} // }}} // {{{ null System.out.print( " getDimensions( null )" ) ; ok = false; try{ RJavaArrayTools.getDimensions( null ) ; } catch( NullPointerException e ){ ok = true; } catch( NotAnArrayException e ){ throw new TestException("getDimensions( null ) throwing wrong kind of exception") ; } if( !ok ) throw new TestException( " getDimensions( null ) not throwing exception " ) ; System.out.println( " : ok" ) ; // }}} } // }}} // {{{ gettruelength private static void gettruelength() throws TestException{ int res = 0 ; // {{{ actual arrays // {{{ int[] o = new int[10] ; int[] o = new int[10] ; System.out.print( " int[] o = new int[10] ;" ) ; try{ res = RJavaArrayTools.getTrueLength( o ); if( res != 10 ){ throw new TestException( "getTrueLength( int[10]) != 10" ); } } catch( NotAnArrayException e){ throw new TestException( "not an array int[10]" ) ; } System.out.println( " 10 : ok " ); // }}} // {{{ Object[][] = new Object[10][10] ; Object[][] ob = new Object[10][10] ; System.out.print( " new Object[10][10]" ) ; try{ res = RJavaArrayTools.getTrueLength( ob ) ; if( res != 100 ){ throw new TestException( "getTrueLength( Object[10][10] ) != 100" ); } } catch( NotAnArrayException e){ throw new TestException( "not an array Object[10][10]" ) ; } System.out.println( " 100 : ok " ); // }}} // {{{ Object[][] = new Object[10][10][10] ; Object[][][] obj = new Object[10][10][10] ; System.out.print( " new Object[10][10][10]" ) ; try{ res = RJavaArrayTools.getTrueLength( obj ) ; if( res != 1000 ){ throw new TestException( "getTrueLength( Object[10][10][10] ) != 1000" ); } } catch( NotAnArrayException e){ throw new TestException( "not an array Object[10][10][10]" ) ; } System.out.println( " 1000 : ok " ); // }}} // }}} // {{{ zeroes System.out.println( " >> zeroes " ) ; // {{{ int[] o = new int[0] ; o = new int[0] ; System.out.print( " int[] o = new int[0] ;" ) ; try{ res = RJavaArrayTools.getTrueLength( o ) ; if( res != 0 ){ throw new TestException( "getTrueLength( int[0]) != 0" ); } } catch( NotAnArrayException e){ throw new TestException( "not an array int[0]" ) ; } System.out.println( " c(0) : ok " ); // }}} // {{{ Object[][] = new Object[10][10][0] ; obj = new Object[10][10][0] ; System.out.print( " new Object[10][10][0]" ) ; try{ res = RJavaArrayTools.getTrueLength( obj ) ; if( res != 0 ){ throw new TestException( "getTrueLength( Object[10][10][0] ) != 0" ); } } catch( NotAnArrayException e){ throw new TestException( "not an array Object[10][10][0]" ) ; } System.out.println( " 0 : ok " ); // }}} // {{{ Object[][] = new Object[10][0][10] ; obj = new Object[10][0][10] ; System.out.print( " new Object[10][0][10]" ) ; try{ res = RJavaArrayTools.getTrueLength( obj ) ; if( res != 0){ throw new TestException( "getTrueLength( Object[10][0][0] ) != 0" ); } } catch( NotAnArrayException e){ throw new TestException( "not an array Object[10][0][10]" ) ; } System.out.println( " 0 : ok " ); // }}} // }}} // {{{ Object System.out.println( " >> Object" ) ; System.out.print( " new Double('10.2') " ) ; boolean ok = false; try{ res = RJavaArrayTools.getTrueLength( new Double("10.3") ) ; } catch( NotAnArrayException e){ ok = true ; } if( !ok ){ throw new TestException( "getTrueLength(Double) did not throw exception" ); } System.out.println( " -> NotAnArrayException : ok " ); // }}} // {{{ primitives System.out.println( " >> Testing primitive types" ) ; // {{{ int System.out.print( " getTrueLength( int )" ) ; ok = false; try{ RJavaArrayTools.getTrueLength( 0 ) ; } catch( NotAnArrayException e){ ok = true; } if( !ok ) throw new TestException( " getTrueLength( int ) not throwing exception" ); System.out.println( " ok" ) ; // }}} // {{{ boolean System.out.print( " getTrueLength( boolean )" ) ; ok = false; try{ RJavaArrayTools.getTrueLength( true ) ; } catch( NotAnArrayException e){ ok = true; } if( !ok ) throw new TestException( " getTrueLength( boolean ) not throwing exception" ); System.out.println( " : ok" ) ; // }}} // {{{ byte System.out.print( " getTrueLength( byte )" ) ; ok = false; try{ RJavaArrayTools.getTrueLength( (byte)0 ) ; } catch( NotAnArrayException e){ ok = true; } if( !ok ) throw new TestException( " getTrueLength( byte ) not throwing exception" ); System.out.println( " : ok" ) ; // }}} // {{{ long System.out.print( " getTrueLength( long )" ) ; ok = false; try{ RJavaArrayTools.getTrueLength( (long)0 ); } catch( NotAnArrayException e){ ok = true; } if( !ok) throw new TestException( " getTrueLength( long ) not throwing exception" ); System.out.println( " ok" ) ; // }}} // {{{ short System.out.print( " getTrueLength( short )" ) ; ok = false; try{ RJavaArrayTools.getTrueLength( (double)0 ) ; } catch( NotAnArrayException e ){ ok = true; } if( !ok ) throw new TestException( " getTrueLength( short ) not throwing exception" ); System.out.println( " : ok" ) ; // }}} // {{{ double System.out.print( " getTrueLength( double )" ) ; ok = false; try{ RJavaArrayTools.getTrueLength( 0.0 ); } catch( NotAnArrayException e ){ ok = true; } if( !ok ) throw new TestException( " getTrueLength( double ) not throwing exception" ); System.out.println( " : ok" ) ; // }}} // {{{ char System.out.print( " getTrueLength( char )" ) ; ok = false; try{ RJavaArrayTools.getTrueLength( 'a' ) ; } catch( NotAnArrayException e ){ ok = true; } if( !ok ) throw new TestException( " getTrueLength( char ) not throwing exception " ); System.out.println( " : ok" ) ; // }}} // {{{ float System.out.print( " getTrueLength( float )" ) ; ok = false; try{ RJavaArrayTools.getTrueLength( 0.0f ) ; } catch( NotAnArrayException e ){ ok = true; } if( !ok ) throw new TestException( " getTrueLength( float ) not throwing exception " ) ; System.out.println( " : ok" ) ; // }}} // }}} // {{{ null System.out.print( " getTrueLength( null )" ) ; ok = false; try{ RJavaArrayTools.getTrueLength( null ) ; } catch( NullPointerException e ){ ok = true; } catch( NotAnArrayException e ){ throw new TestException("getTrueLength( null ) throwing wrong kind of exception") ; } if( !ok ) throw new TestException( " getTrueLength( null ) not throwing exception " ) ; System.out.println( " : ok" ) ; // }}} } // }}} // {{{ isRectangular private static void isrect() throws TestException { // {{{ int System.out.print( " isRectangularArray( int )" ) ; if( RJavaArrayTools.isRectangularArray( 0 ) ){ throw new TestException( " isRectangularArray( int ) " ); } System.out.println( " false : ok" ) ; // }}} // {{{ boolean System.out.print( " isRectangularArray( boolean )" ) ; if( RJavaArrayTools.isRectangularArray( true ) ){ throw new TestException( " isRectangularArray( boolean ) " ); } System.out.println( " false : ok" ) ; // }}} // {{{ byte System.out.print( " isRectangularArray( byte )" ) ; if( RJavaArrayTools.isRectangularArray( (byte)0 ) ){ throw new TestException( " isRectangularArray( byte ) " ); } System.out.println( " false : ok" ) ; // }}} // {{{ long System.out.print( " isRectangularArray( long )" ) ; if( RJavaArrayTools.isRectangularArray( (long)0 ) ){ throw new TestException( " isRectangularArray( long ) " ); } System.out.println( " false : ok" ) ; // }}} // {{{ short System.out.print( " isRectangularArray( short )" ) ; if( RJavaArrayTools.isRectangularArray( (double)0 ) ){ throw new TestException( " isRectangularArray( short ) " ); } System.out.println( " false : ok" ) ; // }}} // {{{ double System.out.print( " isRectangularArray( double )" ) ; if( RJavaArrayTools.isRectangularArray( 0.0 ) ){ throw new TestException( " isRectangularArray( double ) " ); } System.out.println( " false : ok" ) ; // }}} // {{{ char System.out.print( " isRectangularArray( char )" ) ; if( RJavaArrayTools.isRectangularArray( 'a' ) ){ throw new TestException( " isRectangularArray( char ) " ); } System.out.println( " false : ok" ) ; // }}} // {{{ float System.out.print( " isRectangularArray( float )" ) ; if( RJavaArrayTools.isRectangularArray( 0.0f ) ){ throw new TestException( " isRectangularArray( float ) " ) ; } System.out.println( " false : ok" ) ; // }}} // {{{ String System.out.print( " isRectangularArray( String )" ) ; if( RJavaArrayTools.isRectangularArray( "dd" ) ){ throw new TestException( " isRectangularArray( String ) " ) ; } System.out.println( " false : ok" ) ; // }}} // {{{ int[] int[] x = new int[2] ; System.out.print( " isRectangularArray( int[] )" ) ; if( ! RJavaArrayTools.isRectangularArray( x ) ){ throw new TestException( " !isRectangularArray( int[] ) " ) ; } System.out.println( " true : ok" ) ; // }}} // {{{ Object o = new double[2] Object o = new double[2]; System.out.print( " isRectangularArray( double[] (but declared as 0bject) )" ) ; if( ! RJavaArrayTools.isRectangularArray( o ) ){ throw new TestException( " !isRectangularArray( Object o = new double[2]; ) " ) ; } System.out.println( " true : ok" ) ; // }}} // {{{ null System.out.print( " isRectangularArray( null )" ) ; if( RJavaArrayTools.isRectangularArray( null ) ){ throw new TestException( " isRectangularArray( null) " ) ; } System.out.println( " false : ok" ) ; // }}} // {{{ 2d rectangular int[][] x2d = new int[3][4]; System.out.print( " isRectangularArray( new int[3][4] )" ) ; if( ! RJavaArrayTools.isRectangularArray( x2d ) ){ throw new TestException( " !isRectangularArray( new int[3][4] ) " ) ; } System.out.println( " true : ok" ) ; // }}} // {{{ 2d not rectangular int[][] x2d_not = new int[2][] ; x2d_not[0] = new int[2] ; x2d_not[1] = new int[3] ; System.out.print( " isRectangularArray( new int[2][2,4] )" ) ; if( RJavaArrayTools.isRectangularArray( x2d_not ) ){ throw new TestException( " !isRectangularArray( new int[2][2,4] ) " ) ; } System.out.println( " false : ok" ) ; // }}} // {{{ 3d not rectangular int[][][] x3d_not = new int[1][][] ; x3d_not[0] = new int[2][]; x3d_not[0][0] = new int[1] ; x3d_not[0][1] = new int[2] ; System.out.print( " isRectangularArray( new int[2][2][10,25] )" ) ; if( RJavaArrayTools.isRectangularArray( x3d_not ) ){ throw new TestException( " !isRectangularArray( new int[2][2][10,25] ) " ) ; } System.out.println( " false : ok" ) ; // }}} } // }}} // {{{ getObjectTypeName private static void gettypename() throws TestException { String res ; // {{{ actual arrays // {{{ int[] o = new int[10] ; System.out.print( " int[] o = new int[10] ;" ) ; try{ res = RJavaArrayTools.getObjectTypeName( new int[1] ); if( !res.equals("I") ){ throw new TestException( "getObjectTypeName(int[]) != 'I' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array int[10]" ) ; } System.out.println( " I : ok " ); // }}} // {{{ boolean[] ; System.out.print( " boolean[]" ) ; try{ res = RJavaArrayTools.getObjectTypeName( new boolean[1] ); if( !res.equals("Z") ){ throw new TestException( "getObjectTypeName(boolean[]) != 'Z' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array boolean[10]" ) ; } System.out.println( " Z : ok " ); // }}} // {{{ byte[] ; System.out.print( " byte[]" ) ; try{ res = RJavaArrayTools.getObjectTypeName( new byte[1] ); if( !res.equals("B") ){ throw new TestException( "getObjectTypeName(byte[]) != 'B' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array byte[10]" ) ; } System.out.println( " B : ok " ); // }}} // {{{ long[] ; System.out.print( " long[]" ) ; try{ res = RJavaArrayTools.getObjectTypeName( new long[1] ); if( !res.equals("J") ){ throw new TestException( "getObjectTypeName(long[]) != 'J' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array long[10]" ) ; } System.out.println( " J : ok " ); // }}} // {{{ short[] ; System.out.print( " short[]" ) ; try{ res = RJavaArrayTools.getObjectTypeName( new short[1] ); if( !res.equals("S") ){ throw new TestException( "getObjectTypeName(short[]) != 'S' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array short[10]" ) ; } System.out.println( " S : ok " ); // }}} // {{{ double[] ; System.out.print( " double[]" ) ; try{ res = RJavaArrayTools.getObjectTypeName( new double[1] ); if( !res.equals("D") ){ throw new TestException( "getObjectTypeName(double[]) != 'D' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array double[10]" ) ; } System.out.println( " D : ok " ); // }}} // {{{ char[] ; System.out.print( " char[]" ) ; try{ res = RJavaArrayTools.getObjectTypeName( new char[1] ); if( !res.equals("C") ){ throw new TestException( "getObjectTypeName(char[]) != 'C' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array char[10]" ) ; } System.out.println( " C : ok " ); // }}} // {{{ float[] ; System.out.print( " float[]" ) ; try{ res = RJavaArrayTools.getObjectTypeName( new float[1] ); if( !res.equals("F") ){ throw new TestException( "getObjectTypeName(float[]) != 'F' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array float[10]" ) ; } System.out.println( " F : ok " ); // }}} System.out.println(" >> multi dim primitive arrays" ) ; // {{{ int[] o = new int[10] ; System.out.print( " int[][] ;" ) ; try{ res = RJavaArrayTools.getObjectTypeName( new int[1][1] ); if( !res.equals("I") ){ throw new TestException( "getObjectTypeName(int[]) != 'I' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array int[10]" ) ; } System.out.println( " I : ok " ); // }}} // {{{ boolean[] ; System.out.print( " boolean[][]" ) ; try{ res = RJavaArrayTools.getObjectTypeName( new boolean[1][1] ); if( !res.equals("Z") ){ throw new TestException( "getObjectTypeName(boolean[]) != 'Z' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array boolean[10]" ) ; } System.out.println( " Z : ok " ); // }}} // {{{ byte[] ; System.out.print( " byte[][]" ) ; try{ res = RJavaArrayTools.getObjectTypeName( new byte[1][1] ); if( !res.equals("B") ){ throw new TestException( "getObjectTypeName(byte[]) != 'B' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array byte[10]" ) ; } System.out.println( " B : ok " ); // }}} // {{{ long[] ; System.out.print( " long[][]" ) ; try{ res = RJavaArrayTools.getObjectTypeName( new long[1][1] ); if( !res.equals("J") ){ throw new TestException( "getObjectTypeName(long[]) != 'J' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array long[10]" ) ; } System.out.println( " J : ok " ); // }}} // {{{ short[] ; System.out.print( " short[][]" ) ; try{ res = RJavaArrayTools.getObjectTypeName( new short[1][1] ); if( !res.equals("S") ){ throw new TestException( "getObjectTypeName(short[]) != 'S' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array short[10]" ) ; } System.out.println( " S : ok " ); // }}} // {{{ double[] ; System.out.print( " double[][]" ) ; try{ res = RJavaArrayTools.getObjectTypeName( new double[1][1] ); if( !res.equals("D") ){ throw new TestException( "getObjectTypeName(double[]) != 'D' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array double[10]" ) ; } System.out.println( " D : ok " ); // }}} // {{{ char[] ; System.out.print( " char[][]" ) ; try{ res = RJavaArrayTools.getObjectTypeName( new char[1][1] ); if( !res.equals("C") ){ throw new TestException( "getObjectTypeName(char[]) != 'C' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array char[10]" ) ; } System.out.println( " C : ok " ); // }}} // {{{ float[] ; System.out.print( " float[][]" ) ; try{ res = RJavaArrayTools.getObjectTypeName( new float[1][1] ); if( !res.equals("F") ){ throw new TestException( "getObjectTypeName(float[]) != 'F' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array float[10]" ) ; } System.out.println( " F : ok " ); // }}} // {{{ Object[][] = new Object[10][10] ; Object[][] ob = new Object[10][10] ; System.out.print( " new Object[10][10]" ) ; try{ res = RJavaArrayTools.getObjectTypeName( ob ) ; if( !res.equals("java.lang.Object") ){ throw new TestException( "getObjectTypeName(Object[][]) != 'java.lang.Object' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array Object[10][10]" ) ; } System.out.println( " : ok " ); // }}} // {{{ Object[][] = new Object[10][10][10] ; Object[][][] obj = new Object[10][10][10] ; System.out.print( " new Object[10][10][10]" ) ; try{ res = RJavaArrayTools.getObjectTypeName( obj ) ; if( !res.equals("java.lang.Object") ){ throw new TestException( "getObjectTypeName( Object[10][10][10] ) != 'java.lang.Object' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array Object[10][10][10]" ) ; } System.out.println( " 1000 : ok " ); // }}} // }}} // {{{ zeroes System.out.println( " >> zeroes " ) ; // {{{ int[] o = new int[0] ; int[] o = new int[0] ; System.out.print( " int[] o = new int[0] ;" ) ; try{ res = RJavaArrayTools.getObjectTypeName( o ) ; if( !res.equals("I") ){ throw new TestException( "getObjectTypeName(int[0]) != 'I' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array int[0]" ) ; } System.out.println( " : ok " ); // }}} // {{{ Object[][] = new Object[10][10][0] ; obj = new Object[10][10][0] ; System.out.print( " new Object[10][10][0]" ) ; try{ res = RJavaArrayTools.getObjectTypeName( obj ) ; if( !res.equals("java.lang.Object") ){ throw new TestException( "getObjectTypeName( Object[10][10][0] ) != 'java.lang.Object' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array Object[10][10][0]" ) ; } System.out.println( " : ok " ); // }}} // {{{ Object[][] = new Object[10][0][10] ; obj = new Object[10][0][10] ; System.out.print( " new Object[10][0][10]" ) ; try{ res = RJavaArrayTools.getObjectTypeName( obj ) ; if( !res.equals("java.lang.Object") ){ throw new TestException( "getObjectTypeName( Object[10][0][0] ) != 'java.lang.Object' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array Object[10][0][10]" ) ; } System.out.println( " 0 : ok " ); // }}} // }}} // {{{ Object System.out.println( " >> Object" ) ; System.out.print( " new Double('10.2') " ) ; boolean ok = false; try{ res = RJavaArrayTools.getObjectTypeName( new Double("10.3") ) ; } catch( NotAnArrayException e){ ok = true ; } if( !ok ){ throw new TestException( "getObjectTypeName(Double) did not throw exception" ); } System.out.println( " -> NotAnArrayException : ok " ); // }}} // {{{ primitives System.out.println( " >> Testing primitive types" ) ; // {{{ int System.out.print( " getObjectTypeName( int )" ) ; ok = false; try{ RJavaArrayTools.getObjectTypeName( 0 ) ; } catch( NotAnArrayException e){ ok = true; } if( !ok ) throw new TestException( " getObjectTypeName( int ) not throwing exception" ); System.out.println( " ok" ) ; // }}} // {{{ boolean System.out.print( " getObjectTypeName( boolean )" ) ; ok = false; try{ RJavaArrayTools.getObjectTypeName( true ) ; } catch( NotAnArrayException e){ ok = true; } if( !ok ) throw new TestException( " getObjectTypeName( boolean ) not throwing exception" ); System.out.println( " : ok" ) ; // }}} // {{{ byte System.out.print( " getObjectTypeName( byte )" ) ; ok = false; try{ RJavaArrayTools.getObjectTypeName( (byte)0 ) ; } catch( NotAnArrayException e){ ok = true; } if( !ok ) throw new TestException( " getObjectTypeName( byte ) not throwing exception" ); System.out.println( " : ok" ) ; // }}} // {{{ long System.out.print( " getObjectTypeName( long )" ) ; ok = false; try{ RJavaArrayTools.getObjectTypeName( (long)0 ); } catch( NotAnArrayException e){ ok = true; } if( !ok) throw new TestException( " getObjectTypeName( long ) not throwing exception" ); System.out.println( " ok" ) ; // }}} // {{{ short System.out.print( " getObjectTypeName( short )" ) ; ok = false; try{ RJavaArrayTools.getObjectTypeName( (double)0 ) ; } catch( NotAnArrayException e ){ ok = true; } if( !ok ) throw new TestException( " getObjectTypeName( short ) not throwing exception" ); System.out.println( " : ok" ) ; // }}} // {{{ double System.out.print( " getObjectTypeName( double )" ) ; ok = false; try{ RJavaArrayTools.getObjectTypeName( 0.0 ); } catch( NotAnArrayException e ){ ok = true; } if( !ok ) throw new TestException( " getObjectTypeName( double ) not throwing exception" ); System.out.println( " : ok" ) ; // }}} // {{{ char System.out.print( " getObjectTypeName( char )" ) ; ok = false; try{ RJavaArrayTools.getObjectTypeName( 'a' ) ; } catch( NotAnArrayException e ){ ok = true; } if( !ok ) throw new TestException( " getObjectTypeName( char ) not throwing exception " ); System.out.println( " : ok" ) ; // }}} // {{{ float System.out.print( " getObjectTypeName( float )" ) ; ok = false; try{ RJavaArrayTools.getObjectTypeName( 0.0f ) ; } catch( NotAnArrayException e ){ ok = true; } if( !ok ) throw new TestException( " getObjectTypeName( float ) not throwing exception " ) ; System.out.println( " : ok" ) ; // }}} // }}} // {{{ null System.out.print( " getObjectTypeName( null )" ) ; ok = false; try{ RJavaArrayTools.getObjectTypeName( null ) ; } catch( NullPointerException e ){ ok = true; } catch( NotAnArrayException e ){ throw new TestException("getObjectTypeName( null ) throwing wrong kind of exception") ; } if( !ok ) throw new TestException( " getObjectTypeName( null ) not throwing exception " ) ; System.out.println( " : ok" ) ; // }}} } // }}} // {{{ isPrimitiveTypeName private static void isprim() throws TestException{ System.out.print( " isPrimitiveTypeName( 'I' ) " ) ; if( !RJavaArrayTools.isPrimitiveTypeName("I") ) throw new TestException("I not primitive") ; System.out.println( " true : ok " ); System.out.print( " isPrimitiveTypeName( 'Z' ) " ) ; if( !RJavaArrayTools.isPrimitiveTypeName("Z") ) throw new TestException("Z not primitive") ; System.out.println( " true : ok " ); System.out.print( " isPrimitiveTypeName( 'B' ) " ) ; if( !RJavaArrayTools.isPrimitiveTypeName("B") ) throw new TestException("B not primitive") ; System.out.println( " true : ok " ); System.out.print( " isPrimitiveTypeName( 'J' ) " ) ; if( !RJavaArrayTools.isPrimitiveTypeName("J") ) throw new TestException("J not primitive") ; System.out.println( " true : ok " ); System.out.print( " isPrimitiveTypeName( 'S' ) " ) ; if( !RJavaArrayTools.isPrimitiveTypeName("S") ) throw new TestException("S not primitive") ; System.out.println( " true : ok " ); System.out.print( " isPrimitiveTypeName( 'D' ) " ) ; if( !RJavaArrayTools.isPrimitiveTypeName("D") ) throw new TestException("D not primitive") ; System.out.println( " true : ok " ); System.out.print( " isPrimitiveTypeName( 'C' ) " ) ; if( !RJavaArrayTools.isPrimitiveTypeName("C") ) throw new TestException("C not primitive") ; System.out.println( " true : ok " ); System.out.print( " isPrimitiveTypeName( 'F' ) " ) ; if( !RJavaArrayTools.isPrimitiveTypeName("F") ) throw new TestException("F not primitive") ; System.out.println( " true : ok " ); System.out.print( " isPrimitiveTypeName( 'java.lang.Object' ) " ) ; if( RJavaArrayTools.isPrimitiveTypeName("java.lang.Object") ) throw new TestException("Object primitive") ; System.out.println( " false : ok " ); } // }}} // {{{ rep private static void rep() throws TestException{ DummyPoint p = new DummyPoint(10, 10) ; DummyPoint[] res = null; System.out.print( " rep( DummyPoint, 10)" ); try{ res = (DummyPoint[])RJavaArrayTools.rep( p, 10 ); } catch( Throwable e){ throw new TestException( "rep(DummyPoint, 10) failed" ) ; } if( res.length != 10 ){ throw new TestException( "rep(DummyPoint, 10).length != 10" ) ; } if( res[5].getX() != 10.0 ){ throw new TestException( "rep(DummyPoint, 10)[5].getX() != 10" ) ; } System.out.println( ": ok " ); } /// }}} } rJava/inst/java/RJavaArrayTools$ArrayDimensionMismatchException.class0000644000176200001440000000121512256051770025547 0ustar liggesusers.(     (II)VCodeLineNumberTable SourceFileRJavaArrayTools.javajava/lang/StringBuffer dimension of indexer ( !" !#) too large for array (depth =) $% &'/RJavaArrayTools$ArrayDimensionMismatchExceptionArrayDimensionMismatchException InnerClassesjava/lang/Exception()Vappend,(Ljava/lang/String;)Ljava/lang/StringBuffer;(I)Ljava/lang/StringBuffer;toString()Ljava/lang/String;(Ljava/lang/String;)VRJavaArrayTools!  B&*Y  *%+   rJava/inst/java/PrimitiveArrayException.class0000644000176200001440000000074212256051770021100 0ustar liggesusers.    (Ljava/lang/String;)VCodeLineNumberTable SourceFilePrimitiveArrayException.javajava/lang/StringBuffer :cannot convert to single dimension array of primitive type   PrimitiveArrayExceptionjava/lang/Exception()Vappend,(Ljava/lang/String;)Ljava/lang/StringBuffer;toString()Ljava/lang/String;!  4*Y+  rJava/inst/java/ArrayDimensionException.java0000644000176200001440000000020412256051770020662 0ustar liggesuserspublic class ArrayDimensionException extends Exception{ public ArrayDimensionException(String message){ super( message ) ; } } rJava/inst/java/NotComparableException.class0000644000176200001440000000165412256051770020662 0ustar liggesusers.4     !" # $ %&'()'(Ljava/lang/Object;Ljava/lang/Object;)VCodeLineNumberTable(Ljava/lang/Object;)V(Ljava/lang/Class;)V(Ljava/lang/String;)V SourceFileNotComparableException.javajava/lang/StringBuffer *objects of class +,- ./0 12 and  are not comparable 32  class ( does not implement java.util.ComparableNotComparableExceptionjava/lang/Exception()Vappend,(Ljava/lang/String;)Ljava/lang/StringBuffer;java/lang/ObjectgetClass()Ljava/lang/Class;java/lang/ClassgetName()Ljava/lang/String;toString!N2*Y+,   1 ( *+   % *+  9*Y +   rJava/inst/java/NotComparableException.java0000644000176200001440000000132512256051770020471 0ustar liggesusers/** * Exception generated when two objects cannot be compared * * Such cases happen when an object does not implement the Comparable * interface or when the comparison produces a ClassCastException */ public class NotComparableException extends Exception{ public NotComparableException(Object a, Object b){ super( "objects of class " + a.getClass().getName() + " and " + b.getClass().getName() + " are not comparable" ) ; } public NotComparableException( Object o){ this( o.getClass().getName() ) ; } public NotComparableException( Class cl){ this( cl.getName() ) ; } public NotComparableException( String type ){ super( "class " + type + " does not implement java.util.Comparable" ) ; } } rJava/inst/java/RJavaArrayTools.class0000644000176200001440000003705112256051770017300 0ustar liggesusers.- 6:;< = > ?@ ? A BCD AE FA GAH IA AJ KAL MA N 6OP Q 6RST UVW UXY Z[\]^_`ab -? -c -d e -f g Bh Bij 6k l Um Un Uo pq =r =stu @> 6v wx wy z w{ w| w} w~ w w w w          X w w w w w w w w w           m? o m m w m   6 yQ      m     6  6 R  6            ArrayDimensionMismatchException InnerClassesprimitiveClassesLjava/util/Map; NA_INTEGERI ConstantValueNA_REALDNA_bitsJclass$java$lang$ComparableLjava/lang/Class; Synthetic()VCodeLineNumberTableinitPrimitiveClasses()Ljava/util/Map;getObjectTypeName&(Ljava/lang/Object;)Ljava/lang/String; Exceptions(I)I(Z)I(B)I(J)I(S)I(D)I(C)I(F)ImakeArraySignature'(Ljava/lang/String;I)Ljava/lang/String;getClassForSignature<(Ljava/lang/String;Ljava/lang/ClassLoader;)Ljava/lang/Class;isSingleDimensionArray(Ljava/lang/Object;)ZisPrimitiveTypeName(Ljava/lang/String;)ZisRectangularArray Deprecated(I)Z(Z)Z(B)Z(J)Z(S)Z(D)Z(C)Z(F)ZgetDimensionLength(Ljava/lang/Object;)I getDimensions(Ljava/lang/Object;)[I(I)[I(Z)[I(B)[I(J)[I(S)[I(D)[I(C)[I(F)[I getTrueLengthisArrayget((Ljava/lang/Object;[I)Ljava/lang/Object;getInt(Ljava/lang/Object;[I)I getBoolean(Ljava/lang/Object;[I)ZgetByte(Ljava/lang/Object;[I)BgetLong(Ljava/lang/Object;[I)JgetShort(Ljava/lang/Object;[I)S getDouble(Ljava/lang/Object;[I)DgetChar(Ljava/lang/Object;[I)CgetFloat(Ljava/lang/Object;[I)F'(Ljava/lang/Object;I)Ljava/lang/Object;(Ljava/lang/Object;I)I(Ljava/lang/Object;I)Z(Ljava/lang/Object;I)B(Ljava/lang/Object;I)J(Ljava/lang/Object;I)S(Ljava/lang/Object;I)D(Ljava/lang/Object;I)C(Ljava/lang/Object;I)FcheckDimensions(Ljava/lang/Object;[I)Vset)(Ljava/lang/Object;[ILjava/lang/Object;)V(Ljava/lang/Object;[II)V(Ljava/lang/Object;[IZ)V(Ljava/lang/Object;[IB)V(Ljava/lang/Object;[IJ)V(Ljava/lang/Object;[IS)V(Ljava/lang/Object;[ID)V(Ljava/lang/Object;[IC)V(Ljava/lang/Object;[IF)V((Ljava/lang/Object;ILjava/lang/Object;)V(Ljava/lang/Object;II)V(Ljava/lang/Object;IZ)V(Ljava/lang/Object;IB)V(Ljava/lang/Object;IJ)V(Ljava/lang/Object;IS)V(Ljava/lang/Object;ID)V(Ljava/lang/Object;IC)V(Ljava/lang/Object;IF)VgetArrayunique(([Ljava/lang/Object;)[Ljava/lang/Object; duplicated([Ljava/lang/Object;)[Z anyDuplicated([Ljava/lang/Object;)Isort)([Ljava/lang/Object;Z)[Ljava/lang/Object;revcopygetIterableContent)(Ljava/lang/Iterable;)[Ljava/lang/Object;rep((Ljava/lang/Object;I)[Ljava/lang/Object;getCloneMethod-(Ljava/lang/Class;)Ljava/lang/reflect/Method; cloneObject&(Ljava/lang/Object;)Ljava/lang/Object; unboxDoubles([Ljava/lang/Double;)[D unboxIntegers([Ljava/lang/Integer;)[I unboxBooleans([Ljava/lang/Boolean;)[IisNA boxDoubles([D)[Ljava/lang/Double; boxIntegers([I)[Ljava/lang/Integer; boxBooleans([I)[Ljava/lang/Boolean;class$%(Ljava/lang/String;)Ljava/lang/Class; SourceFileRJavaArrayTools.java 6 java/lang/ClassNotFoundExceptionjava/lang/NoClassDefFoundError   java/util/HashMap  ZBSCF  NotAnArrayException  \[+L? ; primitive type : int primitive type : boolean primitive type : byte primitive type : long primitive type : short primitive type : double primitive type : char primitive type : float java/lang/StringBuffer     'java/lang/Class      ArrayWrapper  java/lang/NullPointerException array is null    /RJavaArrayTools$ArrayDimensionMismatchException                    java/util/Vector   [Ljava/lang/Object;  java.lang.Comparable 56   NotComparableException       java/lang/Cloneable $%    ' java/lang/IllegalAccessException+java/lang/reflect/InvocationTargetException  clone  ! " #$ % & '( java/lang/Double . )java/lang/Integer *java/lang/Boolean  +,RJavaArrayToolsjava/lang/Objectjava/lang/ThrowableforName getMessage()Ljava/lang/String;(Ljava/lang/String;)VTYPE java/util/Mapput8(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;java/lang/Bytejava/lang/Longjava/lang/Shortjava/lang/Characterjava/lang/FloatgetClass()Ljava/lang/Class;()Z(Ljava/lang/Class;)VgetNamejava/lang/String replaceFirst8(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;replaceD(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String;append(C)Ljava/lang/StringBuffer;,(Ljava/lang/String;)Ljava/lang/StringBuffer;toString containsKey=(Ljava/lang/String;ZLjava/lang/ClassLoader;)Ljava/lang/Class; lastIndexOflength()Iequals(Ljava/lang/Object;)V isRectangulargetComponentTypejava/lang/reflect/Array getLength(II)VsetInt setBooleansetBytesetLongsetShort setDoublesetCharsetFloataddsize newInstance&(Ljava/lang/Class;I)Ljava/lang/Object;toArrayisAssignableFrom(Ljava/lang/Class;)Zjava/util/Arrays([Ljava/lang/Object;)Vjava/lang/Iterableiterator()Ljava/util/Iterator;java/util/IteratorhasNextnext()Ljava/lang/Object;()[Ljava/lang/Object;java/lang/reflect/Method isAccessible setAccessible(Z)Vinvoke9(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;castgetCause()Ljava/lang/Throwable;getDeclaredMethods()[Ljava/lang/reflect/Method;getParameterTypes()[Ljava/lang/Class; getSuperclass doubleValue()DintValue booleanValuedoubleToRawLongBits(D)J(D)V(I)VlongBitsToDouble(J)D! u!*  ( jYK* W* W* W* W* W* W* W* W** %&' (,)8*D+P,\-h. N**L+ Y++M, !" #9:<= " Y$%? " Y&%@ " Y'%A " Y(%B " Y)%C " Y*%D " Y+%E " Y,%F i5-Y.M>,[/W,*0W*1 ,;/W,2"LMNMP"Q)R0T @ 3*43*56*+7Z [] L(*8Y**L+[9cef&g d*:* ;* ;*;*;*;*;*;*;* m no p+q6rAsLtWubv m)*8<*<=Y*>?<M< $!$" !$%'         m9* @YAB*L+ Y+=++CL"#%,/7@ " Y$% " Y&% " Y'% " Y(% " Y)% " Y*% " Y+% " Y,% v* @YAB*L+ Y+*M*<> :6+),D6O,EM+CLON#%*/29?FINQW_gms@ " Y$% " Y&% " Y'% " Y(% " Y)% " Y*% " Y+% " Y,% Q* @YAB*L+ Y+*M>6+!,Dh>,EM+CL6 #%'*18>AGO@ " Y$% " Y&% " Y'% " Y(%  " Y)%  " Y*%  " Y+%  " Y,%  ***      ! " # $ '*+F++d.E7X '*+F++d.G;X '*+F++d.H>X '*+F++d.IAX '*+F++d.JDX '*+F++d.KGX '*+F++d.LJX '*+F++d.MMX '*+F++d.NPX $ * YOOUX $ * YOPXX $ * YOQ[X $ * YOR^X $ * YOSaX $ * YOTdX $ * YOUgX $ * YOVjX $ * YOWmX @+=*<> XYYqrs tvX ,*+F++d.,Z X ,*+F++d.[ X ,*+F++d.\ X ,*+F++d.] X ,*+F++d. ^ X ,*+F++d._ X ,*+F++d.(` X  ,*+F++d.a X  ,*+F++d.$b X  ) * YO,c  X  ) * YOd  X  ) * YOe  X ) * YOf  X ) * YO g  X ) * YOh  X ) * YO(i  X ) * YOj  X ) * YO$k  X c+*+l+=*N6d-+.EN-&   #)X  *<*M>* ,TmYnN6^,3N*2:6`69*2:,3&o,T-pW6,TDŽ*C-qrss:-tW^"+5;>JPafkruz d*<*M>* ,T>D,35*2:`6%*2:,3o,Tۄ,>!*/:@Q V\b u9*<=0*2N`6*2:-o*  (+17! |*CMuvwYuu,x yY,z*>*{:|l66)2:dd2SddS>01$2-40566;8?9B<I=S>Z?h@s=yCy Z.*<*CrssM>,dd*2S,OPQR&Q,T V**<*CrssM>,*2S,Z[\]"\(_  S+mYnL*}M,~+,pW+efgh&j !"p*rssM*,*N-6-6!*-*s:,Sߧ:-:-,+RU+R`Jvwx{ |&}+4FLRUW]`bhn# $%y=M*8*L>+#+2M,; ,,*K*  +-3; &'A*L+=+N*+*sN:+:+-%(%26  %(*/249?# ()[3*<*=N<-*2 *2R- 1 *+Z2*<*= N<-*2 *2O- 0 ,-b:*<*= N<%-*2*2O- 8 .1& /0]5*<*=N<*1-Y*1S- 3 12\4*<*=N<*.-Y*.S- 2 34d<*<*=N<&*.-Y*.S- :562*LY+17<3#89 X rJava/inst/java/DummyPoint.class0000644000176200001440000000075112256051770016357 0ustar liggesusers.    xIy()VCodeLineNumberTable(II)VgetX()Dmove SourceFileDummyPoint.java    DummyPointjava/lang/Objectjava/lang/Cloneable!    #*   3***   *  5*Y`*Y` rJava/inst/java/ObjectArrayException.class0000644000176200001440000000067712256051770020345 0ustar liggesusers.    (Ljava/lang/String;)VCodeLineNumberTable SourceFileObjectArrayException.javajava/lang/StringBuffer array is of primitive type :   ObjectArrayExceptionjava/lang/Exception()Vappend,(Ljava/lang/String;)Ljava/lang/StringBuffer;toString()Ljava/lang/String;!  4*Y+  rJava/inst/java/DummyPoint.java0000644000176200001440000000046512256051770016175 0ustar liggesusers public class DummyPoint implements Cloneable { public int x; public int y ; public DummyPoint(){ this( 0, 0 ) ; } public DummyPoint( int x, int y){ this.x = x ; this.y = y ; } public double getX(){ return (double)x ; } public void move(int x, int y){ this.x += x ; this.y += y ; } } rJava/inst/java/RectangularArrayExamples.java0000644000176200001440000001275012256051770021035 0ustar liggesusers// :tabSize=2:indentSize=2:noTabs=false:folding=explicit:collapseFolds=1: /** * Utility class that makes example rectangular java arrays of 2 and 3 dimensions * for all primitive types, String and Point (as an example of array of non primitive object) */ public class RectangularArrayExamples { // {{{ Example 2d rect arrays public static int[][] getIntDoubleRectangularArrayExample(){ int[][] x = new int[5][2]; int k= 0; for( int j=0; j<2; j++){ for( int i=0; i<5; i++, k++){ x[i][j] = k ; } } return x; } public static boolean[][] getBooleanDoubleRectangularArrayExample(){ boolean[][] x = new boolean[5][2]; boolean current = false; for( int j=0; j<2; j++){ for( int i=0; i<5; i++, current = !current){ x[i][j] = current ; } } return x ; } public static byte[][] getByteDoubleRectangularArrayExample(){ byte[][] x = new byte[5][2]; int k= 0; for( int j=0; j<2; j++){ for( int i=0; i<5; i++, k++){ x[i][j] = (byte)k ; } } return x; } public static long[][] getLongDoubleRectangularArrayExample(){ long[][] x = new long[5][2]; int k= 0; for( int j=0; j<2; j++){ for( int i=0; i<5; i++, k++){ x[i][j] = (long)k ; } } return x; } public static short[][] getShortDoubleRectangularArrayExample(){ short[][] x = new short[5][2]; int k= 0; for( int j=0; j<2; j++){ for( int i=0; i<5; i++, k++){ x[i][j] = (short)k ; } } return x; } public static double[][] getDoubleDoubleRectangularArrayExample(){ double[][] x = new double[5][2]; int k= 0; for( int j=0; j<2; j++){ for( int i=0; i<5; i++, k++){ x[i][j] = k + 0.0 ; } } return x; } public static char[][] getCharDoubleRectangularArrayExample(){ char[][] x = new char[5][2]; int k= 0; for( int j=0; j<2; j++){ for( int i=0; i<5; i++, k++){ x[i][j] = (char)k ; } } return x; } public static float[][] getFloatDoubleRectangularArrayExample(){ float[][] x = new float[5][2]; int k= 0; for( int j=0; j<2; j++){ for( int i=0; i<5; i++, k++){ x[i][j] = k + 0.0f ; } } return x; } public static String[][] getStringDoubleRectangularArrayExample(){ String[][] x = new String[5][2]; int k= 0; for( int j=0; j<2; j++){ for( int i=0; i<5; i++, k++){ x[i][j] = "" + k ; } } return x; } public static DummyPoint[][] getDummyPointDoubleRectangularArrayExample(){ DummyPoint[][] x = new DummyPoint[5][2]; int k= 0; for( int j=0; j<2; j++){ for( int i=0; i<5; i++, k++){ x[i][j] = new DummyPoint(k,k) ; } } return x; } // }}} // {{{ Example 3d rect arrays public static int[][][] getIntTripleRectangularArrayExample(){ int[][][] x = new int[5][3][2]; int current = 0 ; for( int k=0; k<2; k++){ for( int j=0; j<3; j++){ for( int i=0; i<5; i++, current++){ x[i][j][k] = current ; } } } return x; } public static boolean[][][] getBooleanTripleRectangularArrayExample(){ boolean[][][] x = new boolean[5][3][2]; boolean current = false ; for( int k=0; k<2; k++){ for( int j=0; j<3; j++){ for( int i=0; i<5; i++, current= !current){ x[i][j][k] = current ; } } } return x; } public static byte[][][] getByteTripleRectangularArrayExample(){ byte[][][] x = new byte[5][3][2]; int current = 0 ; for( int k=0; k<2; k++){ for( int j=0; j<3; j++){ for( int i=0; i<5; i++, current++){ x[i][j][k] = (byte)current ; } } } return x; } public static long[][][] getLongTripleRectangularArrayExample(){ long[][][] x = new long[5][3][2]; int current = 0 ; for( int k=0; k<2; k++){ for( int j=0; j<3; j++){ for( int i=0; i<5; i++, current++){ x[i][j][k] = (long)current ; } } } return x; } public static short[][][] getShortTripleRectangularArrayExample(){ short[][][] x = new short[5][3][2]; int current = 0 ; for( int k=0; k<2; k++){ for( int j=0; j<3; j++){ for( int i=0; i<5; i++, current++){ x[i][j][k] = (short)current ; } } } return x; } public static double[][][] getDoubleTripleRectangularArrayExample(){ double[][][] x = new double[5][3][2]; int current = 0 ; for( int k=0; k<2; k++){ for( int j=0; j<3; j++){ for( int i=0; i<5; i++, current++){ x[i][j][k] = 0.0 + current ; } } } return x; } public static char[][][] getCharTripleRectangularArrayExample(){ char[][][] x = new char[5][3][2]; int current = 0 ; for( int k=0; k<2; k++){ for( int j=0; j<3; j++){ for( int i=0; i<5; i++, current++){ x[i][j][k] = (char)current ; } } } return x; } public static float[][][] getFloatTripleRectangularArrayExample(){ float[][][] x = new float[5][3][2]; int current = 0 ; for( int k=0; k<2; k++){ for( int j=0; j<3; j++){ for( int i=0; i<5; i++, current++){ x[i][j][k] = 0.0f + current ; } } } return x; } public static String[][][] getStringTripleRectangularArrayExample(){ String[][][] x = new String[5][3][2]; int current = 0 ; for( int k=0; k<2; k++){ for( int j=0; j<3; j++){ for( int i=0; i<5; i++, current++){ x[i][j][k] = ""+current ; } } } return x; } public static DummyPoint[][][] getDummyPointTripleRectangularArrayExample(){ DummyPoint[][][] x = new DummyPoint[5][3][2]; int current = 0 ; for( int k=0; k<2; k++){ for( int j=0; j<3; j++){ for( int i=0; i<5; i++, current++){ x[i][j][k] = new DummyPoint( current, current ) ; } } } return x; } // }}} } rJava/inst/java/RJavaComparator.class0000644000176200001440000000171112256051770017302 0ustar liggesusers.6      !"# $ %& '()()VCodeLineNumberTablecompare'(Ljava/lang/Object;Ljava/lang/Object;)I Exceptions SourceFileRJavaComparator.java  *+java/lang/Number ,-java/lang/Double ./ 0 12java/lang/ComparableNotComparableException 3 14java/lang/ClassCastException 5RJavaComparatorjava/lang/Objectequals(Ljava/lang/Object;)ZgetClass()Ljava/lang/Class; doubleValue()D(D)V compareTo(Ljava/lang/Double;)I(Ljava/lang/Object;)V(Ljava/lang/Object;)I'(Ljava/lang/Object;Ljava/lang/Object;)V!* *+*;+4*+)Y*NY+:-* Y* + Y+ * + =N+ * t=: Y*+itw x > #2 B!I$Y%i(t/w)x+.,-0 rJava/inst/java/boot/0000755000176200001440000000000012256051770014163 5ustar liggesusersrJava/inst/java/boot/RJavaClassLoader.class0000644000176200001440000002626512256051770020345 0ustar liggesusers.A                ! "#$% &'()  *+ ! ,-. $/ !0 1 234 */ *567 89:;<=>?@A BC BDE F GH IJ IKLM NOP !Q RST RUV WXYZ [ \]^_`abcd ef Xghijk *lm *no cpq rst u v rwxyz r{|}~     X *  *  X/ *  !    ! !         Z       S    {     {  RJavaObjectInputStream InnerClasses UnixDirectory UnixJarFileUnixFile rJavaPathLjava/lang/String; rJavaLibPathlibMapLjava/util/HashMap; classPathLjava/util/Vector; primaryLoaderLRJavaClassLoader;verboseZ useSystemarray$Ljava$lang$StringLjava/lang/Class; SyntheticgetPrimaryLoader()LRJavaClassLoader;CodeLineNumberTable'(Ljava/lang/String;Ljava/lang/String;)VclassNameToFile&(Ljava/lang/String;)Ljava/lang/String; findClass%(Ljava/lang/String;)Ljava/lang/Class; Exceptions findResource"(Ljava/lang/String;)Ljava/net/URL; addRLibrary addClassPath(Ljava/lang/String;)V([Ljava/lang/String;)V getClassPath()[Ljava/lang/String; findLibrary bootClass:(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;)VsetDebug(I)Vu2wmaintoByte(Ljava/lang/Object;)[BtoObject([B)Ljava/lang/Object; toObjectPLclass$()V SourceFileRJavaClassLoader.java  java/lang/ClassNotFoundExceptionjava/lang/NoClassDefFoundError   java/net/URL   rJava.debug  0  java/lang/StringBuffer RJavaClassLoader(" ","")   - primary loader - NOT primrary (this=  , primary=)java/util/HashMap java/util/Vector RJavaClassLoader$UnixDirectory/java   RJavaClassLoader$UnixFile /rJava.so  /rJava.dllrJava /jri/libjri.sor.arch/jri /libjri.so/jri.dll/jri/libjri.jnilib /jri/jri.dlljri - registered JRI:   4RJavaClassLoader initialized. Registered libraries:     : ' ' Registered class paths:   ' ! -- end of class loader report --  .findClass(RJavaClassLoader  RJavaClassLoader: found class  using URL loaderjava/lang/Exception - URL loader did not find it: RJavaClassLoader.findClass(" - trying class path ""RJavaClassLoader$UnixJarFile .class    JAR file, can get ''? NOYES  /  java/io/FileInputStream   Directory, can get ' " loading class file, initial n =    next n =  (rp=, al= RJavaClassLoader: loaded class ,  bytes  defineClass(' ') returned FClass not found - candidate class binary found but could not be loaded  >> ClassNotFoundException  RJavaClassLoader: findResource('') $RJavaClassLoader: found resource in  using URL loader.9 - resource not found with URL loader, trying alternative  - found in a JAR file, URL  - find as a file:  RJavaClassLoader: added '' to the URL class path loader .jar  .JAR,RJavaClassLoader: adding Java archive file '' to the internal class path !*RJavaClassLoader: adding class directory ' "WARNING: the path 'Z' is neither a directory nor a .jar file, it will NOT be added to the internal class path!B' does NOT exist, it will NOT be added to the internal class path! #java.class.path$ % &' (java/lang/String )*RJavaClassLoader.findLibrary(" - mapping to  +,java/lang/Class [Ljava.lang.String;  -.java/lang/Object/ 01 23 rjava.pathERROR: rjava.path is not set 4 rjava.lib 5libs  main.class2WARNING: main.class not specified, assuming 'Main'Mainrjava.class.pathjava/util/StringTokenizer 6 7 "ERROR: while running main method: 8java/io/ByteArrayOutputStreamjava/io/ObjectOutputStream 9 :; <=java/io/ByteArrayInputStream >'RJavaClassLoader$RJavaObjectInputStream ? @ java/net/URLClassLoader java/lang/IllegalAccessException+java/lang/reflect/InvocationTargetExceptionjava/lang/NoSuchMethodExceptionforName getMessage()Ljava/lang/String;([Ljava/net/URL;)Vjava/lang/System getPropertylength()Iequals(Ljava/lang/Object;)ZoutLjava/io/PrintStream;append,(Ljava/lang/String;)Ljava/lang/StringBuffer;toStringjava/io/PrintStreamprintln,(Ljava/lang/Object;)Ljava/lang/StringBuffer;'(LRJavaClassLoader;Ljava/lang/String;)Vaddexists()Zput8(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;java/lang/Thread currentThread()Ljava/lang/Thread;setContextClassLoader(Ljava/lang/ClassLoader;)VkeySet()Ljava/util/Set; java/util/Setiterator()Ljava/util/Iterator;java/util/IteratorhasNextnext()Ljava/lang/Object;get&(Ljava/lang/Object;)Ljava/lang/Object;elements()Ljava/util/Enumeration;java/util/EnumerationhasMoreElements nextElementreplace(CC)Ljava/lang/String;getClass()Ljava/lang/Class;getResourceAsStream)(Ljava/lang/String;)Ljava/io/InputStream;getPathisFile(Ljava/io/File;)Vjava/io/InputStreamread([B)I(I)Ljava/lang/StringBuffer; arraycopy*(Ljava/lang/Object;ILjava/lang/Object;II)V([BII)Iclose defineClass)(Ljava/lang/String;[BII)Ljava/lang/Class;*(Ljava/lang/String;Ljava/lang/Throwable;)V getResourcetoURL()Ljava/net/URL;addURL(Ljava/net/URL;)VgetNameendsWith(Ljava/lang/String;)Z isDirectoryerrcontains java/io/File pathSeparator setProperty8(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;size elementAt(I)Ljava/lang/Object; resolveClass(Ljava/lang/Class;)V getMethod@(Ljava/lang/String;[Ljava/lang/Class;)Ljava/lang/reflect/Method;java/lang/reflect/Methodinvoke9(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object; separatorCharCexit separator hasMoreTokens nextTokenprintStackTrace(Ljava/io/OutputStream;)V writeObject(Ljava/lang/Object;)V toByteArray()[B([B)V*(LRJavaClassLoader;Ljava/io/InputStream;)V readObject!   **  N-- - *Y+,*=2,Y**Y *!Y"#*#$Y*Y+%&'W*+(*,)*Y*Y*)+,:-#*Y*Y*).,:-* /0W*Y*Y+1,:2 :t l*Y*Y+34,:- :6*Y*Y+35,:-:- *Y*Y+6,:- *Y*Y+7,:-/* 80WY9* :*;<* =>:??@:YAB* CDE*#F:G*YHIDҲJ/: +X^bs -5A^er%-9Y`gmu      ! +./K VM*YL*M+N+*O* V*+PM,)!YQ+R,#NYT-!YU+N:*#F:GYI*:"YVWNX\XY*+YZ[NY\*+Y]-^_~$v*Y*Y`a*+YZ,:b cYdN0Ye]-^_->f6:-g6  6 Yh i  -h6  jj6  :  k : 6-  dl6 6Ym in ioi   `6 u-p 6 +Yq+r is*+ tM :  :5%Yu+v,,:Ywx y, Yz,DswSS$S $S? /!=$D&J'N(r)t-w+x,/345679;=>.?g@oABCERSTUVWX!Y(Z.[9\?]J^N_Rabbcefginjlmoq!u$s&v)y.z:}H~LT'!Y{+|* 7*+}M,)!Y~,,M *#FM,G,I*N-X8-X+:&Y\-$U*Y*Y-`a+,:b)Y:S+Z^S S Sj$+15Y[^_mu~ "%/* +*Y*,,0W O*Y*+,M* 3*,!Y+NN,bL,,4XY*+NY+,4$Y*+&NjY+IC,-Y+Y+-<*#-1*#-'WY -`W=@SN =@ACbl )N6=+*+2]-*#<M>,*#*`S, %+l!Y+* +C*MN,,-,`N%Y---$02BjiA*+:*,YYS:Y-SW 1@  )   ! ./*/K*+ N L+ M,Y+MY+,N :  : :,Y::--*$:YSfBC DEGH I:KJLQM_NgOkQrRwSTUVWZ^[\]_ GYLY+M,*,+Űxyz{|SH Y+MY*,N-:- S  *ͰS2*LY+%  /4 "$X*rJava/inst/java/boot/RJavaClassLoader$UnixDirectory.class0000644000176200001440000000066212256051770023133 0ustar liggesusers.  this$0LRJavaClassLoader; Synthetic'(LRJavaClassLoader;Ljava/lang/String;)VCodeLineNumberTable SourceFileRJavaClassLoader.java  RJavaClassLoader$UnixDirectory UnixDirectory InnerClassesRJavaClassLoader$UnixFileUnixFileRJavaClassLoader   , *+,*+    rJava/inst/java/boot/RJavaClassLoader$UnixFile.class0000644000176200001440000000127312256051770022045 0ustar liggesusers.'       lastModStampJthis$0LRJavaClassLoader; Synthetic'(LRJavaClassLoader;Ljava/lang/String;)VCodeLineNumberTable hasChanged()Zupdate()V SourceFileRJavaClassLoader.java! "# $  %&RJavaClassLoader$UnixFileUnixFile InnerClasses java/io/FileRJavaClassLoaderu2w&(Ljava/lang/String;)Ljava/lang/String;(Ljava/lang/String;)V lastModified()J     7*,*+* ML NO0*@* UV% ** ]^ rJava/inst/java/boot/RJavaClassLoader$UnixJarFile.class0000644000176200001440000000366312256051770022507 0ustar liggesusers.p 4 5 6 78 9: ; < ; = > ?@ ABC DE F G H IJ KL M HNOPQ RSVzfileLjava/util/zip/ZipFile; urlPrefixLjava/lang/String;this$0LRJavaClassLoader; Synthetic'(LRJavaClassLoader;Ljava/lang/String;)VCodeLineNumberTableupdate()VgetResourceAsStream)(Ljava/lang/String;)Ljava/io/InputStream; getResource"(Ljava/lang/String;)Ljava/net/URL; SourceFileRJavaClassLoader.java () %& !" X-java/util/zip/ZipFile (Yjava/lang/Exception ,- Z[ \] ^_` abc dejava/lang/StringBuffer (-)RJavaClassLoader$UnixJarFile: exception: fg hi jik lm #$jar: no!java/net/MalformedURLExceptionjava/io/IOException java/net/URL (mRJavaClassLoader$UnixJarFile UnixJarFile InnerClassesRJavaClassLoader$UnixFileUnixFileclose(Ljava/io/File;)V hasChanged()ZgetEntry,(Ljava/lang/String;)Ljava/util/zip/ZipEntry;getInputStream/(Ljava/util/zip/ZipEntry;)Ljava/io/InputStream;RJavaClassLoaderverboseZjava/lang/SystemerrLjava/io/PrintStream;append,(Ljava/lang/String;)Ljava/lang/StringBuffer; getMessage()Ljava/lang/String;toStringjava/io/PrintStreamprintln(Ljava/lang/String;)VtoURL()Ljava/net/URL;  !"#$%&'()*, *+,*++sr t,-*W#* **Y*L*+yz|}"./*Y* * * **+ M, *, &M Y,404+* $(145W01*j**+ M*-*Y*NNYY*+MN,?B?FGdg+6 ?BCFGdgh23U?T ?WrJava/inst/java/boot/RJavaClassLoader$RJavaObjectInputStream.class0000644000176200001440000000160712256051770024651 0ustar liggesusers..     !this$0LRJavaClassLoader; Synthetic*(LRJavaClassLoader;Ljava/io/InputStream;)VCodeLineNumberTable Exceptions" resolveClass.(Ljava/io/ObjectStreamClass;)Ljava/lang/Class;# SourceFileRJavaClassLoader.java $  % &'( )*+ ,-'RJavaClassLoader$RJavaObjectInputStreamRJavaObjectInputStream InnerClassesjava/io/ObjectInputStreamjava/io/IOException java/lang/ClassNotFoundException(Ljava/io/InputStream;)Vjava/io/ObjectStreamClassgetName()Ljava/lang/String;RJavaClassLoadergetPrimaryLoader()LRJavaClassLoader;java/lang/ClassforName=(Ljava/lang/String;ZLjava/lang/ClassLoader;)Ljava/lang/Class;     + *,*+gf h $ +j rJava/inst/java/boot/RJavaClassLoader.java0000644000176200001440000004461512256051770020160 0ustar liggesusers// :tabSize=4:indentSize=4:noTabs=false:folding=explicit:collapseFolds=1: // {{{ imports import java.io.*; import java.io.File; import java.net.URL; import java.net.URLClassLoader; import java.util.HashMap; import java.util.Vector; import java.util.Enumeration; import java.util.Iterator; import java.util.StringTokenizer; import java.util.zip.*; // }}} /** * Class loader used internally by rJava * * The class manages the class paths and the native libraries (jri, ...) */ public class RJavaClassLoader extends URLClassLoader { // {{{ fields /** * path of RJava */ String rJavaPath ; /** * lib sub directory of rJava */ String rJavaLibPath; /** * map of libraries */ HashMap/**/ libMap; /** * The class path vector */ Vector/**/ classPath; /** * singleton */ public static RJavaClassLoader primaryLoader = null; /** * Print debug messages if is set to true */ public static boolean verbose = false; /** * Should the system class loader be used to resolve classes * as well as this class loader */ public boolean useSystem = true; // }}} // {{{ UnixFile class /** * Light extension of File that handles file separators and updates */ class UnixFile extends File { /** * cached "last time modified" stamp */ long lastModStamp; /** * Constructor. Modifies the path so that * the proper path separator is used (most useful on windows) */ public UnixFile(String fn) { super( u2w(fn) ) ; lastModStamp=0; } /** * @return whether the file modified since last time the update method was called */ public boolean hasChanged() { long curMod = lastModified(); return (curMod != lastModStamp); } /** * Cache the result of the lastModified stamp */ public void update() { lastModStamp = lastModified(); } } // }}} // {{{ UnixJarFile /** * Specialization of UnixFile that deals with jar files */ class UnixJarFile extends UnixFile { /** * The cached jar file */ private ZipFile zfile ; /** * common prefix for all URLs within this jar file */ private String urlPrefix ; public UnixJarFile( String filename ){ super( filename ); } /* @Override */ public void update(){ try { if (zfile != null){ zfile.close(); } zfile = new ZipFile( this ) ; } catch (Exception tryCloseX) {} /* time stamp */ super.update( ) ; } /** * Get an input stream for a resource contained in the jar file * * @param name file name of the resource within the jar file * @return an input stream representing the resouce if it exists or null */ public InputStream getResourceAsStream( String name ){ if (zfile==null || hasChanged()) { update(); } try { if (zfile == null) return null; ZipEntry e = zfile.getEntry(name); if (e != null) return zfile.getInputStream(e); } catch(Exception e) { if (verbose) System.err.println("RJavaClassLoader$UnixJarFile: exception: "+e.getMessage()); } return null; } public URL getResource(String name ){ if( zfile == null || zfile.getEntry( name ) == null ){ return null ; } URL u = null ; if( urlPrefix == null ){ try{ urlPrefix = "jar:" + toURL().toString() + "!" ; } catch( java.net.MalformedURLException ex){ } catch( java.io.IOException ex){ } } try{ u = new URL( urlPrefix + name ) ; } catch( java.net.MalformedURLException ex ){ /* not to worry */ } return u ; } } // }}} // {{{ UnixDirectory class /** * Specialization of UnixFile representing a directory */ /* it is not really a specialization but makes possible to dispatch on instanceof*/ class UnixDirectory extends UnixFile { public UnixDirectory( String dirname ){ super( dirname ) ; } } // }}} // {{{ getPrimaryLoader /** * Returns the singleton instance of RJavaClassLoader */ public static RJavaClassLoader getPrimaryLoader() { return primaryLoader; } // }}} // {{{ constructor /** * Constructor. The first time an RJavaClassLoader is created, it is * cached as the primary loader. * * @param path path of the rJava package * @param libpath lib sub directory of the rJava package */ public RJavaClassLoader(String path, String libpath) { super(new URL[] {}); // respect rJava.debug level String rjd = System.getProperty("rJava.debug"); if (rjd != null && rjd.length() > 0 && !rjd.equals("0")) verbose = true; if (verbose) System.out.println("RJavaClassLoader(\""+path+"\",\""+libpath+"\")"); if (primaryLoader==null) { primaryLoader = this; if (verbose) System.out.println(" - primary loader"); } else { if (verbose) System.out.println(" - NOT primrary (this="+this+", primary="+primaryLoader+")"); } libMap = new HashMap/**/(); classPath = new Vector/**/(); classPath.add(new UnixDirectory(path+"/java")); rJavaPath = path; rJavaLibPath = libpath; /* load the rJava library */ UnixFile so = new UnixFile(rJavaLibPath+"/rJava.so"); if (!so.exists()) so = new UnixFile(rJavaLibPath+"/rJava.dll"); if (so.exists()) libMap.put("rJava", so); /* load the jri library */ UnixFile jri = new UnixFile(path+"/jri/libjri.so"); String rarch = System.getProperty("r.arch"); if (rarch != null && rarch.length()>0) { UnixFile af = new UnixFile(path+"/jri"+rarch+"/libjri.so"); if (af.exists()) jri = af; else { af = new UnixFile(path+"/jri"+rarch+"/jri.dll"); if (af.exists()) jri = af; } } if (!jri.exists()) jri = new UnixFile(path+"/jri/libjri.jnilib"); if (!jri.exists()) jri = new UnixFile(path+"/jri/jri.dll"); if (jri.exists()) { libMap.put("jri", jri); if (verbose) System.out.println(" - registered JRI: "+jri); } /* if we are the primary loader, make us the context loader so projects that rely on the context loader pick us */ if (primaryLoader == this) Thread.currentThread().setContextClassLoader(this); if (verbose) { System.out.println("RJavaClassLoader initialized.\n\nRegistered libraries:"); for(Iterator entries = libMap.keySet().iterator(); entries.hasNext(); ) { Object key = entries.next(); System.out.println(" " + key + ": '" + libMap.get(key) + "'"); } System.out.println("\nRegistered class paths:"); for (Enumeration e = classPath.elements() ; e.hasMoreElements() ;) System.out.println(" '"+e.nextElement()+"'"); System.out.println("\n-- end of class loader report --"); } } // }}} // {{{ classNameToFile /** * convert . to / */ String classNameToFile(String cls) { return cls.replace('.','/'); } // }}} // {{{ findClass protected Class findClass(String name) throws ClassNotFoundException { Class cl = null; if (verbose) System.out.println(""+this+".findClass("+name+")"); if ("RJavaClassLoader".equals(name)) return getClass(); // {{{ use the usual method of URLClassLoader if (useSystem) { try { cl = super.findClass(name); if (cl != null) { if (verbose) System.out.println("RJavaClassLoader: found class "+name+" using URL loader"); return cl; } } catch (Exception fnf) { if (verbose) System.out.println(" - URL loader did not find it: " + fnf); } } if (verbose) System.out.println("RJavaClassLoader.findClass(\""+name+"\")"); // }}} // {{{ iterate through the elements of the class path InputStream ins = null; Exception defineException = null; Enumeration/**/ e = classPath.elements() ; while( e.hasMoreElements() ){ UnixFile cp = (UnixFile) e.nextElement(); if (verbose) System.out.println(" - trying class path \""+cp+"\""); try { ins = null; /* a file - assume it is a jar file */ if (cp instanceof UnixJarFile){ ins = ((UnixJarFile)cp).getResourceAsStream( classNameToFile(name) + ".class" ) ; if (verbose) System.out.println(" JAR file, can get '" + classNameToFile(name) + "'? " + ((ins == null) ? "NO" : "YES")); } else if ( cp instanceof UnixDirectory ){ UnixFile class_f = new UnixFile(cp.getPath()+"/"+classNameToFile(name)+".class"); if (class_f.isFile() ) { ins = new FileInputStream(class_f); } if (verbose) System.out.println(" Directory, can get '" + class_f + "'? " + ((ins == null) ? "NO" : "YES")); } /* some comments on the following : we could call ZipEntry.getSize in case of a jar file to find out the size of the byte[] directly also ByteBuffer seems more efficient, but the ByteBuffer class is java >= 1.4 and the defineClass method that uses the class is java >= 1.5 */ if (ins != null) { int al = 128*1024; byte fc[] = new byte[al]; int n = ins.read(fc); int rp = n; if( verbose ) System.out.println(" loading class file, initial n = "+n); while (n > 0) { if (rp == al) { int nexa = al*2; if (nexa<512*1024) nexa=512*1024; byte la[] = new byte[nexa]; System.arraycopy(fc, 0, la, 0, al); fc = la; al = nexa; } n = ins.read(fc, rp, fc.length-rp); if( verbose ) System.out.println(" next n = "+n+" (rp="+rp+", al="+al+")"); if (n>0) rp += n; } ins.close(); n = rp; if (verbose) System.out.println("RJavaClassLoader: loaded class "+name+", "+n+" bytes"); try { cl = defineClass(name, fc, 0, n); } catch (Exception dce) { // we want to save this one so we can pass it on defineException = dce; break; } if (verbose) System.out.println(" defineClass('" + name +"') returned " + cl); // System.out.println(" - class = "+cl); return cl; } } catch (Exception ex) { // System.out.println(" * won't work: "+ex.getMessage()); } } // }}} if (defineException != null) // we bailed out on class interpretation, re-throw it throw (new ClassNotFoundException("Class not found - candidate class binary found but could not be loaded", defineException)); // giving up if( verbose ) System.out.println(" >> ClassNotFoundException "); if (cl == null) { throw (new ClassNotFoundException()); } return cl; } // }}} // {{{ findResource public URL findResource(String name) { if (verbose) System.out.println("RJavaClassLoader: findResource('"+name+"')"); // {{{ use the standard way if (useSystem) { try { URL u = super.findResource(name); if (u != null) { if (verbose) System.out.println("RJavaClassLoader: found resource in "+u+" using URL loader."); return u; } } catch (Exception fre) { } } // }}} // {{{ iterate through the classpath if (verbose) System.out.println(" - resource not found with URL loader, trying alternative"); Enumeration/**/ e = classPath.elements() ; while( e.hasMoreElements()) { UnixFile cp = (UnixFile) e.nextElement(); try { /* is a file - assume it is a jar file */ if (cp instanceof UnixJarFile ) { URL u = ( (UnixJarFile)cp ).getResource( name ) ; if (u != null) { if (verbose) System.out.println(" - found in a JAR file, URL "+u); return u; } } else if(cp instanceof UnixDirectory ) { UnixFile res_f = new UnixFile(cp.getPath()+"/"+name); if (res_f.isFile()) { if (verbose) System.out.println(" - find as a file: "+res_f); return res_f.toURL(); } } } catch (Exception iox) { } } // }}} return null; } // }}} // {{{ addRLibrary /** add a library to path mapping for a native library */ public void addRLibrary(String name, String path) { libMap.put(name, new UnixFile(path)); } // }}} // {{{ addClassPath /** * adds an entry to the class path */ public void addClassPath(String cp) { UnixFile f = new UnixFile(cp); // use the URLClassLoader if (useSystem) { try { addURL(f.toURL()); if (verbose) System.out.println("RJavaClassLoader: added '" + cp + "' to the URL class path loader"); //return; // we need to add it anyway so it appears in .jclassPath() } catch (Exception ufe) { } } UnixFile g = null ; if( f.isFile() && (f.getName().endsWith(".jar") || f.getName().endsWith(".JAR"))) { g = new UnixJarFile(cp) ; if (verbose) System.out.println("RJavaClassLoader: adding Java archive file '"+cp+"' to the internal class path"); } else if( f.isDirectory() ){ g = new UnixDirectory(cp) ; if (verbose) System.out.println("RJavaClassLoader: adding class directory '"+cp+"' to the internal class path"); } else if (verbose) System.err.println(f.exists() ? ("WARNING: the path '"+cp+"' is neither a directory nor a .jar file, it will NOT be added to the internal class path!") : ("WARNING: the path '"+cp+"' does NOT exist, it will NOT be added to the internal class path!")); if (g != null && !classPath.contains(g)) { // this is the real meat - add it to our internal list classPath.add(g); // this is just cosmetics - it doesn't really have any meaning System.setProperty("java.class.path", System.getProperty("java.class.path")+File.pathSeparator+g.getPath()); } } /** * adds several entries to the class path */ public void addClassPath(String[] cp) { int i = 0; while (i < cp.length) addClassPath(cp[i++]); } // }}} // {{{ getClassPath /** * @return the array of class paths used by this class loader */ public String[] getClassPath() { int j = classPath.size(); String[] s = new String[j]; int i = 0; while (i < j) { s[i] = ((UnixFile) classPath.elementAt(i)).getPath(); i++; } return s; } // }}} // {{{ findLibrary protected String findLibrary(String name) { if (verbose) System.out.println("RJavaClassLoader.findLibrary(\""+name+"\")"); //if (name.equals("rJava")) // return rJavaLibPath+"/"+name+".so"; UnixFile u = (UnixFile) libMap.get(name); String s = null; if (u!=null && u.exists()) s=u.getPath(); if (verbose) System.out.println(" - mapping to "+((s==null)?"":s)); return s; } // }}} // {{{ bootClass /** * Boots the specified method of the specified class * * @param cName class to boot * @param mName method to boot (typically main). The method must take a String[] as parameter * @param args arguments to pass to the method */ public void bootClass(String cName, String mName, String[] args) throws java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException, java.lang.NoSuchMethodException, java.lang.ClassNotFoundException { Class c = findClass(cName); resolveClass(c); java.lang.reflect.Method m = c.getMethod(mName, new Class[] { String[].class }); m.invoke(null, new Object[] { args }); } // }}} // {{{ setDebug /** * Set the debug level. At the moment, there is only verbose (level>0) * or quiet * * @param level debug level. verbose (>0), quiet otherwise */ public static void setDebug(int level) { verbose=(level>0); } // }}} // {{{ u2w /** * Utility to convert paths for windows. Converts / to the path separator in use * * @param fn file name */ public static String u2w(String fn) { return (File.separatorChar != '/') ? fn.replace('/', File.separatorChar) : fn ; } // }}} // {{{ main /** * main method * *

This uses the system properties: *

    *
  • rjava.path : path of the rJava package
  • *
  • rjava.lib : lib sub directory of the rJava package
  • *
  • main.class : main class to "boot", assumes Main if not specified
  • *
  • rjava.class.path : set of paths to populate the initiate the class path
  • *
*

* *

and boots the "main" method of the specified main.class, * passing the args down to the booted class

* *

This makes sure R and rJava are known by the class loader

*/ public static void main(String[] args) { String rJavaPath = System.getProperty("rjava.path"); if (rJavaPath == null) { System.err.println("ERROR: rjava.path is not set"); System.exit(2); } String rJavaLib = System.getProperty("rjava.lib"); if (rJavaLib == null) { // it is not really used so far, just for rJava.so, so we can guess rJavaLib = rJavaPath + File.separator + "libs"; } RJavaClassLoader cl = new RJavaClassLoader(u2w(rJavaPath), u2w(rJavaLib)); String mainClass = System.getProperty("main.class"); if (mainClass == null || mainClass.length()<1) { System.err.println("WARNING: main.class not specified, assuming 'Main'"); mainClass = "Main"; } String classPath = System.getProperty("rjava.class.path"); if (classPath != null) { StringTokenizer st = new StringTokenizer(classPath, File.pathSeparator); while (st.hasMoreTokens()) { String dirname = u2w(st.nextToken()); cl.addClassPath(dirname); } } try { cl.bootClass(mainClass, "main", args); } catch (Exception ex) { System.err.println("ERROR: while running main method: "+ex); ex.printStackTrace(); } } // }}} //----- tools ----- // {{{ RJavaObjectInputStream class class RJavaObjectInputStream extends ObjectInputStream { public RJavaObjectInputStream(InputStream in) throws IOException { super(in); } protected Class resolveClass(ObjectStreamClass desc) throws ClassNotFoundException { return Class.forName(desc.getName(), false, RJavaClassLoader.getPrimaryLoader()); } } // }}} // {{{ toByte /** * Serialize an object to a byte array. (code by CB) * * @param object object to serialize * @return byte array that represents the object * @throws Exception */ public static byte[] toByte(Object object) throws Exception { ByteArrayOutputStream os = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream((OutputStream) os); oos.writeObject(object); oos.close(); return os.toByteArray(); } // }}} // {{{ toObject /** * Deserialize an object from a byte array. (code by CB) * * @param byteArray * @return the object that is represented by the byte array * @throws Exception */ public Object toObject(byte[] byteArray) throws Exception { InputStream is = new ByteArrayInputStream(byteArray); RJavaObjectInputStream ois = new RJavaObjectInputStream(is); Object o = (Object) ois.readObject(); ois.close(); return o; } // }}} // {{{ toObjectPL /** * converts the byte array into an Object using the primary RJavaClassLoader */ public static Object toObjectPL(byte[] byteArray) throws Exception{ return RJavaClassLoader.getPrimaryLoader().toObject(byteArray); } // }}} } rJava/inst/java/RectangularArrayExamples.class0000644000176200001440000001034112256051770021213 0ustar liggesusers.r NOPQRSTUVWX NY Z [ \]^ _`abcdefghijk()VCodeLineNumberTable#getIntDoubleRectangularArrayExample()[[I'getBooleanDoubleRectangularArrayExample()[[Z$getByteDoubleRectangularArrayExample()[[B$getLongDoubleRectangularArrayExample()[[J%getShortDoubleRectangularArrayExample()[[S&getDoubleDoubleRectangularArrayExample()[[D$getCharDoubleRectangularArrayExample()[[C%getFloatDoubleRectangularArrayExample()[[F&getStringDoubleRectangularArrayExample()[[Ljava/lang/String;*getDummyPointDoubleRectangularArrayExample()[[LDummyPoint;#getIntTripleRectangularArrayExample()[[[I'getBooleanTripleRectangularArrayExample()[[[Z$getByteTripleRectangularArrayExample()[[[B$getLongTripleRectangularArrayExample()[[[J%getShortTripleRectangularArrayExample()[[[S&getDoubleTripleRectangularArrayExample()[[[D$getCharTripleRectangularArrayExample()[[[C%getFloatTripleRectangularArrayExample()[[[F&getStringTripleRectangularArrayExample()[[[Ljava/lang/String;*getDummyPointTripleRectangularArrayExample()[[[LDummyPoint; SourceFileRectangularArrayExamples.java ![[I[[Z[[B[[J[[S[[D[[C[[F[[Ljava/lang/String;java/lang/StringBuffer lm ln op[[LDummyPoint; DummyPoint q[[[I[[[Z[[[B[[[J[[[S[[[D[[[C[[[F[[[Ljava/lang/String;[[[LDummyPoint;RectangularArrayExamplesjava/lang/Objectappend,(Ljava/lang/String;)Ljava/lang/StringBuffer;(I)Ljava/lang/StringBuffer;toString()Ljava/lang/String;(II)V! !"*# $%"b.K<=>*2O*#"  & , &'"i5K<=&>*2T<*#" -3 ()"c/K<= >*2T*#"!" #$%$'#-( *+"c/K<= >*2P*#",- ./0/'.-3 ,-"c/K<= >*2V*#"78 9:;:'9-> ./"e1K<=">*2cR*#"BC DEF E)D/I 01"c/K<= >*2U*#"MN OPQP'O-T 23"e1 K<=">*2 bQ*#"XY Z[\ [)Z/_ 45"t@ K<=1>$*2 Y  S݄*#"cd efg/f8e>j 67"j6K<='>*2YS*#"no pqr%q.p4u 89"}AK<=1>$6*22O݄*#* {| }~!*3~9}? :;"HK<=8>+6*22T<ք*#*  !*:@F <="~BK<=2>%6*22T܄*#*  !+4:@ >?"~BK<=2>%6*22P܄*#*  !+4:@ @A"~BK<=2>%6*22V܄*#*  !+4:@ BC"DK<=4>'6*22cRڄ*#*  !-6<B DE"~BK<=2>%6*22U܄*#*  !+4:@ FG"DK<=4>'6*22 bQڄ*#*  !-6<B HI"SK<=C>66'*22 Y  Sل˄*#*  !<EKQ JK"IK<=9>,6*22YSՄ*#*  !2;AGLMrJava/inst/java/RJavaImport.class0000644000176200001440000000612612256051770016452 0ustar liggesusers. 3Q 1RS Q 1TU Q 1V 1W 1X YZ[ Q\ ]^_` ab c de fg fhi ajk fl mn op qrst u 1vw x y 1z f{ |m |}~ |  1DEBUGZimportedPackagesLjava/util/Vector;cacheLjava/util/Map;loaderLjava/lang/ClassLoader;(Ljava/lang/ClassLoader;)VCodeLineNumberTablelookup%(Ljava/lang/String;)Ljava/lang/Class;lookup_exists(Ljava/lang/String;)Zexists_ importPackage(Ljava/lang/String;)V([Ljava/lang/String;)VgetKnownClasses()[Ljava/lang/String;4(Ljava/lang/String;Ljava/util/Set;)Ljava/lang/Class;()V SourceFileRJavaImport.java =N ;<java/util/Vector 78java/util/HashMap 9: CB 56 java/lang/StringBuffer [J] lookup( ' ' ) =  '  H java/lang/String Bjava/lang/Exception  [J]  packages . [J] trying class :  [JE] FE [J] exists( ' GH  ! [J] getKnownClasses().length =   RJavaImport ABjava/lang/Objectjava/io/Serializablejava/lang/SystemoutLjava/io/PrintStream;append,(Ljava/lang/String;)Ljava/lang/StringBuffer;java/lang/ClassgetName()Ljava/lang/String;toStringjava/io/PrintStreamprintln java/util/Map containsKey(Ljava/lang/Object;)Zget&(Ljava/lang/Object;)Ljava/lang/Object;forNameput8(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;size()I(I)Ljava/lang/StringBuffer;(I)Ljava/lang/Object; getMessage(Z)Ljava/lang/StringBuffer;addkeySet()Ljava/util/Set; java/util/SettoArray(([Ljava/lang/Object;)[Ljava/lang/Object;iterator()Ljava/util/Iterator;java/util/IteratorhasNext()Znext()Ljava/lang/Object;!134 56789:;< =>?H **+*Y*Y@23 456AB?sS*+ M H Y +, Y ,,@@AQBCB?M*+*+N-:N+MN,*++W,*> ! Y 6* : Y !+:  Y "M(: Y #$,*+,W,l%&',/{@nFHJK#L&M'T,U0V4W@XB[J\n]r^{`abcfdeghi^ mDE?P0*+%= % Y &+'@tu.vFE?9*+*+ @ z|GH?& *+(W@  GI?:=+*+2)@JK?l@**L++=N+-,W  Y ---@ > AL?]-+.N-/-01:*2M,,@"(+MN? @OPrJava/inst/java/RectangularArraySummary.class0000644000176200001440000000707212256051770021101 0ustar liggesusers. KLMN O P 'Q &R ST &U SV &W XY KZ S[ &\ &] &^ &_` &a &b &c &d &e &f &gh i Kj kl &mn o &pq &r KstulengthItypeNameLjava/lang/String; isprimitiveZ componentTypeLjava/lang/Class;class$java$lang$Comparable Synthetic(Ljava/lang/Object;[I)VCodeLineNumberTable Exceptionsv(Ljava/lang/Object;I)Vmin(Z)Ljava/lang/Object;maxrange(Z)[Ljava/lang/Object;(([Ljava/lang/Object;Z)Ljava/lang/Object;)([Ljava/lang/Object;Z)[Ljava/lang/Object;checkComparableObjects()VcontainsComparableObjects()Zsmaller'(Ljava/lang/Object;Ljava/lang/Object;)Zbiggerclass$%(Ljava/lang/String;)Ljava/lang/Class; SourceFileRectangularArraySummary.javaw xH java/lang/ClassNotFoundExceptionjava/lang/NoClassDefFoundError yz 2{ 2| }~ *+ ,- ./ @A 23 [Ljava/lang/Object; 9> C DE ;> FE <?java/lang/Comparable  BCNotComparableException 2{ 0/java.lang.Comparable GH RectangularArraySummaryRJavaArrayIteratorNotAnArrayExceptionjava/lang/ClassforName getMessage()Ljava/lang/String;(Ljava/lang/String;)V([I)VarrayLjava/lang/Object;RJavaArrayToolsgetObjectTypeName&(Ljava/lang/Object;)Ljava/lang/String;isPrimitiveTypeName(Ljava/lang/String;)Zjava/lang/ObjectgetClass()Ljava/lang/Class;getClassLoader()Ljava/lang/ClassLoader;getClassForSignature<(Ljava/lang/String;Ljava/lang/ClassLoader;)Ljava/lang/Class; dimensions[IhasNextnext()Ljava/lang/Object; compareTo(Ljava/lang/Object;)IgetComponentTypejava/lang/reflect/Array newInstance&(Ljava/lang/Class;I)Ljava/lang/Object;isAssignableFrom(Ljava/lang/Class;)Z!&'()*+,-./0/1 234t8*,*+*+ ** ** + N*/25" /3 7!67 284) *+ YO5 $ %67 9:4b* M6***6*N-  -M6-,-M,5B,- / 134&8-9<:@;F=K>M?S@[A`E;:4b* M6***6*N-  -M6-,-M,5BOP S UWX&\-]<^@_FaKbMcSd[e`i<=4|* **M6*P*N-  -M6-2,2 ,-2S-2,2,-2S,5Jst wx!{#}&-<@FKMS_eqz 9>4I*=N669*2: $ N6-N-5:"'*0>AG ;>4I*=N669*2: $ N6-N-5:"'*0>AG <?4y*=* N66Y*2: D-S-S6--2-S-2-S-5F!',27<AGW\lqw@A40* Y* !5 6 BC45"#$Y""*%5 DE4+*+5 FE4+*+5GH42*LY+51IJrJava/inst/java/RectangularArrayBuilder.java0000644000176200001440000001462512256051770020650 0ustar liggesusers// :tabSize=2:indentSize=2:noTabs=false:folding=explicit:collapseFolds=1: import java.lang.reflect.Array ; /** * Builds rectangular java arrays */ public class RectangularArrayBuilder extends RJavaArrayIterator { // {{{ constructors /** * constructor * * @param payload one dimensional array * @param dimensions target dimensions * @throws NotAnArrayException if payload is not an array */ public RectangularArrayBuilder( Object payload, int[] dimensions) throws NotAnArrayException, ArrayDimensionException { super( dimensions ) ; if( !RJavaArrayTools.isArray(payload) ){ throw new NotAnArrayException( payload.getClass() ) ; } if( !RJavaArrayTools.isSingleDimensionArray(payload)){ throw new ArrayDimensionException( "not a single dimension array : " + payload.getClass() ) ; } if( dimensions.length == 1 ){ array = payload ; } else{ String typeName = RJavaArrayTools.getObjectTypeName( payload ); Class clazz = null ; try{ clazz = RJavaArrayTools.getClassForSignature( typeName, payload.getClass().getClassLoader() ); } catch( ClassNotFoundException e){/* should not happen */} array = Array.newInstance( clazz , dimensions ) ; if( typeName.equals( "I" ) ){ fill_int( (int[])payload ) ; } else if( typeName.equals( "Z" ) ){ fill_boolean( (boolean[])payload ) ; } else if( typeName.equals( "B" ) ){ fill_byte( (byte[])payload ) ; } else if( typeName.equals( "J" ) ){ fill_long( (long[])payload ) ; } else if( typeName.equals( "S" ) ){ fill_short( (short[])payload ) ; } else if( typeName.equals( "D" ) ){ fill_double( (double[])payload ) ; } else if( typeName.equals( "C" ) ){ fill_char( (char[])payload ) ; } else if( typeName.equals( "F" ) ){ fill_float( (float[])payload ) ; } else{ fill_Object( (Object[])payload ) ; } } } public RectangularArrayBuilder( Object payload, int length ) throws NotAnArrayException, ArrayDimensionException{ this( payload, new int[]{ length } ) ; } // java < 1.5 kept happy public RectangularArrayBuilder(int x , int[] dim ) throws NotAnArrayException { throw new NotAnArrayException("primitive type : int ") ; } public RectangularArrayBuilder(boolean x, int[] dim ) throws NotAnArrayException { throw new NotAnArrayException("primitive type : boolean ") ; } public RectangularArrayBuilder(byte x , int[] dim ) throws NotAnArrayException { throw new NotAnArrayException("primitive type : byte ") ; } public RectangularArrayBuilder(long x , int[] dim ) throws NotAnArrayException { throw new NotAnArrayException("primitive type : long ") ; } public RectangularArrayBuilder(short x , int[] dim ) throws NotAnArrayException { throw new NotAnArrayException("primitive type : short ") ; } public RectangularArrayBuilder(double x , int[] dim ) throws NotAnArrayException { throw new NotAnArrayException("primitive type : double ") ; } public RectangularArrayBuilder(char x , int[] dim ) throws NotAnArrayException { throw new NotAnArrayException("primitive type : char ") ; } public RectangularArrayBuilder(float x , int[] dim ) throws NotAnArrayException { throw new NotAnArrayException("primitive type : float ") ; } public RectangularArrayBuilder(int x , int length ) throws NotAnArrayException { throw new NotAnArrayException("primitive type : int ") ; } public RectangularArrayBuilder(boolean x, int length ) throws NotAnArrayException { throw new NotAnArrayException("primitive type : boolean ") ; } public RectangularArrayBuilder(byte x , int length ) throws NotAnArrayException { throw new NotAnArrayException("primitive type : byte ") ; } public RectangularArrayBuilder(long x , int length ) throws NotAnArrayException { throw new NotAnArrayException("primitive type : long ") ; } public RectangularArrayBuilder(short x , int length ) throws NotAnArrayException { throw new NotAnArrayException("primitive type : short ") ; } public RectangularArrayBuilder(double x , int length ) throws NotAnArrayException { throw new NotAnArrayException("primitive type : double ") ; } public RectangularArrayBuilder(char x , int length ) throws NotAnArrayException { throw new NotAnArrayException("primitive type : char ") ; } public RectangularArrayBuilder(float x , int length ) throws NotAnArrayException { throw new NotAnArrayException("primitive type : float ") ; } // }}} // {{{ fill_** private void fill_int( int[] payload ){ int k; while( hasNext() ){ int[] current = (int[])next() ; k = start ; for( int j=0; j?@ T AB AC DEF GHIJ KLMNODummyNonStaticClass InnerClasses TestException ExampleClassbogusI staticbogusxstatic_xclass$DummyPointLjava/lang/Class; Syntheticclass$RJavaTools_Testclass$java$lang$Objectclass$java$lang$Integer#class$RJavaTools_Test$TestException)class$RJavaTools_Test$DummyNonStaticClassclass$java$lang$String"class$RJavaTools_Test$ExampleClass()VCodeLineNumberTablegetBogus()IgetStaticBogusgetX getStaticXsetX(Ljava/lang/Integer;)Vmain([Ljava/lang/String;)Vruntests Exceptionsfails"(LRJavaTools_Test$TestException;)Vsuccess getfieldnamesgetmethodnamesgetcompletionnameisstatic constructorsmethodshasfield hasmethodhasclassgetclass classhasfield classhasclassclasshasmethodgetstaticfieldsgetstaticmethodsgetstaticclasses invokemethodgetfieldtypenameclass$%(Ljava/lang/String;)Ljava/lang/Class; SourceFileRJavaTools_Test.java PK java/lang/ClassNotFoundExceptionjava/lang/NoClassDefFoundError QR &S &'    T U+ 3'RJavaTools_Test$TestException 56V WX YZ!Testing RJavaTools.getConstructor[ \S <' 7' Testing RJavaTools.classHasField B'!Testing RJavaTools.classHasMethod D' Testing RJavaTools.classHasClass C'Testing RJavaTools.hasField >'Testing RJavaTools.hasClass @'Testing RJavaTools.getClass A'Testing RJavaTools.hasMethod ?'Testing RJavaTools.isStatic ;'$Testing RJavaTools.getCompletionName :' Testing RJavaTools.getFieldNames 8'!Testing RJavaTools.getMethodNames 9'"Testing RJavaTools.getStaticFields E'#Testing RJavaTools.getStaticMethods F'#Testing RJavaTools.getStaticClasses G'Testing RJavaTools.invokeMethod H'#Testing RJavaTools.getFieldTypeName I'Testing RJavaTools.getMethodNOT YET AVAILABLETesting RJavaTools.newInstance ]Z ^'FAILEDPASSED& * getFieldNames(DummyPoint, false) _S  DummyPoint JK` ab,getFieldNames(DummyPoint, false).length != 2 &S cdy6getFieldNames(DummyPoint, false).length != c('x','y')  : ok & * getFieldNames(DummyPoint, true )0getFieldNames(DummyPoint, true ) != character(0)+ * getFieldNames(RJavaTools_Test, true ) RJavaTools_Test1getFieldNames(RJavaTools_Test, true ).length != 17getFieldNames(RJavaTools_Test, true )[0] != 'static_x' , * getFieldNames(RJavaTools_Test, false )2getFieldNames(RJavaTools_Test, false ).length != 2=getFieldNames(RJavaTools_Test, false ) != c('x', 'static_x') + * getMethodNames(RJavaTools_Test, true) ebjava/lang/StringBuffer3getMethodNames(RJavaTools_Test, true).length != 3 ( fg fh) iRjava/lang/String getStaticX()main( runtests()PgetMethodNames(RJavaTools_Test, true) != {'getStaticX()','main(', 'runtests()' }" * getMethodNames(Object, true)  java.lang.Object*getMethodNames(Object, true).length != 0 (, * getMethodNames(RJavaTools_Test, false)getX()setX(HgetMethodNames(RJavaTools_Test, false) did not contain expected methods * * getCompletionName(RJavaTools_Test.x) jk lm,getCompletionName(RJavaTools_Test.x) != 'x'  == 'x' : ok java/lang/NoSuchFieldException1 * getCompletionName(RJavaTools_Test.static_x):getCompletionName(RJavaTools_Test.static_x) != 'static_x'  == 'static_x' : ok 0 * getCompletionName(RJavaTools_Test.getX() )[Ljava/lang/Class; no8getCompletionName(RJavaTools_Test.getX() ) != ''getX()'  == 'getX()' : ok java/lang/NoSuchMethodException9 * getCompletionName(RJavaTools_Test.setX( Integer ) )java/lang/Class !java.lang.Integer=getCompletionName(RJavaTools_Test.setX(Integer) ) != 'setX('  == 'setX(' : ok ! * isStatic(RJavaTools_Test.x) pq#isStatic(RJavaTools_Test.x) == true = false : ok ' * isStatic(RJavaTools_Test.getX() )*isStatic(RJavaTools_Test.getX() ) == false( * isStatic(RJavaTools_Test.static_x)+isStatic(RJavaTools_Test.static_x) == false = true : ok - * isStatic(RJavaTools_Test.getStaticX() )0isStatic(RJavaTools_Test.getStaticX() ) == false. * isStatic(RJavaTools_Test.TestException ) " pr0isStatic(RJavaTools_Test.TestException) == false4 * isStatic(RJavaTools_Test.DummyNonStaticClass ) ##RJavaTools_Test$DummyNonStaticClass5isStatic(RJavaTools_Test.DummyNonStaticClass) == true$ * getConstructor( String, null ) $java.lang.String[Z stjava/lang/ExceptiongetConstructor( String, null )1 * getConstructor( Integer, { String.class } )+getConstructor( Integer, { String.class } )% * getConstructor( Integer, null )6getConstructor( Integer, null ) did not generate error -> exception : ok RJavaTools_Test$ExampleClass &uM * getConstructor( ExampleClass, {Object.class, Object.class, boolean}) : %v wQgetConstructor( ExampleClass, {Object.class, Object.class, boolean}) : exception  ok) java> DummyPoint p = new DummyPoint() * hasField( p, 'x' ) xy% hasField( DummyPoint, 'x' ) == false true : ok% * hasField( p, 'iiiiiiiiiiiii' )  iiiiiiiiiiiii0 hasField( DummyPoint, 'iiiiiiiiiiiii' ) == true false : ok * testing a private field ( hasField returned true on private field * hasMethod( p, 'move' ) move zy( hasField( DummyPoint, 'move' ) == false& * hasMethod( p, 'iiiiiiiiiiiii' ) , hasMethod( Point, 'iiiiiiiiiiiii' ) == true * testing a private method * hasMethod returned true on private method3 * hasClass( RJavaTools_Test, 'TestException' ) {y6 hasClass( RJavaTools_Test, 'TestException' ) == false true : ok9 * hasClass( RJavaTools_Test, 'DummyNonStaticClass' ) < hasClass( RJavaTools_Test, 'DummyNonStaticClass' ) == false9 * getClass( RJavaTools_Test, 'TestException', true ) |}D getClass( RJavaTools_Test, 'TestException', true ) != TestException : ok? * getClass( RJavaTools_Test, 'DummyNonStaticClass', true ) A getClass( RJavaTools_Test, 'DummyNonStaticClass', true ) != null@ * getClass( RJavaTools_Test, 'DummyNonStaticClass', false ) > * classHasClass( RJavaTools_Test, 'TestException', true ) ~A classHasClass( RJavaTools_Test, 'TestException', true ) == falseD * classHasClass( RJavaTools_Test, 'DummyNonStaticClass', true ) F classHasClass( RJavaTools_Test, 'DummyNonStaticClass', true ) == trueE * classHasClass( RJavaTools_Test, 'DummyNonStaticClass', false ) H classHasClass( RJavaTools_Test, 'DummyNonStaticClass', false ) == false7 * classHasMethod( RJavaTools_Test, 'getX', false ) : classHasMethod( RJavaTools_Test, 'getX', false ) == false= * classHasMethod( RJavaTools_Test, 'getStaticX', false ) @ classHasMethod( RJavaTools_Test, 'getStaticX', false ) == false6 * classHasMethod( RJavaTools_Test, 'getX', true ) L classHasMethod( RJavaTools_Test, 'getX', true ) == true (non static method)< * classHasMethod( RJavaTools_Test, 'getStaticX', true ) H classHasMethod( RJavaTools_Test, 'getStaticX', true ) == false (static); * classHasMethod( RJavaTools_Test, 'getBogus', false ) N classHasMethod( RJavaTools_Test, 'getBogus', false ) == true (private method)@ * classHasMethod( RJavaTools_Test, 'getStaticBogus', true ) M classHasMethod( RJavaTools_Test, 'getBogus', true ) == true (private method)) * getStaticFields( RJavaTools_Test ) / getStaticFields( RJavaTools_Test ).length != 1 R4 getStaticFields( RJavaTools_Test )[0] != 'static_x' * getStaticFields( Object ) " getStaticFields( Object ) != null* * getStaticMethods( RJavaTools_Test ) 0 getStaticMethods( RJavaTools_Test ).length != 2M getStaticMethods( RJavaTools_Test ) != c('main', 'getStaticX', 'runtests' ) ! * getStaticMethods( Object ) # getStaticMethods( Object ) != null! * getStaticClasses( Object ) # getStaticClasses( Object ) != null* * getStaticClasses( RJavaTools_Test ) 0 getStaticClasses( RJavaTools_Test ).length != 1E getStaticClasses( RJavaTools_Test ) != RJavaTools_Test.TestException. * testing enforcing accessibility (bug# 128)java/util/HashMap   |iterator[Ljava/lang/Object; java/lang/Throwable!not able to enforce accessibility% * getFieldTypeName( DummyPoint, x ) int(getFieldTypeName( DummyPoint, x ) != int: okjava/lang/ObjectforName getMessage()Ljava/lang/String;(Ljava/lang/String;)Vjava/lang/IntegerintValuejava/lang/Systemexit(I)VoutLjava/io/PrintStream;java/io/PrintStreamprintlnerrprintStackTraceprint RJavaTools getFieldNames'(Ljava/lang/Class;Z)[Ljava/lang/String;equals(Ljava/lang/Object;)ZgetMethodNamesappend,(Ljava/lang/String;)Ljava/lang/StringBuffer;(I)Ljava/lang/StringBuffer;toStringgetField-(Ljava/lang/String;)Ljava/lang/reflect/Field;getCompletionName.(Ljava/lang/reflect/Member;)Ljava/lang/String; getMethod@(Ljava/lang/String;[Ljava/lang/Class;)Ljava/lang/reflect/Method;isStatic(Ljava/lang/reflect/Member;)Z(Ljava/lang/Class;)ZgetConstructorF(Ljava/lang/Class;[Ljava/lang/Class;[Z)Ljava/lang/reflect/Constructor;((Ljava/lang/Object;Ljava/lang/String;Z)Vjava/lang/BooleanTYPEhasField'(Ljava/lang/Object;Ljava/lang/String;)Z hasMethodhasClassgetClass7(Ljava/lang/Class;Ljava/lang/String;Z)Ljava/lang/Class; classHasClass'(Ljava/lang/Class;Ljava/lang/String;Z)ZclassHasMethodgetStaticFields-(Ljava/lang/Class;)[Ljava/lang/reflect/Field;java/lang/reflect/FieldgetNamegetStaticMethods.(Ljava/lang/Class;)[Ljava/lang/reflect/Method;java/lang/reflect/MethodgetStaticClasses%(Ljava/lang/Class;)[Ljava/lang/Class; java/util/Mapput8(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;entrySet()Ljava/util/Set;()Ljava/lang/Class; invokeMethodn(Ljava/lang/Class;Ljava/lang/Object;Ljava/lang/String;[Ljava/lang/Object;[Ljava/lang/Class;)Ljava/lang/Object;getFieldTypeName7(Ljava/lang/Class;Ljava/lang/String;)Ljava/lang/String;!    !"#$%&'(3***)  *+(*) ,+( )-+(*) .+( )/0(! *+ ) 12(D L+ )!%"# $& 3'( !"#$%&'()*+,-./012345676)8)* +-./1$2'3*5265789@:C;F=N>Q?TA\B_CbEjFmGpIxJ{K~MNOQRSUVWYZ[]^_abcefgijkmnpqs4 56(989*:8;)yz {| 7'(% <)  8'(W=>?@AY??BK* YCD<)E*2FG*2F YHDزIJ>?@AY??BK* YKDIL>MNAYMMBK* YODP*2F YQDIR>MNAYMMBK* YSD<)E*2FP*2F YTDزI)~"(29OY_go!(>HNV4 9'(:=U>MNAYMMVK*$ YWYXYZ*[\Z]D^Y_SY`SYaSL=>*,6+*2+2F  + YWYXbZ[]DIc>deAYddVK*$ YWYXfZ*[\Z]DIg>MNAYMMVK=^YhSY_SYiSY`SL>*,6+*2+2F  + YjDI)% $*K_ais -/HPZgjmsy4 :'(9yk>MNAYMMElKE*mF YnDoN Y-qDr>MNAYMMPlKP*mF YsDtN Y-qDu>MNAYMMvwxLh+mF8+m YyDzN Y-|D}>MNAYMM~YAYSxLi+mF8+m YDN Y-|DADpQp{hk{)##/9A DE QYt "%#$* +@,L-V.`0h3k1l2x64 ;'(>MNAYMMElK* YDM Y,qD>MNAYMMvwxL+ YDM Y,|D>MNAYMMPlK* YDM Y,qD>MNAYMMwxL+ YDM Y,|D>AYM, YD>AYM, YD<?pL{p(+{)+@A#B*C4E<H?F@GLMTNsOzPRUSTZ[\]_b`aghij l(o+m,n8u@vVw]xgzo~w4 <'(B>AYwKM YDI>AYYAYSYTKM YDI<>AYwKM< YDMNY,-^:<>AYYdeAYddSYdeAYddSYSYTYTYTK :< YD),G_b)#),-7?G_bdfkoy4 ='()4 >'(YK>*E YD>* YDYL>+ YD)B!+3;DNV^foy4 ?'(YK>* YD¶>* Y÷DYLĶ>+Ÿ YƷD)B !+3;DNV^foy!#4 @'(OYKǶ>*ȸɚ YʷD˶̶>*͸ɚ YηD˶)* )+,-#/+132<3F5N74 A'(-ٲ϶>MNAYMMK*AY YѷDҶӶ>MNAYMMK* YԷDҶն>MNAYMMK*AY YԷDҶ)B>?$@=AGCOEWFsGwHJLMNOQS4 B'()Y4 C'(ֶ>MNAYMMך YطD˶ٶ>MNAYMMי YڷD۶>MNAYMMך YܷD˶)6 ^_&`0b8d@e^fhhpjxklnp4 D'(Qݶ>MNAYMMvޚ Y߷D˶>MNAYMMޚ YD˶>MNAYMMvޙ YD>MNAYMMޚ YD˶>MNAYMMޙ YD>MNAYMMޙ YD)fvw&x0z8|@}^~hpx >HP4 E'(>MNAYMMK* YDP*2F YDҶ>deAYddK* YDҶ)6 !'1?IQYrv4 F'(8̲>MNAYMMK^YSYSYSL=*+ YD>*/6+*2+2F  + YDҶ>deAYddK* YDҶ)Z!57>HPZjmpv|4 G'(>deAYddK* YDҶ>MNAYMMK* YD*2AY YDҶ)6 !%/7?X^h4 H'(O>YK*EEW*L++w MM Y DI#7: )*  #7:;FN4 I'(oC >?@AY??E K*F YD)  $ .9B4 JK(2*LY+)L'( )MN   rJava/inst/java/PrimitiveArrayException.java0000644000176200001440000000044512256051770020714 0ustar liggesusers/** * Generated when one tries to convert an arrays into * a primitive array of the wrong type */ public class PrimitiveArrayException extends Exception{ public PrimitiveArrayException(String type){ super( "cannot convert to single dimension array of primitive type" + type ) ; } } rJava/inst/java/NotAnArrayException.class0000644000176200001440000000104212256051770020141 0ustar liggesusers."     (Ljava/lang/Class;)VCodeLineNumberTable(Ljava/lang/String;)V SourceFileNotAnArrayException.javajava/lang/StringBuffer not an array :   ! NotAnArrayExceptionjava/lang/Exception()Vappend,(Ljava/lang/String;)Ljava/lang/StringBuffer;java/lang/ClassgetName()Ljava/lang/String;toString!   7*Y+   "*+   rJava/inst/java/ArrayWrapper.class0000644000176200001440000001314312256051770016670 0ustar liggesusers.    H G G G G G G G H  O F   G G G GJ G 9  G G  isRectZtypeNameLjava/lang/String; primitivelengthIclass$java$lang$ObjectLjava/lang/Class; Synthetic(Ljava/lang/Object;)VCodeLineNumberTable Exceptions(I)V(Z)V(B)V(J)V(S)V(D)V(C)V(F)V isRectangular()ZisRectangular_(Ljava/lang/Object;I)ZgetObjectTypeName()Ljava/lang/String; isPrimitiveflat_int()[I flat_boolean()[Z flat_byte()[B flat_long()[J flat_short()[S flat_double()[D flat_char()[C flat_float()[F flat_Object()[Ljava/lang/Object; flat_String()[Ljava/lang/String;class$%(Ljava/lang/String;)Ljava/lang/Class; SourceFileArrayWrapper.java | java/lang/ClassNotFoundExceptionjava/lang/NoClassDefFoundError e S S d KL MJ IJ bc NO SNotAnArrayExceptionprimitive type S PrimitiveArrayExceptionint FlatException[I a O Oboolean[ZBbyte[BJlong[JSshort[SDdouble[DCchar[CFfloat[F faObjectArrayException[Ljava/lang/Object; PQjava.lang.Object {| java.lang.String[Ljava/lang/String;java/lang/String ArrayWrapperRJavaArrayIteratorjava/lang/ClassforName getMessage(Ljava/lang/String;)VRJavaArrayTools getDimensions(Ljava/lang/Object;)[I([I)VarrayLjava/lang/Object;&(Ljava/lang/Object;)Ljava/lang/String;isPrimitiveTypeName(Ljava/lang/String;)Z dimensions()Vjava/lang/reflect/Array getLength(Ljava/lang/Object;)Iget'(Ljava/lang/Object;I)Ljava/lang/Object;equals(Ljava/lang/Object;)ZhasNextnext()Ljava/lang/Object;start incrementjava/lang/ObjectgetClass()Ljava/lang/Class;getClassLoader()Ljava/lang/ClassLoader;=(Ljava/lang/String;ZLjava/lang/ClassLoader;)Ljava/lang/Class; newInstance&(Ljava/lang/Class;I)Ljava/lang/Object;cast&(Ljava/lang/Object;)Ljava/lang/Object;!GHIJKLMJNOPQRSTUu*+*+*+ ** *  * **+** *(*=* *Y* .hV>"# $% &)'1);,B-G.O0T1_2n1t5WSXU&*YV8WSYU&*YV9WSZU&*YV:WS[U&*YV;WS\U&*YV<WS]U&*YV=WS^U&*YV>WS_U&*YV?W`aU*VFbcUs?* +>* .6*+`V"M NOP%Q5R7P=UdeU* V\faU* VcghUz*  Y* Y* ** L*4* N*!=6-+-.O*"`=+V6 no%p.q9s@vGwRxWyazhyu|x}WijUz#*  Y$* Y* *%%*L*4* %%N*!=6-+-3T*"`=+V6 %.9@GRWahuxWklUz&*  Y'* Y* *((*L*4* ((N*!=6-+-3T*"`=+V6 %.9@GRWahuxWmnUz)*  Y** Y* *++* L*4* ++N*!=6-+-/P*"`=+V6 %.9@GRWahuxWopUz,*  Y-* Y* *..* L*4* ..N*!=6-+-5V*"`=+V6 %.9@GRWahuxWqrUz/*  Y0* Y* *11*L*4* 11N*!=6-+-1R*"`=+V6 %.9@GRWahuxWstUz2*  Y3* Y* *44*L*4* 44N*!=6-+-4U*"`=+V6 %.9@GRWahuxWuvUz5*  Y6* Y* *77*L*4* 77N*!=6-+-0Q*"`=+V6 *+%,.-9/@1G2R3W4a5h4u7x8WwxU"*89Y* :* Y* *;;*<=L>?@Y>>M* *<=AMN,*B;;N*?* ;;:*!66-,2CS*"`6ߧ-WjmVF@A"B+C6EAFWHjInK}MNOPQPSTW9yzU{D*  YD* Y* *EE*FL*4* EEN*!=6-+-2S*"`=+V6 bc%d.e9gAiHjSkXlbmilvoypW{|U2*LY+VFR}~rJava/inst/jri/0000755000176200001440000000000012256051763013065 5ustar liggesusersrJava/inst/jri/REngine.jar0000644000176200001440000007714212256051763015125 0ustar liggesusersPK"JC META-INF/PKPK"JCMETA-INF/MANIFEST.MFMLK-. K-*ϳR03r.JM,IMu ě*h%&*8%krrPKXECDPK "JCorg/PK "JC org/rosuda/PK "JCorg/rosuda/REngine/PK"JC(org/rosuda/REngine/REXPEnvironment.classTSQ=OpUQK1KDS!jeVhN6~[autap`339S}joAڥ={_}0 =7 |S"1#AD܇Y>OL9"e SZ ¡ffu@H;ǚK?3%;oFiaJiFohd*%4A6'Aڍb<5y%D9VT"Nr<aPnm,%"v6)LJ}腒7 qfV,99k_(h]_Hi*oLqݽ&^VlenQ'K2z'.x%#e%QNfˌ6fuYu|gN@]gNex2D]_f^vnvFޠ̒TTF# tҔD ׼̼Tm퓕X\Rn_Z\4ÐD3@Fg! ҢTLriiIAig^IjQZbr.FMFi`d@8?)+5YX4+fg02pI&.PKD\bPK"JC)org/rosuda/REngine/REngineException.class}PJ@}IcւKm5?"x(qb̛y;o||8¦ -5X` H%vT'N)/!H%ScYc|x8* G*̳tJZ.۱W|<#IDUtQ8SDe2UmuX 1v>]ΤKFe6V(:T6+XT !2z cX%٥Zz5PK ӁF PK"JC.org/rosuda/REngine/REXPMismatchException.class}SmoP~`t2/X ͗O]'6/vıD?x.lrӞs{o?kt\Wn▎*s*yP2RuEPjI%q:r~cj/Ҕj(2 @UQ(24 Վ{qW0Zw8wDwzB*N?T糩u\h/BsY´ϥa/21l̲EbBR@2'&iÎ]QljPRԇ&.`b  FPO  ݱE[}G<y p1Bœ Rء!pNM vi|[Qah֐n߫b06>9'_TOe>yE_Sp RWSpgvOVp; Nrw9C)?_ SqHK*8⤊S*W*>T3*>Vo'18OU+\bQ57$!hc#VeO8rb}@;# ~<>oU$sy OP[q9Ҁr- ׭pUAjQx)1#cEJLLAiCjWdHTzFͤ:u"$eH)wLl^w`"6teo  CH[Z̴g;bZWe}u%UKx z6#.àpG#89v'H+)n? D9ԺYM:RT})z ڀG)Ui~_ǝXΰ?k岸\:yą֋Oz%wpy]u5a]t|K\;fbH3r2m:Dɸ}aK4oc.lai =Oe\2!$1L:G(x:"_Dltq^tɘQ)]m}=!:s=IuuY|.Q'v׆xR=,:|jP䏛5@G=#c>]by V"'KA#Zu4t(k bi<)"nʹMǢ!'(~9CoXN0W$'qǣD7R 5`iљ Su4Z4jRjBvhS)RD-t),Vg:fdFxD!cP*}bGKUw`gܙ~_/57d[ z:+1rx]W1XfR3-PH+X{R>_NZ+k|-NAN^*@yo%J4p6pFEuW v霓 e/{w9jmjj\~F47C-1 ޮEll,ciUeDԛm~ĕe h?{3z 9KW3z>Gx4y?5xp^f h@KA/URCb8oK4Ka͠fr^e,jD~ -I Waǭch82ƴmx<ښdI-I֌$H~+ls\t߈QC[̶цse+3s~-3NaF:cz{T*=0dݙF!|٫ ShhܾŽ 1JZhĝJkX%qÜBp Z܈ dN$W M<ږd[5tfR&2l:dT U?#teoтn-5ILi.-ibM텄@ \VDT*dQK7m9UZ7VPE]CIJ y%,f1X`9U,^Vlֱ[Al`m&Ylf(xc4Y x}U<-)!ixFJN7Að[쓦U*R9ڤ98 9qPp K^㈴ K )!܇8&qޖNt HgpR"ޕd@ sr!>\[p^&₼_KqQpI~[pYގݸ"H=('"a|_2]ȺɗY-=Y?KA ~1P"k**teX`&RBEd`}^oiƲ7 2Er3^kEXok+pW  ۑ0z׼p+QK䳈n̾=s= HE/ _ 1C0iG8(@&n\l80n#Ik>X:|/iJPKS[ PK"JC!org/rosuda/REngine/REXPNull.classNPå,x &ֽƍх!huwRۤʅH4|(L骱=\|Ϝ~||8F M6:Zeֱ#*Wgy P8@m\{m^CϟYDSi^3"? UpQ8sr{fOXA. ¾ y=iPϜrˑZ["b_*ޭk#& Xc.'ZUPȟȖ('/Kw hB > z ȥY$kc?8l  ץF?-QxKѬzZU*- PK=fPK"JC$org/rosuda/REngine/MutableREXP.class;o>NvvvFǒ̤ҒTF= IJDļt`p^O~Q~Q~qiJ~k^zf^* cd /-JNu--ILIadâIP>6FF&`dad`f`X$PKNBLnPK"JC#org/rosuda/REngine/REXPVector.classQ]oP =Bl]¾cOiR4!&`!]B.҄_xi%@~N2!u*"lc_9<fb:6Lh9)іm;vےihʏ0Hf1A{:L/z*~nN Ӿy\k7&]-T'2 iSvvOF%qrϽϞ3B.a6^^_GQWܧ*s}Pż u,&gg*=<$Љ|,U4)B,OK {MA757b `jV[W|:HTç&{b=}Pc[t(@ε;c֚jpuE#Y[YrѷR(i_&l^Q^*f~hnjbD/h2.Dߡg"#5PpjbL]D?PK^NOPK"JC org/rosuda/REngine/REngine.classWV*~#n&m:k:wcA#Ya([E 4++1`ՍnsJ/|p(xO={ÿ%cYĊKBXe˓bUe "Vc6۟b -N =v"~ iPďZǏE\eObD31]_xV_k@3 FιBp(ͅȒbqG a&bX[Vt@Qr~`xGO.N:C:iwmwϿ=7CݴbގQJ$'1S\Gz&Dڟcz ;Í5 wD?D{>t{?Ʈ[OZ콆(Q`NSM""Ci:k㶡hg4Cø Wq]_x5]Br" l`3CGUJK4uIګNvgCzn!tܬlؘ-ӑݽFJPKMM|z{[PK"JC7org/rosuda/REngine/REngineConsoleHistoryInterface.classu 0Eojm8.;PZpm )%4-k~%6`u[.=ޏ' SYeml6]7^ xqRъ)A3kfe19?Ȋ,՝VzIYnn,k΁"Zx>>ew PKe1PK"JC*org/rosuda/REngine/REXPGenericVector.classUSg-dòxI KHjBE%,a1٤FEm׾L3S2uڗvO}?%+ژ0 ~|A|1U4 ֈΈY )8/ /{qAUxpIOI! bL ɴ W;`VEеᚂ7Uto*{&ż` f\Ԙ^,) %A˩>/=%L0G'bVҴDLE1=65] O=lWq9RXX0}'4|5 aI3 G3"4| U'xFGz{eؽu.VԯS}~̧u;1!*&Ƿ|XKh v_55bp:QȺml\j';ڦDƲuʟ7^\>PFH}65Wԕ-P{B ̚;*qd2%95,=QDQ{ivyGm#&J|Mc1Zn=ZX/OTĎhtɫ.-"Z=~oh{~RDk^qK"?gmm:__v刟Wdmj {??x MB#09^X^:ϲpxה}xQd<ʿcwz|uF^4*u\mw;Gձt"Zioc:n ut.+T^{}]pvSVĞj #Xk,{+/:p{_@ h:,"Et ~ BBUWg& )rcJ, \IQNPK~ PK"JC!org/rosuda/REngine/REXPList.classUKsd=-G"&M8[ 8! }%MC\ҚQ%wRvl,`Qgf^Yucgܣ{?73UqY*8k2s*qeȸ",#]N;{GA^]r5> =n`ee/ jƖxVd5ed֗e Y˶%xte SxQ-Fi"W)Y~aM.&B~xdd )uˮxY5\yJfOݎlAwؤYL9:ZI0r  YκYn! #ڭv vkR jz\X3i\E| 0~^}(0GD3MpGWT6mn7HZ/iБ1fwhlo{s>5:P¬@6&~zss&-kMHABE ;a$i:~!0qyȯ}}w-j坎7OΊbǭ3;vWɱ>o$F2P[Vl=Gz UT5)G}j>rM \o34D_3 ў@tC2X@b CHϐ~j㴞"$WKQ1˴2O9^H$[BF{菸7P8p.jwL>M9m>j)>|.r/eXir0H)R/F͒44 UUԱ8W$/XPK[d`"PK"JCorg/rosuda/REngine/RList.classWkp~Nl.K.KIv7 !" Y%AE YjdF[o^JkQ7ⴝmg:љZgcJ|'ˆG;߹y9Wo0 Q;dt>E\+#M.=2r^2yC yăGe1<.# L xO yZ632z@v#B'zM<8ZB~ x/_Nj|Ƀan/W cx8&'}Ń؞xou}taK|W:}BD2*nQV: x[M]\ m[lNv6Iv+/PZou()S]]H%5s`luŒ ݉d>n 'ɓi{:RȋrOB\WR+ӗ,SZr[fG 0::.ӕu9im>:GT3kӽ+TyRQ7w( I틏Afp%z\]_OD'ޝ6 cE4M22FYu1 ŻRIѬlK{8ˇ]% QΥCN1˵tIs_ڗAnrfDbkA G%Ny̆lmLv_Re6/5^juyʜmK6/֋7obȋKaEl9℈zxDU^|ۅjHhb'vy!gN]=doq{_F &ȈMkc=2в^/ҸE/7ũݻRzF8ŭŋ6gwD ?έ %# 'qs\7,WTO&;7=A`a|~yp/O5 N jv`!?5H0JC'*+c@}d!43 =K]j4,P8h9sy8y,'rk#'`"rV FhvEuE}.Քі. 2(G3╞B+I[ VjS&hϳvװ2̠ܨdkwg/# FLM})p39q?ukZxf>"xF/@1nޝMg$,7Ṳ [mT{Li[vz$nޛDktH0 RË m&p Re=0 cG J8{av'F-\SFFp.Vg=bЎkNGXϠ O:DpWg|hT@3z +}-OjkH8jgLʷ9Δ,i5L״`U"28}u<յyzAyCϬZ< vbJmJjٍ0M1j!+d0@sFE.ST]F=}!9YQOO>Jy:޶Z]QZ` * faVn~6Y,O+#ʴ gԼ&gc+ j}9/_b:~ k7olMuS/ߓvZ:͔'`\f;?%M,]v'H$ݓ͎ZÜ/3ğHYވ5=3('B-e{q1>wEj7`2xdrA6۲Zm'j樊*Ҙ_>7(طivsYFOUَ|v 3|ɍ_4Ae2~{ O7K?<+9*BTqA*  t ~Uj5,ۏEDu]UԮ1"52y-6<ej]'X0_mqT#m` y$AwJ28%R2TrvQ*0KU)WSHUaZf*_|j:v@:_A5[{c Q 7>'ʾ FBգR5FGP5bjBX-"2u\J={&t~$U-GjOEtEW|YΒRg\KO`R}dWR~|dQ[^*[q9m" PK W 3PK"JC.org/rosuda/REngine/REngineInputInterface.class;o>NvvvFTFg tҔD ׼̼Tm퓕X\Rn)_Z 2R 33$(-19UAm'e&120201# #3 $PK[I;SPK"JC-org/rosuda/REngine/REXPExpressionVector.class}J@ƿMbbcl՛ ?bsO㟕gjybeQ(vN 62gOY, 9s U7K|\CP.w{SWz ,rND0ۘO4 ޠȮԸ&i,PKMPPK"JC#org/rosuda/REngine/REXPFactor.classT[sT%[6m.M⤗uhzbJiP8-uLQ\eWk~î$\0{v>PE|ꮂSp_ b*>ѐC *ʌ~> XkXWXyl0s^mRS_(x&hGf8[GFeŪӵr tbcvj5˸ն;z9$S|k T(ter3<&tgvsaE14 T^ 2m2}l&;acl()^7|D;f8G`}+aU "ٴj0,&u;X 鸌y^tl_X!y}DD@:Wx+xe6|vxб Yqヽ;3 q u4B@yag.r1&4FI./0|~yb~ZBߋXՠä_J{-M]e"&p

h C|0An8pXˆQ c}oK{35 m[K|6h|v;m k!=-351mfF/,iy1\+6 T,ִ,^(Z6˛Y)3HFaڎG V\,c[Mw3u㥢K.b5 -&e3lHETXo<'X!L24hA+@hZi}]/ȸK21^Ș2*P'$^2tj'ŗAf)+zh[[z'Qk>rP27gvs-}^ͣUQgO{*li=6`q<+ {tl! A~֥C6]G@ ]j $xD+1F<'Oh|;!om9ZGN۶ #u=o[tqu\h/nl/.;^Gf"jej{"CTvTxqv+/[_Qo'@BD>@X $) trvZ߫k^: CYCb Ʊ 1I>,PK&LPK"JC$org/rosuda/REngine/REXPInteger.classTOWfg_.+ eUb b]* U2̐YӦi҇&/L /}ЦBR&wY$r|;9o`^k]$R\#(aJLdSpU|ŵ(G1A9 㻺c)-Wh)Pivl3loɨ7M劐drvZ9\_1:= ˶)-,AUQ+6f5rNr% w'XXylz 2cuî}o]Qf܊5!=̆ nF],+:niRt*Kעװ]tK>S6W5ߪr_tUs: @ tGnJu DEnb/"{UM6zysB X3d0m>|XO9:ݱt׍oT@$M > (rC}ҭ3s4@u2C8`lHk f>'Y>FfVG>V8*9)s'RU'Sr 'uK~SHOdpQ-r@#\ɧ]zCzIFkl!c? ]s2#},Z~MY$+~uޓoOIv1\e?|3 w@3_4TZNg8z$侾}Y],' I&x>Af(o%ܠ*5i >PK8kPK"JCorg/rosuda/REngine/REXPS4.class;o>.fYb✟WZQ/J//.MIrK>% \Eɩn `IJDV6 Ô`Fqr @7#0 iF ͪq#$ `Pr@L 9- LjA$xnPK2>G -PK"JC&org/rosuda/REngine/REXPReference.class}WGƿf7Th%Fcc -if6C7-f}_}ɃxNQ9nO3@9CUnߺ]>ԡ;yIFr1ꘓחcȣ ӞEE\.rC+"D^yMu7DyKmwDyO}t|Cf}'~gQ|._RW-'53=yPL=CNvWCmt9KCs9oL'sz8[ nnJO"?#ڎp ֒.9!21Id8;m'i mMgcbAj\#̛9;mzDb@lZʚl)Svᬗ%d/j )}񬌕wx.[ )-%I7cLۅ!gλάxO!4͌UZ[3e؅ fY4㘕* |ߛb .hT"٥qI;Qn-2 ? >5$2KwQ;CҼH%er՚˦nWe,o$(ԍ+ %@Uܥ]n9Kgb>e !Ӽ_pp~<<hhXvt#GqPǷ!_z.̚^*[.C P udO9' EDEDENI9g LଁI!.> fYb ___\䚗Y\b✟+MJ- ILXшU5"n*WfOb^zib:$f (Pp~iQr[&pAj IJDV6 xx `f` $ف<9& d``bd4PH-'T

Mœr^-sڛ 'Q*z詸l-Δ5DDPcF:$xnU?zLpݞ:gҩ FT+AG¬U!)΂ЂJs1·o" N. !pI(Dhc 5!'8fzk{ӇaG\k>}Ub@%|C,Z(`RlH8& G9KAi)16Ԅn r]6S\_&h$,,V iyDRޓ04,'A B],xHY0e`$ͫD?,ca`.ZG,M3RF6h*Ղ geeܤ/+]ݼbs;G>|,Jf>9S\bs{2-Xćl/ L [ʞZmϰ*UԮvgNMdK5-ŴqZOB4ۍb|(k)# 3M / ڑՏkiXCdPʘa4,]f 8Up7H*a7GΧ3<e$ujSt%ʪĵI_CU\[䯵TWɧK]-$U\-iwrHwW tOrHV 9[+k&դ*[K Ho@n=ivHz_@n;)OV[Y㐣ac 7K8H*dxC]6[k 4 o(t N _fZlS4'wsoI\-E,E jLn&d[Ul9 "pj5 )Hg"ӳ:BrC2a04S+]O 2aRys}0j['1f/< ,3nE0 >2znvNv.F ĒTF tҔD ׼̼Tm䜑_ꖙ`WCOVbY~Nb^~pIQf^5ҢdPy%Eiɩz = FR ?)+5XX4+P$PK< PK"JC org/rosuda/REngine/REXPRaw.classPKKQ=w5e,Z٢VF  \]uiQPn~TQZ"=9ޟ1}dCa-/RZ#{&o3H2|sS\{b5HE7jY7٣*)ZobUEؖ{q._6ZaJbdZb]}‹"DyO@_T̜:ɘkޱ.x*g}B*C\Ϗo=_gx ܽ0ex(+A2ҾMwG,th6RfZGvIL)VRWIaLq>:$1BL=$PK?TPK"JC*org/rosuda/REngine/REXPJavaReference.classRN@=ȣV (ŸŸ5jƸ(04%ڒR.MM?x4=̝sfܙϯ;ؒ0d,`Y(VELE&zl2b\P՛zAܙi>CRN_32gL6ܹҋc(؎sz.,<o fZYWOulF]uL:YIv)cS6)6 ^J|[XdA1`i:hT c324d؝ Y"^am!05@TE+?k5nj{)> 9VQ#cSkaP*2<{ °<}O:HqX˶k&15,P!'tp$!PW2D6mm[(Qn!H[/4M8K1oPKPK"JC$org/rosuda/REngine/REXPUnknown.classQ]OA=]׵ QZJwLjjBBPӦaegɺhO>B&陕',i6{ϙ;;g==T ̡0[Ӱn ZQlCGQaIGYᦆ- oRu /sVrD8:4}~a91S jap18G 맦UQ;n*lGA+ } ,XszjOٺ {Y!+&6,ݮX+4]8->IS ڰ<T6;:6xvQct_^'^bu{^E*K*ZTPƃF#XM iT̨ b.ye^&/)(1F>g( j粖gi=S06σ}ԥ(&<0-$8-16ef#?/dh 1+ӎ?'|8Ks\>ݙY%sB6M(3SeNs:2F6mR'xirisQܖJ֘nw]}|ᶱh+'RtcQ֭Q&+m-!=1OĠn ܳ tk0Wm]Ӡ4My32lRNDkZ2)/J4ƢnKιhsB!@U/'s1d:$9$Z/I^ZpP7s`+ 7oq!:F v ,FML~{GW)hy^ uj~4:rQ KЗ,Nbu^2+aHߖ;Z>ij/!Ʒ̵GZ[biֲ}Qϯ!DaZҦp4A |o[s ȳ: $݈.jU(Iߚ:9<ߕwB<jl-HE9ԕl1RnwO0VDhWk*h[  pVqUDzWTBh{6?BS{xbZx߸؟&C# A0cyQvC\i!j:erqIuRU.S`jgdeڥ̫"tlS0Olwο@ Q~)?]Ȭ[E ?_;6Z v"Z bc_"ErMۮ5" CeH#MmL ?طޟ&>]|F!34PK+@ PK"JC org/rosuda/REngine/RFactor.classuVksU~6tY@ imPv7m"` (`I MQ//00#^3 *qf?@gA}޳KRB=gy'GDxLִ2ƀa#"TvO1&b}&tSavN{p ێq+Mu<@v+N^X`;I&+kM@<&;x.&>.P7~V\1 MdW ൺ?Q>W*uo*βT`VP1#${\F?S>5]PK 5u0 PK"JC#org/rosuda/REngine/REXPDouble.classTMWe~L20jK&B@B):iLOpItڕ+.ذqbtΝ3Ç9}}s?Ϗ\ĊkxǿB+UèƄ6 `BEAL 8#mJ"#,7E`6 f@yfݜyKP֍ϊ*n9#;*AdG v_SBE\TŸjJhJf3FHK`P*\ #;)3V9?P*Uc`vg,Lb @,%≴Qv9e<4s[B$<@(\됄Uraʼn&ŐQIYU2 QjT%̛eϖvr)Jp>RfwT+E d²9Z^1' AbXVa5N Іv-IhŗRk޿o%@,㮆pEC5+C 9 !tO_ 4:ʼ5k|HY(ܩWX_7Kdx 'mk2qÚ3m7]i*z[Dk|ãvVt1V>I.kzҫgRuCoț}RB%pg/^EZ}M}ɻʒw?Dr[ IBD'7Z$8/v&_JY@d%~ .HБ )Ea<-W5{m_~_sq]yur-s:亦Q鮚uͺNC? 3 $J.vM[2"`/;X?#x[6p47pjIDW_C0S D=.Yљ$O~PHSo[nzA#}j"izbѼo]!*<\`=$Izb@d؄D =撾=Egvp ι ȇ:~AaOPKEPK"JC)org/rosuda/REngine/REngineCallbacks.class;o>vvVv6FҢT̜TF ׼̼TĜbIJDFtҔD}}t  9yIY%@ H21PK F;kPK"JC#org/rosuda/REngine/REXPSymbol.classR]OA=neiqK"U @D|0JH|e%[/>hmWN KMxسws;ϷTE HbI-*bXPqEIJ`E !cM]-A>ghr2jg;V!v`!S]' qjvjU7=^o~}6["1LK 3|q^p\C}aps|E(gFm|iRS[ovŮ\ :1@0L` SǦ'c]}sS!A&Iwq~zj: q|w[A\ CD"biiZ+A# "'&%T!a3џ.(?cWyD?Ru9\.AդBP +2# A;"^@@ Aha/yU^C.&/i$z8OxS PK?#&PK"JC META-INF/PK"JCXECD=META-INF/MANIFEST.MFPK "JCorg/PK "JC org/rosuda/PK "JC org/rosuda/REngine/PK"JC"(>org/rosuda/REngine/REXPEnvironment.classPK"JCD\b/org/rosuda/REngine/REngineOutputInterface.classPK"JC ӁF )org/rosuda/REngine/REngineException.classPK"JCz.org/rosuda/REngine/REXPMismatchException.classPK"JC|kU-d org/rosuda/REngine/REngineEvalException.classPK"JCP)* org/rosuda/REngine/REngineStdOutput.classPK"JCS[ $ org/rosuda/REngine/REXPWrapper.classPK"JC=f!borg/rosuda/REngine/REXPNull.classPK"JCNBLn$org/rosuda/REngine/MutableREXP.classPK"JC^NO#org/rosuda/REngine/REXPVector.classPK"JCMM|z{[ org/rosuda/REngine/REngine.classPK"JCe17#org/rosuda/REngine/REngineConsoleHistoryInterface.classPK"JC~ *$org/rosuda/REngine/REXPGenericVector.classPK"JC[d`"!**org/rosuda/REngine/REXPList.classPK"JC W 3d.org/rosuda/REngine/RList.classPK"JC[I;S.9org/rosuda/REngine/REngineInputInterface.classPK"JCMP-9org/rosuda/REngine/REXPExpressionVector.classPK"JC#R#_;org/rosuda/REngine/REXPFactor.classPK"JC&L#G?org/rosuda/REngine/REXPString.classPK"JC8k$Borg/rosuda/REngine/REXPInteger.classPK"JC2>G -vForg/rosuda/REngine/REXPS4.classPK"JC6HBq &Gorg/rosuda/REngine/REXPReference.classPK"JC$5%!Morg/rosuda/REngine/REXPLanguage.classPK"JC)  iNorg/rosuda/REngine/REXP.classPK"JC< +Worg/rosuda/REngine/REngineUIInterface.classPK"JC?T Xorg/rosuda/REngine/REXPRaw.classPK"JC*Zorg/rosuda/REngine/REXPJavaReference.classPK"JC~U$\org/rosuda/REngine/REXPUnknown.classPK"JC+@ $^org/rosuda/REngine/REXPLogical.classPK"JC 5u0 ,dorg/rosuda/REngine/RFactor.classPK"JCE#jorg/rosuda/REngine/REXPDouble.classPK"JC F;k)oorg/rosuda/REngine/REngineCallbacks.classPK"JC?#&#oorg/rosuda/REngine/REXPSymbol.classPK&& MrrJava/inst/jri/JRIEngine.jar0000644000176200001440000002404012256051763015335 0ustar liggesusersPK#JC META-INF/PKPK#JCMETA-INF/MANIFEST.MFMLK-. K-*ϳR03r.JM,IMu ě*h%&*8%krrPKXECDPK #JCorg/rosuda/REngine/JRI/PK#JC&org/rosuda/REngine/JRI/JRIEngine.class|y|TExUB ;@CI8*a&N0ޫꊈ+(rH"zc=r[ޛL?>twuwUWWUWU}' Ϸ VY*^),ڊ~ v-)+\&V!髓ގ ^ZxԍȂK; K퐎 ˥BIqWYpF^-υ5Һ6͊zYzoviЈɂ퐋7[q&-⭲V+&3&nB΄nŻ0}o{d++}Vߊ;YxЂW wK#V|T#^gvXY[j ia;'GxT-x̂ڡ`!K_z|Q,xŠ/ˢHk |M_7xSdo߱50(:|Od2 Í; 7G"?Yϲ Wi>֧R|&_VFoCR|'R A"+)VR@v5D6[!&E`%ˎ[H=d EVJR/if#4i9F}e~8N-4/R: 5l!2>TIkF8 )E2-`/*+, VB5޺:_BbIaqR,DH꽁EޚH,3BKqay /0!E&Ҳa+kTyiA~a^cY + K++3A/ng$HO-+J%&CPa̞ TP*C M)XRF``v ! TF(;y *+cazeyM/BBDp!|4CP?`515!A`?CR  5T{ǔcXg@SP7zL)'ت55+UkYûhice}"8;SyNr@n1,% G׷Mo]m}>߲[[ZƠShDHG0=*²yy=,iX𮨑m\X嫭g g,+^]S S^VMQB]zWDb9Uf4_?՞;20t|d{`KGFK3]Fj:VSW'%\zo BIF9qȞԿ.8kH[SB`z_!L/(%"d@FQw{'0jag(J9bs?_M;cocֳ#񇂁uD8#>VRL6J )9\>XZLHl 5PJk "`;E{.y0WĆIF`_U}|Fڤ␿'?Xc8T+7PY ш4-TVG9On﫫b9?kzМՑ03y`Q⠷:ZU՘^lU&GhYCD}Ha&r:74)s>Fw!=sU@ Xn}վjw$~* ~=!)[095J,99`N [&#^ȍְ7i>5,I75!oQ4@F8qr_Qj>$yVW&kvj4[hF@3/ HJ E~%4$\u˜Ǻ[q0J\,M£a?쯡 {h8PZHu4n Z!fi4!.gBJ =ŝ!Ǝ>#wdn89LbuJuB`Hd:]h1O8$Rh󲾨.la hFsD7}$qtu)tD<.plip(Q|@j95Ѩ8$ 2O`Cx 5OmC},nM[1Ga$^v g+j[c?Pk*wnyodaq4N5TJlʨ/]FFhFKṚFKEŹV'[?2r5PۨkB(9, 3;tPjBvV2J-`FG/fO {4I5D˺}x7aO7ftZ6Mp -Y|dx ?8E\77"#yaF\VWfu:|Qb?.27 q8诓۶~HxܿN[!. ETjN7[m&^yf5L"35lIadl6,:Y:j鮯kj8?Ѥ$Wr1 G]F?X8&yugRtSWɉaqĽ2eP]5CvnMb6lD|x加x8ȕ WL0;5S Qse jk {F~~(iK!^=(< Wm<Mtɋ¾-`ӽZ^]tM\ȗߤ7l{#]sYniۋ}.z@[@xA_xIcQc_( F'Q ߢ/2 ᯣo6 ;3]/0) VV` (ư= v0EIdYX僀T׽1MG|]zj:ݬ ts=l8Ckɿ!Pe+(ޣc S\a $ZH.?`^U,H a6H9j%RZ! ReCQGbB9{P~AX; ebfBz{eORIQp(]% Ƭ& GVv<+(}MGj ZgA$XH>H"aL)}R{C[wIg(2LI@_ŭ-]LYuܹqE=ˤ~+X)s V|D ɘca QcFpHΌJS`fIJ8Fme0%;Jmj$rLnf-LLbӜ&+po=t*`;,`5!½p[~;UhfA0΀G1`!GZ?aj=׺hXƾs0 s0TN>̊~}}{p YXmvRp 9xc %/S78^IN7q&IcL%_JV?FY2NNvç(W6 Gճd@rP"}>IDYK;>+$+ɩdNM9%)d!pӏ9hUN7N2qJ=|K>_(g,3}IJ>1cs [ )h-34.|,Q9 !擳rZ`BI3$x,mc#9{8~ yX N L$.Փ'8Nx6Ʃl9 :%z xg!֦Ŏ3^tӰ9W;b9t#Vag*xbpu_:p6˻z\6ylEll9.UX "f.XV?m\-$8>c~Cxv"0kN$'kp uչyr8ͬV>B|RAS@V'=Wbӕvʖke5y$-MШcӴ-87ə$\gP\J]M`q&ZIOW68%a>~r]2'UaK}ǾQv9Z".G+ﱈ5A]T/co>ZUSq+&sYZaGXڞ],JEK忁F?f&[945Wo_5X;9Hsc*ezVW²@X%P#Z9m"qnYc))wszc2:_$VSCP[ JC wIg=w~lv4xl.S2ɑr٥QQջf>)WTlt:_?+]v)n5)^S|=vcsIr:d%ƒ*O2)9-Y -9WLVW1Е.av! qZڮVda2f𞯐ΟqM$ڝva&ഛ&_3bo+spdP2e`#;59=])$\6Wzq3͕"a:?ϵ79-!%ny)ӵQС_009H +}oީYV~s+&XD7U%scDZ;Z-Tϒ`xpZH/A|/XǶ[ӱz8ոsFNj9^R83F><@Bފt/$qc%>S9e)cyeK+។?R`DO7Ճ_3R;EiH8g W`uG9 !{[?pOLp5:n#K9ra9F~}?0!\R`0\/N1Ln܊}gc #$JwK+=Ӊ+2MF ʡMLn[n~<&UG4Gr ;Sf>-ha?Pts' zSk;=nѽ}wG=-CփeOfޔHVIt%ޯ]PO\F8 c=RFreǢKEuI4+Z^-WYI4eIczFca\6J8]ܖdgM_Nթٶ&b6@yؙnuxs Js|*—ʚ:5N뽇˚3P Mfq:LO9lTd!NGFx;3U%V!%No=Mej\Dw4T7A;+)$Mh_X̌%BȦ7Kӑ'I22@ 02:b'IÉ㹑dJ_D̏jR2acX)8MxobWcVgjTGN-;U,b#&gg-Ao]=ʍ#5uwؘD氭XVlFca4`DHrQ]v1l-ݯi$3Ryzr>b{"VGNIZnv>_w4n2, 4 ) /'L~tJt#̣MPJ7AmZrz p4a( #4h$I>e§_S64 }h41Acq"\i"Σ3&aR^+Ƀљx5M94o8L}w6O\ I"JH~FM%I h,*rZFTM i -ZZLxޥjsZN;|=Mt6 봂ާ*|A>V*Z8hB~QS2)S(̦2jhr mPnFe]]IG7)f(Gb.QNХI#>ettڤLڬN+i3u]UBڨGWUsu-]^BתMtq2]{/fx/~vO0o3)3db (z2qVvwV6syCY0Nzm #yn5v; wgr]D;:1[!%`q7g̤ly$'&FL͎}b<&ӹ}i<x눥fv~OK֮z}vBqB`zFC|w,=|B#mkilp/=tvs>?1Oth`ϣ^l MCb:b3ᘥ?y]ǸTF28Et2\[Du㭿'P@f< 84$3lz3 ^{쥗YЯ@;*J{\FDX`~to~t#p;$(g_ZU|Moacx˯MLS0vܴ|d6?ݭgj%{0G2/B%"43KԿGUE&VvmGϹȖڙ y_24Gv${JU Ïͣb.,5J,x)RX[Ew/I|Gr!͜oΙf쟿?0 Q@2]:uDѣ˜*WC@۴.Rsg#⚙HO-hL b{ҳrl˛^_, 5)P3GjiU:KjLźey+@Teӻ9Y0(m,ۓ?OzPtr򅥪2wLaMQ၁10a #᱁'0f`&USB@t[ ArrayWrapper_Test

JavaScript is disabled on your browser.

Class ArrayWrapper_Test

  • java.lang.Object
    • ArrayWrapper_Test


  • public class ArrayWrapper_Test
    extends java.lang.Object
    Test suite for ArrayWrapper
    • Method Summary

      Methods 
      Modifier and Type Method and Description
      static void main(java.lang.String[] args) 
      static void runtests() 
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ArrayWrapper_Test

        public ArrayWrapper_Test()
    • Method Detail

      • main

        public static void main(java.lang.String[] args)
rJava/inst/javadoc/RJavaArrayTools.html0000644000176200001440000030537112256051770017630 0ustar liggesusers RJavaArrayTools

Class RJavaArrayTools

  • java.lang.Object
    • RJavaArrayTools


  • public class RJavaArrayTools
    extends java.lang.Object
    • Field Summary

      Fields 
      Modifier and Type Field and Description
      static int NA_INTEGER 
      static double NA_REAL 
    • Constructor Summary

      Constructors 
      Constructor and Description
      RJavaArrayTools() 
    • Method Summary

      Methods 
      Modifier and Type Method and Description
      static int anyDuplicated(java.lang.Object[] array) 
      static java.lang.Boolean[] boxBooleans(int[] d) 
      static java.lang.Double[] boxDoubles(double[] d) 
      static java.lang.Integer[] boxIntegers(int[] d) 
      static java.lang.Object cloneObject(java.lang.Object o) 
      static java.lang.Object[] copy(java.lang.Object[] original) 
      static boolean[] duplicated(java.lang.Object[] array) 
      static java.lang.Object get(java.lang.Object array, int position) 
      static java.lang.Object get(java.lang.Object array, int[] position)
      Gets a single object from a multi dimensional array
      static boolean getBoolean(java.lang.Object array, int position) 
      static boolean getBoolean(java.lang.Object array, int[] position) 
      static byte getByte(java.lang.Object array, int position) 
      static byte getByte(java.lang.Object array, int[] position) 
      static char getChar(java.lang.Object array, int position) 
      static char getChar(java.lang.Object array, int[] position) 
      static java.lang.Class getClassForSignature(java.lang.String signature, java.lang.ClassLoader loader) 
      static int getDimensionLength(boolean x) 
      static int getDimensionLength(byte x) 
      static int getDimensionLength(char x) 
      static int getDimensionLength(double x) 
      static int getDimensionLength(float x) 
      static int getDimensionLength(int x) 
      static int getDimensionLength(long x) 
      static int getDimensionLength(java.lang.Object o)
      Returns the number of dimensions of an array
      static int getDimensionLength(short x) 
      static int[] getDimensions(boolean x) 
      static int[] getDimensions(byte x) 
      static int[] getDimensions(char x) 
      static int[] getDimensions(double x) 
      static int[] getDimensions(float x) 
      static int[] getDimensions(int x) 
      static int[] getDimensions(long x) 
      static int[] getDimensions(java.lang.Object o)
      Returns the dimensions of an array
      static int[] getDimensions(short x) 
      static double getDouble(java.lang.Object array, int position) 
      static double getDouble(java.lang.Object array, int[] position) 
      static float getFloat(java.lang.Object array, int position) 
      static float getFloat(java.lang.Object array, int[] position) 
      static int getInt(java.lang.Object array, int position) 
      static int getInt(java.lang.Object array, int[] position) 
      static java.lang.Object[] getIterableContent(java.lang.Iterable o) 
      static long getLong(java.lang.Object array, int position) 
      static long getLong(java.lang.Object array, int[] position) 
      static int getObjectTypeName(boolean x) 
      static int getObjectTypeName(byte x) 
      static int getObjectTypeName(char x) 
      static int getObjectTypeName(double x) 
      static int getObjectTypeName(float x) 
      static int getObjectTypeName(int x) 
      static int getObjectTypeName(long x) 
      static java.lang.String getObjectTypeName(java.lang.Object o)
      Get the object type name of an multi dimensional array.
      static int getObjectTypeName(short x) 
      static short getShort(java.lang.Object array, int position) 
      static short getShort(java.lang.Object array, int[] position) 
      static int getTrueLength(boolean x) 
      static int getTrueLength(byte x) 
      static int getTrueLength(char x) 
      static int getTrueLength(double x) 
      static int getTrueLength(float x) 
      static int getTrueLength(int x) 
      static int getTrueLength(long x) 
      static int getTrueLength(java.lang.Object o)
      Returns the true length of an array (the product of its dimensions)
      static int getTrueLength(short x) 
      static boolean isArray(boolean x) 
      static boolean isArray(byte x) 
      static boolean isArray(char x) 
      static boolean isArray(double x) 
      static boolean isArray(float x) 
      static boolean isArray(int x) 
      static boolean isArray(long x) 
      static boolean isArray(java.lang.Object o)
      Deprecated. 
      use RJavaArrayTools#isArray
      static boolean isArray(short x) 
      static boolean isNA(double value) 
      static boolean isPrimitiveTypeName(java.lang.String name) 
      static boolean isRectangularArray(boolean x) 
      static boolean isRectangularArray(byte x) 
      static boolean isRectangularArray(char x) 
      static boolean isRectangularArray(double x) 
      static boolean isRectangularArray(float x) 
      static boolean isRectangularArray(int x) 
      static boolean isRectangularArray(long x) 
      static boolean isRectangularArray(java.lang.Object o)
      Deprecated. 
      use new ArrayWrapper(o).isRectangular() instead
      static boolean isRectangularArray(short x) 
      static boolean isSingleDimensionArray(java.lang.Object o) 
      static java.lang.String makeArraySignature(java.lang.String typeName, int depth) 
      static java.lang.Object[] rep(java.lang.Object o, int size)
      Creates a java array by cloning o several times
      static java.lang.Object[] rev(java.lang.Object[] original)
      Returns a copy of the input array with elements in reverse order
      static void set(java.lang.Object array, int[] position, boolean value) 
      static void set(java.lang.Object array, int[] position, byte value) 
      static void set(java.lang.Object array, int[] position, char value) 
      static void set(java.lang.Object array, int[] position, double value) 
      static void set(java.lang.Object array, int[] position, float value) 
      static void set(java.lang.Object array, int[] position, int value) 
      static void set(java.lang.Object array, int[] position, long value) 
      static void set(java.lang.Object array, int[] position, java.lang.Object value)
      Replaces a single value of the array
      static void set(java.lang.Object array, int[] position, short value) 
      static void set(java.lang.Object array, int position, boolean value) 
      static void set(java.lang.Object array, int position, byte value) 
      static void set(java.lang.Object array, int position, char value) 
      static void set(java.lang.Object array, int position, double value) 
      static void set(java.lang.Object array, int position, float value) 
      static void set(java.lang.Object array, int position, int value) 
      static void set(java.lang.Object array, int position, long value) 
      static void set(java.lang.Object array, int position, java.lang.Object value) 
      static void set(java.lang.Object array, int position, short value) 
      static java.lang.Object[] sort(java.lang.Object[] array, boolean decreasing)
      Returns a copy of the array where elements are sorted
      static int[] unboxBooleans(java.lang.Boolean[] o) 
      static double[] unboxDoubles(java.lang.Double[] o) 
      static int[] unboxIntegers(java.lang.Integer[] o) 
      static java.lang.Object[] unique(java.lang.Object[] array) 
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
rJava/inst/javadoc/ArrayWrapper.html0000644000176200001440000006321212256051767017225 0ustar liggesusers ArrayWrapper

Class ArrayWrapper

rJava/inst/javadoc/package-summary.html0000644000176200001440000002301712256051770017665 0ustar liggesusers

Package <Unnamed>

rJava/inst/javadoc/help-doc.html0000644000176200001440000001673212256051770016300 0ustar liggesusers API Help

How This API Document Is Organized

This API (Application Programming Interface) document has pages corresponding to the items in the navigation bar, described as follows.
  • Package

    Each package has a page that contains a list of its classes and interfaces, with a summary for each. This page can contain six categories:

    • Interfaces (italic)
    • Classes
    • Enums
    • Exceptions
    • Errors
    • Annotation Types
  • Class/Interface

    Each class, interface, nested class and nested interface has its own separate page. Each of these pages has three sections consisting of a class/interface description, summary tables, and detailed member descriptions:

    • Class inheritance diagram
    • Direct Subclasses
    • All Known Subinterfaces
    • All Known Implementing Classes
    • Class/interface declaration
    • Class/interface description
    • Nested Class Summary
    • Field Summary
    • Constructor Summary
    • Method Summary
    • Field Detail
    • Constructor Detail
    • Method Detail

    Each summary entry contains the first sentence from the detailed description for that item. The summary entries are alphabetical, while the detailed descriptions are in the order they appear in the source code. This preserves the logical groupings established by the programmer.

  • Annotation Type

    Each annotation type has its own separate page with the following sections:

    • Annotation Type declaration
    • Annotation Type description
    • Required Element Summary
    • Optional Element Summary
    • Element Detail
  • Enum

    Each enum has its own separate page with the following sections:

    • Enum declaration
    • Enum description
    • Enum Constant Summary
    • Enum Constant Detail
  • Tree (Class Hierarchy)

    There is a Class Hierarchy page for all packages, plus a hierarchy for each package. Each hierarchy page contains a list of classes and a list of interfaces. The classes are organized by inheritance structure starting with java.lang.Object. The interfaces do not inherit from java.lang.Object.

    • When viewing the Overview page, clicking on "Tree" displays the hierarchy for all packages.
    • When viewing a particular package, class or interface page, clicking "Tree" displays the hierarchy for only that package.
  • Deprecated API

    The Deprecated API page lists all of the API that have been deprecated. A deprecated API is not recommended for use, generally due to improvements, and a replacement API is usually given. Deprecated APIs may be removed in future implementations.

  • Index

    The Index contains an alphabetic list of all classes, interfaces, constructors, methods, and fields.

  • Prev/Next

    These links take you to the next or previous class, interface, package, or related page.

  • Frames/No Frames

    These links show and hide the HTML frames. All pages are available with or without frames.

  • All Classes

    The All Classes link shows all classes and interfaces except non-static nested types.

  • Serialized Form

    Each serializable or externalizable class has a description of its serialization fields and methods. This information is of interest to re-implementors, not to developers using the API. While there is no link in the navigation bar, you can get to this information by going to any serialized class and clicking "Serialized Form" in the "See also" section of the class description.

  • Constant Field Values

    The Constant Field Values page lists the static final fields and their values.

This help file applies to API documentation generated using the standard doclet.
rJava/inst/javadoc/index.html0000644000176200001440000000474212256051770015712 0ustar liggesusers Generated Documentation (Untitled) <noscript> <div>JavaScript is disabled on your browser.</div> </noscript> <h2>Frame Alert</h2> <p>This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. Link to <a href="ArrayDimensionException.html">Non-frame version</a>.</p> rJava/inst/javadoc/RectangularArrayBuilder_Test.html0000644000176200001440000002054312256051770022354 0ustar liggesusers RectangularArrayBuilder_Test

Class RectangularArrayBuilder_Test

  • java.lang.Object
    • RectangularArrayBuilder_Test


  • public class RectangularArrayBuilder_Test
    extends java.lang.Object
    Test suite for RectangularArrayBuilder
    • Method Summary

      Methods 
      Modifier and Type Method and Description
      static void main(java.lang.String[] args) 
      static void runtests() 
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • RectangularArrayBuilder_Test

        public RectangularArrayBuilder_Test()
    • Method Detail

      • main

        public static void main(java.lang.String[] args)
rJava/inst/javadoc/TestException.html0000644000176200001440000001627412256051770017404 0ustar liggesusers TestException

Class TestException

  • java.lang.Object
    • java.lang.Throwable
      • java.lang.Exception
        • TestException
  • All Implemented Interfaces:
    java.io.Serializable


    public class TestException
    extends java.lang.Exception
    Generated as part of testing rjava internal java tools
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor and Description
      TestException(java.lang.String message) 
    • Method Summary

      • Methods inherited from class java.lang.Throwable

        addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • TestException

        public TestException(java.lang.String message)
rJava/inst/javadoc/ArrayDimensionException.html0000644000176200001440000001636412256051767021417 0ustar liggesusers ArrayDimensionException

Class ArrayDimensionException

  • java.lang.Object
    • java.lang.Throwable
      • java.lang.Exception
        • ArrayDimensionException
  • All Implemented Interfaces:
    java.io.Serializable


    public class ArrayDimensionException
    extends java.lang.Exception
    See Also:
    Serialized Form
    • Method Summary

      • Methods inherited from class java.lang.Throwable

        addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • ArrayDimensionException

        public ArrayDimensionException(java.lang.String message)
rJava/inst/javadoc/RJavaTools_Test.DummyNonStaticClass.html0000644000176200001440000001571012256051770023526 0ustar liggesusers RJavaTools_Test.DummyNonStaticClass

Class RJavaTools_Test.DummyNonStaticClass

  • java.lang.Object
    • RJavaTools_Test.DummyNonStaticClass
  • Enclosing class:
    RJavaTools_Test


    public class RJavaTools_Test.DummyNonStaticClass
    extends java.lang.Object
    • Method Summary

      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • RJavaTools_Test.DummyNonStaticClass

        public RJavaTools_Test.DummyNonStaticClass()
rJava/inst/javadoc/serialized-form.html0000644000176200001440000001447112256051770017677 0ustar liggesusers Serialized Form

Serialized Form

rJava/inst/javadoc/RectangularArraySummary.html0000644000176200001440000003377412256051770021436 0ustar liggesusers RectangularArraySummary

Class RectangularArraySummary



  • public class RectangularArraySummary
    extends RJavaArrayIterator
    Utility class to extract something from a rectangular array
    • Method Detail

      • min

        public java.lang.Object min(boolean narm)
        Iterates over the array to find the minimum value (in the sense of the Comparable interface)
      • max

        public java.lang.Object max(boolean narm)
        Iterates over the array to find the maximum value (in the sense of the Comparable interface)
      • range

        public java.lang.Object[] range(boolean narm)
        Iterates over the array to find the range of the java array (in the sense of the Comparable interface)
      • containsComparableObjects

        public boolean containsComparableObjects()
rJava/inst/javadoc/RJavaImport.html0000644000176200001440000003267412256051770017006 0ustar liggesusers RJavaImport

Class RJavaImport

  • java.lang.Object
    • RJavaImport
  • All Implemented Interfaces:
    java.io.Serializable


    public class RJavaImport
    extends java.lang.Object
    implements java.io.Serializable
    Utilities to manage java packages and how they are "imported" to R databases. This is the back door of the javaImport system in the R side
    Author:
    Romain Francois
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field and Description
      static boolean DEBUG
      Debug flag.
      java.lang.ClassLoader loader
      associated class loader
    • Constructor Summary

      Constructors 
      Constructor and Description
      RJavaImport(java.lang.ClassLoader loader)
      Constructor.
    • Method Summary

      Methods 
      Modifier and Type Method and Description
      boolean exists_(java.lang.String clazz) 
      boolean exists(java.lang.String clazz) 
      java.lang.String[] getKnownClasses() 
      void importPackage(java.lang.String packageName)
      Adds a package to the list of "imported" packages
      void importPackage(java.lang.String[] packages)
      Adds a set of packages
      java.lang.Class lookup(java.lang.String clazz)
      Look for the class in the set of packages
      static java.lang.Class lookup(java.lang.String clazz, java.util.Set importers) 
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • DEBUG

        public static boolean DEBUG
        Debug flag. Prints some messages if it is set to TRUE
      • loader

        public java.lang.ClassLoader loader
        associated class loader
    • Constructor Detail

      • RJavaImport

        public RJavaImport(java.lang.ClassLoader loader)
        Constructor. Initializes the imported package vector and the cache
    • Method Detail

      • lookup

        public java.lang.Class lookup(java.lang.String clazz)
        Look for the class in the set of packages
        Parameters:
        clazz - the simple class name
        Returns:
        an instance of Class representing the actual class
      • exists

        public boolean exists(java.lang.String clazz)
        Returns:
        true if the class is known
      • exists_

        public boolean exists_(java.lang.String clazz)
      • importPackage

        public void importPackage(java.lang.String packageName)
        Adds a package to the list of "imported" packages
        Parameters:
        packageName - package path name
      • importPackage

        public void importPackage(java.lang.String[] packages)
        Adds a set of packages
        Parameters:
        packages - package path names
      • getKnownClasses

        public java.lang.String[] getKnownClasses()
        Returns:
        the simple names of the classes currently known by this importer
      • lookup

        public static java.lang.Class lookup(java.lang.String clazz,
                             java.util.Set importers)
rJava/inst/javadoc/stylesheet.css0000644000176200001440000002560312256051770016617 0ustar liggesusers/* Javadoc style sheet */ /* Overall document style */ body { background-color:#ffffff; color:#353833; font-family:Arial, Helvetica, sans-serif; font-size:76%; margin:0; } a:link, a:visited { text-decoration:none; color:#4c6b87; } a:hover, a:focus { text-decoration:none; color:#bb7a2a; } a:active { text-decoration:none; color:#4c6b87; } a[name] { color:#353833; } a[name]:hover { text-decoration:none; color:#353833; } pre { font-size:1.3em; } h1 { font-size:1.8em; } h2 { font-size:1.5em; } h3 { font-size:1.4em; } h4 { font-size:1.3em; } h5 { font-size:1.2em; } h6 { font-size:1.1em; } ul { list-style-type:disc; } code, tt { font-size:1.2em; } dt code { font-size:1.2em; } table tr td dt code { font-size:1.2em; vertical-align:top; } sup { font-size:.6em; } /* Document title and Copyright styles */ .clear { clear:both; height:0px; overflow:hidden; } .aboutLanguage { float:right; padding:0px 21px; font-size:.8em; z-index:200; margin-top:-7px; } .legalCopy { margin-left:.5em; } .bar a, .bar a:link, .bar a:visited, .bar a:active { color:#FFFFFF; text-decoration:none; } .bar a:hover, .bar a:focus { color:#bb7a2a; } .tab { background-color:#0066FF; background-image:url(resources/titlebar.gif); background-position:left top; background-repeat:no-repeat; color:#ffffff; padding:8px; width:5em; font-weight:bold; } /* Navigation bar styles */ .bar { background-image:url(resources/background.gif); background-repeat:repeat-x; color:#FFFFFF; padding:.8em .5em .4em .8em; height:auto;/*height:1.8em;*/ font-size:1em; margin:0; } .topNav { background-image:url(resources/background.gif); background-repeat:repeat-x; color:#FFFFFF; float:left; padding:0; width:100%; clear:right; height:2.8em; padding-top:10px; overflow:hidden; } .bottomNav { margin-top:10px; background-image:url(resources/background.gif); background-repeat:repeat-x; color:#FFFFFF; float:left; padding:0; width:100%; clear:right; height:2.8em; padding-top:10px; overflow:hidden; } .subNav { background-color:#dee3e9; border-bottom:1px solid #9eadc0; float:left; width:100%; overflow:hidden; } .subNav div { clear:left; float:left; padding:0 0 5px 6px; } ul.navList, ul.subNavList { float:left; margin:0 25px 0 0; padding:0; } ul.navList li{ list-style:none; float:left; padding:3px 6px; } ul.subNavList li{ list-style:none; float:left; font-size:90%; } .topNav a:link, .topNav a:active, .topNav a:visited, .bottomNav a:link, .bottomNav a:active, .bottomNav a:visited { color:#FFFFFF; text-decoration:none; } .topNav a:hover, .bottomNav a:hover { text-decoration:none; color:#bb7a2a; } .navBarCell1Rev { background-image:url(resources/tab.gif); background-color:#a88834; color:#FFFFFF; margin: auto 5px; border:1px solid #c9aa44; } /* Page header and footer styles */ .header, .footer { clear:both; margin:0 20px; padding:5px 0 0 0; } .indexHeader { margin:10px; position:relative; } .indexHeader h1 { font-size:1.3em; } .title { color:#2c4557; margin:10px 0; } .subTitle { margin:5px 0 0 0; } .header ul { margin:0 0 25px 0; padding:0; } .footer ul { margin:20px 0 5px 0; } .header ul li, .footer ul li { list-style:none; font-size:1.2em; } /* Heading styles */ div.details ul.blockList ul.blockList ul.blockList li.blockList h4, div.details ul.blockList ul.blockList ul.blockListLast li.blockList h4 { background-color:#dee3e9; border-top:1px solid #9eadc0; border-bottom:1px solid #9eadc0; margin:0 0 6px -8px; padding:2px 5px; } ul.blockList ul.blockList ul.blockList li.blockList h3 { background-color:#dee3e9; border-top:1px solid #9eadc0; border-bottom:1px solid #9eadc0; margin:0 0 6px -8px; padding:2px 5px; } ul.blockList ul.blockList li.blockList h3 { padding:0; margin:15px 0; } ul.blockList li.blockList h2 { padding:0px 0 20px 0; } /* Page layout container styles */ .contentContainer, .sourceContainer, .classUseContainer, .serializedFormContainer, .constantValuesContainer { clear:both; padding:10px 20px; position:relative; } .indexContainer { margin:10px; position:relative; font-size:1.0em; } .indexContainer h2 { font-size:1.1em; padding:0 0 3px 0; } .indexContainer ul { margin:0; padding:0; } .indexContainer ul li { list-style:none; } .contentContainer .description dl dt, .contentContainer .details dl dt, .serializedFormContainer dl dt { font-size:1.1em; font-weight:bold; margin:10px 0 0 0; color:#4E4E4E; } .contentContainer .description dl dd, .contentContainer .details dl dd, .serializedFormContainer dl dd { margin:10px 0 10px 20px; } .serializedFormContainer dl.nameValue dt { margin-left:1px; font-size:1.1em; display:inline; font-weight:bold; } .serializedFormContainer dl.nameValue dd { margin:0 0 0 1px; font-size:1.1em; display:inline; } /* List styles */ ul.horizontal li { display:inline; font-size:0.9em; } ul.inheritance { margin:0; padding:0; } ul.inheritance li { display:inline; list-style:none; } ul.inheritance li ul.inheritance { margin-left:15px; padding-left:15px; padding-top:1px; } ul.blockList, ul.blockListLast { margin:10px 0 10px 0; padding:0; } ul.blockList li.blockList, ul.blockListLast li.blockList { list-style:none; margin-bottom:25px; } ul.blockList ul.blockList li.blockList, ul.blockList ul.blockListLast li.blockList { padding:0px 20px 5px 10px; border:1px solid #9eadc0; background-color:#f9f9f9; } ul.blockList ul.blockList ul.blockList li.blockList, ul.blockList ul.blockList ul.blockListLast li.blockList { padding:0 0 5px 8px; background-color:#ffffff; border:1px solid #9eadc0; border-top:none; } ul.blockList ul.blockList ul.blockList ul.blockList li.blockList { margin-left:0; padding-left:0; padding-bottom:15px; border:none; border-bottom:1px solid #9eadc0; } ul.blockList ul.blockList ul.blockList ul.blockList li.blockListLast { list-style:none; border-bottom:none; padding-bottom:0; } table tr td dl, table tr td dl dt, table tr td dl dd { margin-top:0; margin-bottom:1px; } /* Table styles */ .contentContainer table, .classUseContainer table, .constantValuesContainer table { border-bottom:1px solid #9eadc0; width:100%; } .contentContainer ul li table, .classUseContainer ul li table, .constantValuesContainer ul li table { width:100%; } .contentContainer .description table, .contentContainer .details table { border-bottom:none; } .contentContainer ul li table th.colOne, .contentContainer ul li table th.colFirst, .contentContainer ul li table th.colLast, .classUseContainer ul li table th, .constantValuesContainer ul li table th, .contentContainer ul li table td.colOne, .contentContainer ul li table td.colFirst, .contentContainer ul li table td.colLast, .classUseContainer ul li table td, .constantValuesContainer ul li table td{ vertical-align:top; padding-right:20px; } .contentContainer ul li table th.colLast, .classUseContainer ul li table th.colLast,.constantValuesContainer ul li table th.colLast, .contentContainer ul li table td.colLast, .classUseContainer ul li table td.colLast,.constantValuesContainer ul li table td.colLast, .contentContainer ul li table th.colOne, .classUseContainer ul li table th.colOne, .contentContainer ul li table td.colOne, .classUseContainer ul li table td.colOne { padding-right:3px; } .overviewSummary caption, .packageSummary caption, .contentContainer ul.blockList li.blockList caption, .summary caption, .classUseContainer caption, .constantValuesContainer caption { position:relative; text-align:left; background-repeat:no-repeat; color:#FFFFFF; font-weight:bold; clear:none; overflow:hidden; padding:0px; margin:0px; } caption a:link, caption a:hover, caption a:active, caption a:visited { color:#FFFFFF; } .overviewSummary caption span, .packageSummary caption span, .contentContainer ul.blockList li.blockList caption span, .summary caption span, .classUseContainer caption span, .constantValuesContainer caption span { white-space:nowrap; padding-top:8px; padding-left:8px; display:block; float:left; background-image:url(resources/titlebar.gif); height:18px; } .overviewSummary .tabEnd, .packageSummary .tabEnd, .contentContainer ul.blockList li.blockList .tabEnd, .summary .tabEnd, .classUseContainer .tabEnd, .constantValuesContainer .tabEnd { width:10px; background-image:url(resources/titlebar_end.gif); background-repeat:no-repeat; background-position:top right; position:relative; float:left; } ul.blockList ul.blockList li.blockList table { margin:0 0 12px 0px; width:100%; } .tableSubHeadingColor { background-color: #EEEEFF; } .altColor { background-color:#eeeeef; } .rowColor { background-color:#ffffff; } .overviewSummary td, .packageSummary td, .contentContainer ul.blockList li.blockList td, .summary td, .classUseContainer td, .constantValuesContainer td { text-align:left; padding:3px 3px 3px 7px; } th.colFirst, th.colLast, th.colOne, .constantValuesContainer th { background:#dee3e9; border-top:1px solid #9eadc0; border-bottom:1px solid #9eadc0; text-align:left; padding:3px 3px 3px 7px; } td.colOne a:link, td.colOne a:active, td.colOne a:visited, td.colOne a:hover, td.colFirst a:link, td.colFirst a:active, td.colFirst a:visited, td.colFirst a:hover, td.colLast a:link, td.colLast a:active, td.colLast a:visited, td.colLast a:hover, .constantValuesContainer td a:link, .constantValuesContainer td a:active, .constantValuesContainer td a:visited, .constantValuesContainer td a:hover { font-weight:bold; } td.colFirst, th.colFirst { border-left:1px solid #9eadc0; white-space:nowrap; } td.colLast, th.colLast { border-right:1px solid #9eadc0; } td.colOne, th.colOne { border-right:1px solid #9eadc0; border-left:1px solid #9eadc0; } table.overviewSummary { padding:0px; margin-left:0px; } table.overviewSummary td.colFirst, table.overviewSummary th.colFirst, table.overviewSummary td.colOne, table.overviewSummary th.colOne { width:25%; vertical-align:middle; } table.packageSummary td.colFirst, table.overviewSummary th.colFirst { width:25%; vertical-align:middle; } /* Content styles */ .description pre { margin-top:0; } .deprecatedContent { margin:0; padding:10px 0; } .docSummary { padding:0; } /* Formatting effect styles */ .sourceLineNo { color:green; padding:0 30px 0 0; } h1.hidden { visibility:hidden; overflow:hidden; font-size:.9em; } .block { display:block; margin:3px 0 0 0; } .strong { font-weight:bold; } rJava/inst/javadoc/ObjectArrayException.html0000644000176200001440000001702012256051770020660 0ustar liggesusers ObjectArrayException

Class ObjectArrayException

  • java.lang.Object
    • java.lang.Throwable
      • java.lang.Exception
        • ObjectArrayException
  • All Implemented Interfaces:
    java.io.Serializable


    public class ObjectArrayException
    extends java.lang.Exception
    Generated when one tries to access an array of primitive values as an array of Objects
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor and Description
      ObjectArrayException(java.lang.String type) 
    • Method Summary

      • Methods inherited from class java.lang.Throwable

        addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • ObjectArrayException

        public ObjectArrayException(java.lang.String type)
rJava/inst/javadoc/package-list0000644000176200001440000000000112256051770016164 0ustar liggesusers rJava/inst/javadoc/overview-tree.html0000644000176200001440000001635012256051770017404 0ustar liggesusers Class Hierarchy

Hierarchy For All Packages

rJava/inst/javadoc/FlatException.html0000644000176200001440000001642412256051770017350 0ustar liggesusers FlatException

Class FlatException

  • java.lang.Object
    • java.lang.Throwable
      • java.lang.Exception
        • FlatException
  • All Implemented Interfaces:
    java.io.Serializable


    public class FlatException
    extends java.lang.Exception
    Generated when one attemps to flatten an array that is not rectangular
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor and Description
      FlatException() 
    • Method Summary

      • Methods inherited from class java.lang.Throwable

        addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • FlatException

        public FlatException()
rJava/inst/javadoc/deprecated-list.html0000644000176200001440000001014312256051770017644 0ustar liggesusers Deprecated List

Deprecated API

Contents

rJava/inst/javadoc/RJavaTools.html0000644000176200001440000007741712256051770016640 0ustar liggesusers RJavaTools

Class RJavaTools

  • java.lang.Object
    • RJavaTools


  • public class RJavaTools
    extends java.lang.Object
    Tools used internally by rJava. The method lookup code is heavily based on ReflectionTools by Romain Francois licensed under GPL v2 or higher.
    • Constructor Summary

      Constructors 
      Constructor and Description
      RJavaTools() 
    • Method Summary

      Methods 
      Modifier and Type Method and Description
      static boolean classHasClass(java.lang.Class cl, java.lang.String name, boolean staticRequired)
      Checks if the specified class has the given inner class.
      static boolean classHasField(java.lang.Class cl, java.lang.String name, boolean staticRequired)
      Checks if the specified class has the given field.
      static boolean classHasMethod(java.lang.Class cl, java.lang.String name, boolean staticRequired)
      Checks if the specified class has the given method.
      static java.lang.Class getClass(java.lang.Class cl, java.lang.String name, boolean staticRequired)
      Returns an inner class of the class with the given simple name
      static java.lang.Class[] getClasses(java.lang.Object o)
      Returns the list of classes of the object
      static java.lang.String[] getClassNames(java.lang.Object o)
      Returns the list of class names of the object
      static java.lang.String getCompletionName(java.lang.reflect.Member m)
      Completion name of a member.
      static java.lang.reflect.Constructor getConstructor(java.lang.Class o_clazz, java.lang.Class[] arg_clazz, boolean[] arg_is_null)
      Attempts to find the best-matching constructor of the class o_clazz with the parameter types arg_clazz
      static java.lang.String[] getFieldNames(java.lang.Class cl, boolean staticRequired)
      Returns the names of the fields of a given class
      static java.lang.String getFieldTypeName(java.lang.Class cl, java.lang.String field) 
      static java.lang.reflect.Method getMethod(java.lang.Class o_clazz, java.lang.String name, java.lang.Class[] arg_clazz, boolean[] arg_is_null)
      Attempts to find the best-matching method of the class o_clazz with the method name name and arguments types defined by arg_clazz.
      static java.lang.String[] getMethodNames(java.lang.Class cl, boolean staticRequired)
      Returns the completion names of the methods of a given class.
      static java.lang.String[] getSimpleClassNames(java.lang.Object o, boolean addConditionClasses)
      Returns the list of simple class names of the object
      static java.lang.Class[] getStaticClasses(java.lang.Class cl)
      Returns the static inner classes of the class
      static java.lang.reflect.Field[] getStaticFields(java.lang.Class cl)
      Returns the static fields of the class
      static java.lang.reflect.Method[] getStaticMethods(java.lang.Class cl)
      Returns the static methods of the class
      static boolean hasClass(java.lang.Object o, java.lang.String name)
      Checks if the class of the object has the given inner class.
      static boolean hasField(java.lang.Object o, java.lang.String name)
      Checks if the class of the object has the given field.
      static boolean hasMethod(java.lang.Object o, java.lang.String name)
      Checks if the class of the object has the given method.
      static java.lang.Object invokeMethod(java.lang.Class o_clazz, java.lang.Object o, java.lang.String name, java.lang.Object[] args, java.lang.Class[] clazzes)
      Invoke a method of a given class First the appropriate method is resolved by getMethod and then invokes the method
      static boolean isStatic(java.lang.Class clazz)
      Indicates if a class is static
      static boolean isStatic(java.lang.reflect.Member member)
      Indicates if a member of a Class (field, method ) is static
      static java.lang.Object newInstance(java.lang.Class o_clazz, java.lang.Object[] args, java.lang.Class[] clazzes)
      Object creator.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • RJavaTools

        public RJavaTools()
    • Method Detail

      • getClass

        public static java.lang.Class getClass(java.lang.Class cl,
                               java.lang.String name,
                               boolean staticRequired)
        Returns an inner class of the class with the given simple name
        Parameters:
        cl - class
        name - simple name of the inner class
        staticRequired - boolean, if true the inner class is required to be static
      • getStaticClasses

        public static java.lang.Class[] getStaticClasses(java.lang.Class cl)
        Returns the static inner classes of the class
        Parameters:
        cl - class
        Returns:
        an array of classes or null if cl does not have static inner classes
      • isStatic

        public static boolean isStatic(java.lang.Class clazz)
        Indicates if a class is static
        Parameters:
        clazz - class
        Returns:
        true if the class is static
      • getStaticFields

        public static java.lang.reflect.Field[] getStaticFields(java.lang.Class cl)
        Returns the static fields of the class
        Parameters:
        cl - class
        Returns:
        an array of static fields
      • getStaticMethods

        public static java.lang.reflect.Method[] getStaticMethods(java.lang.Class cl)
        Returns the static methods of the class
        Parameters:
        cl - class
        Returns:
        an array of static fields
      • getFieldNames

        public static java.lang.String[] getFieldNames(java.lang.Class cl,
                                       boolean staticRequired)
        Returns the names of the fields of a given class
        Parameters:
        cl - class
        staticRequired - if true only static fields are returned
        Returns:
        the public (and maybe only static) names of the fields.
      • getMethodNames

        public static java.lang.String[] getMethodNames(java.lang.Class cl,
                                        boolean staticRequired)
        Returns the completion names of the methods of a given class. See the getMethodCompletionName method below
        Parameters:
        cl - class
        staticRequired - if true only static methods are returned
        Returns:
        the public (and maybe only static) names of the methods.
      • getCompletionName

        public static java.lang.String getCompletionName(java.lang.reflect.Member m)
        Completion name of a member.

        For fields, it just returns the name of the fields

        For methods, this returns the name of the method plus a suffix that depends on the number of arguments of the method.

        The string "()" is added if the method has no arguments, and the string "(" is added if the method has one or more arguments.

      • isStatic

        public static boolean isStatic(java.lang.reflect.Member member)
        Indicates if a member of a Class (field, method ) is static
        Parameters:
        member - class member
        Returns:
        true if the member is static
      • hasField

        public static boolean hasField(java.lang.Object o,
                       java.lang.String name)
        Checks if the class of the object has the given field. The getFields method of Class is used so only public fields are checked
        Parameters:
        o - object
        name - name of the field
        Returns:
        true if the class of o has the field name
      • hasClass

        public static boolean hasClass(java.lang.Object o,
                       java.lang.String name)
        Checks if the class of the object has the given inner class. The getClasses method of Class is used so only public classes are checked
        Parameters:
        o - object
        name - (simple) name of the inner class
        Returns:
        true if the class of o has the class name
      • classHasField

        public static boolean classHasField(java.lang.Class cl,
                            java.lang.String name,
                            boolean staticRequired)
        Checks if the specified class has the given field. The getFields method of Class is used so only public fields are checked
        Parameters:
        cl - class object
        name - name of the field
        staticRequired - if true then the field is required to be static
        Returns:
        true if the class cl has the field name
      • classHasMethod

        public static boolean classHasMethod(java.lang.Class cl,
                             java.lang.String name,
                             boolean staticRequired)
        Checks if the specified class has the given method. The getMethods method of Class is used so only public methods are checked
        Parameters:
        cl - class
        name - name of the method
        staticRequired - if true then the method is required to be static
        Returns:
        true if the class cl has the method name
      • classHasClass

        public static boolean classHasClass(java.lang.Class cl,
                            java.lang.String name,
                            boolean staticRequired)
        Checks if the specified class has the given inner class. The getClasses method of Class is used so only public classes are checked
        Parameters:
        cl - class
        name - name of the inner class
        staticRequired - if true then the method is required to be static
        Returns:
        true if the class cl has the field name
      • hasMethod

        public static boolean hasMethod(java.lang.Object o,
                        java.lang.String name)
        Checks if the class of the object has the given method. The getMethods method of Class is used so only public methods are checked
        Parameters:
        o - object
        name - name of the method
        Returns:
        true if the class of o has the field name
      • newInstance

        public static java.lang.Object newInstance(java.lang.Class o_clazz,
                                   java.lang.Object[] args,
                                   java.lang.Class[] clazzes)
                                            throws java.lang.Throwable
        Object creator. Find the best constructor based on the parameter classes and invoke newInstance on the resolved constructor
        Throws:
        java.lang.Throwable
      • invokeMethod

        public static java.lang.Object invokeMethod(java.lang.Class o_clazz,
                                    java.lang.Object o,
                                    java.lang.String name,
                                    java.lang.Object[] args,
                                    java.lang.Class[] clazzes)
                                             throws java.lang.Throwable
        Invoke a method of a given class

        First the appropriate method is resolved by getMethod and then invokes the method

        Throws:
        java.lang.Throwable
      • getConstructor

        public static java.lang.reflect.Constructor getConstructor(java.lang.Class o_clazz,
                                                   java.lang.Class[] arg_clazz,
                                                   boolean[] arg_is_null)
                                                            throws java.lang.SecurityException,
                                                                   java.lang.NoSuchMethodException
        Attempts to find the best-matching constructor of the class o_clazz with the parameter types arg_clazz
        Parameters:
        o_clazz - Class to look for a constructor
        arg_clazz - parameter types
        arg_is_null - indicates if each argument is null
        Returns:
        null if no constructor is found, or the constructor
        Throws:
        java.lang.SecurityException
        java.lang.NoSuchMethodException
      • getMethod

        public static java.lang.reflect.Method getMethod(java.lang.Class o_clazz,
                                         java.lang.String name,
                                         java.lang.Class[] arg_clazz,
                                         boolean[] arg_is_null)
                                                  throws java.lang.SecurityException,
                                                         java.lang.NoSuchMethodException
        Attempts to find the best-matching method of the class o_clazz with the method name name and arguments types defined by arg_clazz. The lookup is performed by finding the most specific methods that matches the supplied arguments (see also isMoreSpecific(java.lang.reflect.Method, java.lang.reflect.Method)).
        Parameters:
        o_clazz - class in which to look for the method
        name - method name
        arg_clazz - an array of classes defining the types of arguments
        arg_is_null - indicates if each argument is null
        Returns:
        null if no matching method could be found or the best matching method.
        Throws:
        java.lang.SecurityException
        java.lang.NoSuchMethodException
      • getClasses

        public static java.lang.Class[] getClasses(java.lang.Object o)
        Returns the list of classes of the object
        Parameters:
        o - an Object
      • getClassNames

        public static java.lang.String[] getClassNames(java.lang.Object o)
        Returns the list of class names of the object
        Parameters:
        o - an Object
      • getSimpleClassNames

        public static java.lang.String[] getSimpleClassNames(java.lang.Object o,
                                             boolean addConditionClasses)
        Returns the list of simple class names of the object
        Parameters:
        o - an Object
      • getFieldTypeName

        public static java.lang.String getFieldTypeName(java.lang.Class cl,
                                        java.lang.String field)
        Parameters:
        cl - class
        field - name of the field
        Returns:
        the class name of the field of the class (or null) if the class does not have the given field)
rJava/inst/javadoc/RJavaArrayIterator.html0000644000176200001440000003311112256051770020307 0ustar liggesusers RJavaArrayIterator

Class RJavaArrayIterator

  • java.lang.Object
    • RJavaArrayIterator
    • Field Detail

      • dimensions

        protected int[] dimensions
      • nd

        protected int nd
      • index

        protected int[] index
      • dimprod

        protected int[] dimprod
      • array

        protected java.lang.Object array
      • increment

        protected int increment
      • position

        protected int position
      • start

        protected int start
    • Constructor Detail

      • RJavaArrayIterator

        public RJavaArrayIterator()
      • RJavaArrayIterator

        public RJavaArrayIterator(int[] dimensions)
      • RJavaArrayIterator

        public RJavaArrayIterator(int d1)
    • Method Detail

      • getArray

        public java.lang.Object getArray()
      • getArrayClassName

        public java.lang.String getArrayClassName()
        Returns:
        the class name of the array
      • getDimensions

        public int[] getDimensions()
      • next

        protected java.lang.Object next()
      • hasNext

        protected boolean hasNext()
rJava/inst/javadoc/constant-values.html0000644000176200001440000001027512256051770017727 0ustar liggesusers Constant Field Values

Constant Field Values

Contents

<Unnamed>.*

rJava/inst/javadoc/resources/0000755000176200001440000000000012256051770015720 5ustar liggesusersrJava/inst/javadoc/resources/background.gif0000644000176200001440000000441112256051770020526 0ustar liggesusersGIF89a2p=[q>\r?]sCby@^tDczA_uKmVz<[q=\r<[p>]s=\q;YmBbyAaw?^t>]rXfcIs( gxrIhCN)nB!9_<]x>c|bYi 7`mڪkҚj  kJ˫F{+Z~[l2˭R{{n*n o;-oΫ;̯n+ G;ƽ[q$;l2[/+{˱+r:/65;sq;#3&M̲@ ¼tC\QSV?ݵ^,p mZ7kqL:-KMpށtSvn uH#0wyB. @E1z騗>:驫~:꯷:;Nz޺z»>|N<7_<~'_?O7{~~݋_=ۧ{o@?Տ@0~^7A{TUB;aF ) Ђ" a SHB5Px &b(@jqc7FЇ^DaXQd4nw@# }A @#)H> iπsD'-OxB3ѹP`vդ@P3%I۩ДmH PN~g; Ӑ t'MSt Cg*ΒED*SJjSYJЏ4Kj,GQ4Z=+J_Ւ1jO0$ I+^W~_kWuիaֱ}d#ZlcKY6Eh;v=brVk+Kھ6ejS Z6jWڽV%m6-.t{;ֺՕ-n[i r䅬t]^Ve:udK_0z+YMe[_7px8M{^µ%\651|K7™ pA x;c!=qZ@j AJ$?J!JBڣZ MZVX a*gLʥM7ljڦ[e5*-:i(]|*j vU 2j4:;Jzڦ9A`jApʩکZZJڪꪰ ꪵjj ʫȚ*JjՊ ʬªjJຮzڭʮ뺭گJ蚮:z ۰j њ* k{۫k+,[Z[밚*.0*=K9{;:F{B[:J7Zڴ*R ʳZ ?KjZ-˩A0/"!k ot+vKozs;vx~붂|+ w[{۸u+}K˷ {k{kۺ KK[rK{[빨ۻλ;{;{ K˼ܻ۷ҫ曾뻰۾[ۼ; ;˿+k~; \l[{{kK!, <{̺웿٫ 0-!@#000?\@~k>nN_^mny藾扞N>((?)O( o //O  &O'* /!?)!?,;2O_.?$/%OJF?W6O"?=/_VoUd9^f_hlC?T?n/bC?uJjN[m|_j/op_o7Q<?OlO_//_t?_oxO-+,,,ÓʘӺƹׯȏȠ⥎ı Fm]X <ʡ~2rY&=Jj$ip‹ uxR"~UgǂB Gj) K2iUJJjTVUu,٦`jMm[XԬ\v-[]n{vk޺u`!7ak3eɠ'6qeΑ/?\4^ԟU;Ypڑ^tyᙟ^x݊kj,nǾKv[bԚ+/z쩪* .2@wX܁c1xq"o(|r'L-qӌ13/k= 3<4E"|AoQOP'MuK)Smu>:/KO]lh>@0p T(. @ VpChA z'` %P, _І&$?HRPԡ [(q7Da C&:3$!XDF"A(갃^b(F,0Uh'qjxE&ЍsdF<0["Q:oE@h d!y6񎋄GA IJ&ѓT$(EI4#S9HFNcyIR"D(OJKĠ})S%2[M.ͬ"9MnV \+)gnD'gylR;oiKd̥5?@ π5AЂ6CP'Cщ4G-χT%%iDQzP *(K]Q:43Nszѝ4,}iP+:T)R}jԟ7S:UVݨRUzҨ:դLiQӄtcjVVZuX(ZR>tR\W•c=+Wc ӽ~*DiZV"McKFv^5KYVvl^?R=^;ҺujY [2ֳukl*؅fvmS[vbkWZ6kmUs[ׁ^+_;[]lXW+&wy.tbE)JsvI LsӔg0`S\,g- S{7 Oֻ-rܷ~آ-}RMUlZ֮p maOصa;uvk~F7Ukus;VjZkp;n kw˾7dGF|ߪ|v8O+kێ|%An[($x p.e#ds ]K>.Htr"MNw3hLf΍f`9(9=z2,e9Yl]a_\ab]K4oKΉW:N=f~d3Mvw΁f{їH?y~SvnQ[m>p咵Mrl7o8zuw7ok߇ĥ>仧wOZrW˿}$G5{>gm͆pqFoH~#eo|Wq~qlp~~kHro}+~&ȂQ }6W-h1q&(q.X_sfvsgxW{Ry]C Ԅnwt7fxHdwvZyW'f6{Z&vySsdtWhzz{&wybyq`7VeD{Dž4xsW~8LuQeqc`xyu$zTxs{({xzzfAM(sM]gaCwxuyhvxhCXȇ^7HxwWm(hl(dFhSFt(oƉxouVd茮8YI؍[8y Y?ǎPY`莇W~?Xtzs؋Mh秀X*X|9x8('؀=G]Aj(|FqhqE'䷔(ڷ\ǃ֗rAHXM k: h9헂&%GV6~Q9jiC tYT)Wey]iـWƀ){ W)AGWoyiŋu'0GXyU8#%GdKL) LĹz$9vNǏhəiwH牜Ȉ,ɛyxyXBy}(`cy%ٟɠRvogv9IݙY L4If8陗FR8VIXiZIxGAɔǖ$x:U5*FfYCzȕ9Iǚz闣I>&ꁥ٤L=H7o"P:餌iٗvWEږ\7[9p9;nz0z{R)/ j:@1 [G i "  j y ^&鍠v j J#zڞڙ9:yo(HHj "*|ĮڮĄ鑿M% ,_(բN9n^:4Z2xVm:p J Y{ۥ+iu*}!]}B&ɗtU3{/1@۱$;z/՘@)ڲ)Rjj{00}ob;A{8+`II󕟧:۫*١ȫ˷ʐ cjz۷HFϩuWڎZyJ Gג>Ǻ޺C jc;t;$z{Kp[ iٰlkMVkD[ZKjk[h~ʩۻ`kn6*,[>{=d+;\QiU<֦57o%47kPpa@Ԡ`#E3V 1Ȅ/B 2DI"LN列0Yx9s H@O;uP`ĉ%Pj4i '$@A5 WX;6X +0Lؠ!C p}m 0`A_ymAB<8܁1"SÇ-c "@"BiӡIbr̝7g ZӧUnMYlٱ?:5nޯ1|Boؾ9kn4n㫑^.pEw=o<['^7k7>xDL H ( ;rJava/inst/javadoc/package-tree.html0000644000176200001440000001636112256051770017133 0ustar liggesusers Class Hierarchy

Hierarchy For Package <Unnamed>

rJava/inst/javadoc/RJavaArrayTools.ArrayDimensionMismatchException.html0000644000176200001440000002011112256051770026102 0ustar liggesusers RJavaArrayTools.ArrayDimensionMismatchException

Class RJavaArrayTools.ArrayDimensionMismatchException

  • java.lang.Object
    • java.lang.Throwable
      • java.lang.Exception
        • RJavaArrayTools.ArrayDimensionMismatchException
  • All Implemented Interfaces:
    java.io.Serializable
    Enclosing class:
    RJavaArrayTools


    public static class RJavaArrayTools.ArrayDimensionMismatchException
    extends java.lang.Exception
    See Also:
    Serialized Form
    • Method Summary

      • Methods inherited from class java.lang.Throwable

        addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • RJavaArrayTools.ArrayDimensionMismatchException

        public RJavaArrayTools.ArrayDimensionMismatchException(int index_dim,
                                                       int actual_dim)
rJava/inst/javadoc/package-frame.html0000644000176200001440000000701012256051770017255 0ustar liggesusers &lt;Unnamed&gt;

<Unnamed>

rJava/inst/javadoc/PrimitiveArrayException.html0000644000176200001440000001710012256051770021421 0ustar liggesusers PrimitiveArrayException

Class PrimitiveArrayException

  • java.lang.Object
    • java.lang.Throwable
      • java.lang.Exception
        • PrimitiveArrayException
  • All Implemented Interfaces:
    java.io.Serializable


    public class PrimitiveArrayException
    extends java.lang.Exception
    Generated when one tries to convert an arrays into a primitive array of the wrong type
    See Also:
    Serialized Form
    • Method Summary

      • Methods inherited from class java.lang.Throwable

        addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • PrimitiveArrayException

        public PrimitiveArrayException(java.lang.String type)
rJava/inst/javadoc/DummyPoint.html0000644000176200001440000002270612256051770016710 0ustar liggesusers DummyPoint

Class DummyPoint

  • java.lang.Object
    • DummyPoint
  • All Implemented Interfaces:
    java.lang.Cloneable


    public class DummyPoint
    extends java.lang.Object
    implements java.lang.Cloneable
    • Field Summary

      Fields 
      Modifier and Type Field and Description
      int x 
      int y 
    • Constructor Summary

      Constructors 
      Constructor and Description
      DummyPoint() 
      DummyPoint(int x, int y) 
    • Method Summary

      Methods 
      Modifier and Type Method and Description
      double getX() 
      void move(int x, int y) 
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • x

        public int x
      • y

        public int y
    • Constructor Detail

      • DummyPoint

        public DummyPoint()
      • DummyPoint

        public DummyPoint(int x,
                  int y)
    • Method Detail

      • getX

        public double getX()
      • move

        public void move(int x,
                int y)
rJava/inst/javadoc/RJavaArrayTools_Test.html0000644000176200001440000002026112256051770020617 0ustar liggesusers RJavaArrayTools_Test

Class RJavaArrayTools_Test

  • java.lang.Object
    • RJavaArrayTools_Test


  • public class RJavaArrayTools_Test
    extends java.lang.Object
    • Method Summary

      Methods 
      Modifier and Type Method and Description
      static void main(java.lang.String[] args) 
      static void runtests() 
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • RJavaArrayTools_Test

        public RJavaArrayTools_Test()
    • Method Detail

      • main

        public static void main(java.lang.String[] args)
rJava/inst/javadoc/NotComparableException.html0000644000176200001440000002211512256051770021202 0ustar liggesusers NotComparableException

Class NotComparableException

  • java.lang.Object
    • java.lang.Throwable
      • java.lang.Exception
        • NotComparableException
  • All Implemented Interfaces:
    java.io.Serializable


    public class NotComparableException
    extends java.lang.Exception
    Exception generated when two objects cannot be compared Such cases happen when an object does not implement the Comparable interface or when the comparison produces a ClassCastException
    See Also:
    Serialized Form
    • Method Summary

      • Methods inherited from class java.lang.Throwable

        addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • NotComparableException

        public NotComparableException(java.lang.Object a,
                              java.lang.Object b)
      • NotComparableException

        public NotComparableException(java.lang.Object o)
      • NotComparableException

        public NotComparableException(java.lang.Class cl)
      • NotComparableException

        public NotComparableException(java.lang.String type)
rJava/inst/javadoc/index-all.html0000644000176200001440000026440412256051770016463 0ustar liggesusers Index
A B C D E F G H I L M N O P R S T U V X Y 

A

addClassPath(String) - Method in class RJavaClassLoader
adds an entry to the class path
addClassPath(String[]) - Method in class RJavaClassLoader
adds several entries to the class path
addRLibrary(String, String) - Method in class RJavaClassLoader
add a library to path mapping for a native library
anyDuplicated(Object[]) - Static method in class RJavaArrayTools
 
array - Variable in class RJavaArrayIterator
 
ArrayDimensionException - Exception in <Unnamed>
 
ArrayDimensionException(String) - Constructor for exception ArrayDimensionException
 
ArrayWrapper - Class in <Unnamed>
Utility class to deal with arrays
ArrayWrapper(Object) - Constructor for class ArrayWrapper
Constructor
ArrayWrapper(int) - Constructor for class ArrayWrapper
 
ArrayWrapper(boolean) - Constructor for class ArrayWrapper
 
ArrayWrapper(byte) - Constructor for class ArrayWrapper
 
ArrayWrapper(long) - Constructor for class ArrayWrapper
 
ArrayWrapper(short) - Constructor for class ArrayWrapper
 
ArrayWrapper(double) - Constructor for class ArrayWrapper
 
ArrayWrapper(char) - Constructor for class ArrayWrapper
 
ArrayWrapper(float) - Constructor for class ArrayWrapper
 
ArrayWrapper_Test - Class in <Unnamed>
Test suite for ArrayWrapper
ArrayWrapper_Test() - Constructor for class ArrayWrapper_Test
 

B

bootClass(String, String, String[]) - Method in class RJavaClassLoader
Boots the specified method of the specified class
boxBooleans(int[]) - Static method in class RJavaArrayTools
 
boxDoubles(double[]) - Static method in class RJavaArrayTools
 
boxIntegers(int[]) - Static method in class RJavaArrayTools
 

C

checkComparableObjects() - Method in class RectangularArraySummary
 
classHasClass(Class, String, boolean) - Static method in class RJavaTools
Checks if the specified class has the given inner class.
classHasField(Class, String, boolean) - Static method in class RJavaTools
Checks if the specified class has the given field.
classHasMethod(Class, String, boolean) - Static method in class RJavaTools
Checks if the specified class has the given method.
cloneObject(Object) - Static method in class RJavaArrayTools
 
compare(Object, Object) - Static method in class RJavaComparator
compares a and b in the sense of the java.lang.Comparable if possible instances of the Number interface are treated specially, in order to allow comparing Numbers of different classes, for example it is allowed to compare a Double with an Integer. if the Numbers have the same class, they are compared normally, otherwise they are first converted to Doubles and then compared
containsComparableObjects() - Method in class RectangularArraySummary
 
copy(Object[]) - Static method in class RJavaArrayTools
 

D

DEBUG - Static variable in class RJavaImport
Debug flag.
dimensions - Variable in class RJavaArrayIterator
 
dimprod - Variable in class RJavaArrayIterator
 
DummyPoint - Class in <Unnamed>
 
DummyPoint() - Constructor for class DummyPoint
 
DummyPoint(int, int) - Constructor for class DummyPoint
 
duplicated(Object[]) - Static method in class RJavaArrayTools
 

E

exists(String) - Method in class RJavaImport
 
exists_(String) - Method in class RJavaImport
 

F

findClass(String) - Method in class RJavaClassLoader
 
findLibrary(String) - Method in class RJavaClassLoader
 
findResource(String) - Method in class RJavaClassLoader
 
flat_boolean() - Method in class ArrayWrapper
Flattens the array into a single dimensionned boolean array
flat_byte() - Method in class ArrayWrapper
Flattens the array into a single dimensionned byte array
flat_char() - Method in class ArrayWrapper
Flattens the array into a single dimensionned double array
flat_double() - Method in class ArrayWrapper
Flattens the array into a single dimensionned double array
flat_float() - Method in class ArrayWrapper
Flattens the array into a single dimensionned float array
flat_int() - Method in class ArrayWrapper
Flattens the array into a single dimensionned int array
flat_long() - Method in class ArrayWrapper
Flattens the array into a single dimensionned long array
flat_Object() - Method in class ArrayWrapper
 
flat_short() - Method in class ArrayWrapper
Flattens the array into a single dimensionned short array
flat_String() - Method in class ArrayWrapper
Flattens the array into a single dimensionned String array
FlatException - Exception in <Unnamed>
Generated when one attemps to flatten an array that is not rectangular
FlatException() - Constructor for exception FlatException
 

G

get(Object, int[]) - Static method in class RJavaArrayTools
Gets a single object from a multi dimensional array
get(Object, int) - Static method in class RJavaArrayTools
 
getArray() - Method in class RJavaArrayIterator
 
getArrayClassName() - Method in class RJavaArrayIterator
 
getBoolean(Object, int[]) - Static method in class RJavaArrayTools
 
getBoolean(Object, int) - Static method in class RJavaArrayTools
 
getBooleanDoubleRectangularArrayExample() - Static method in class RectangularArrayExamples
 
getBooleanTripleRectangularArrayExample() - Static method in class RectangularArrayExamples
 
getByte(Object, int[]) - Static method in class RJavaArrayTools
 
getByte(Object, int) - Static method in class RJavaArrayTools
 
getByteDoubleRectangularArrayExample() - Static method in class RectangularArrayExamples
 
getByteTripleRectangularArrayExample() - Static method in class RectangularArrayExamples
 
getChar(Object, int[]) - Static method in class RJavaArrayTools
 
getChar(Object, int) - Static method in class RJavaArrayTools
 
getCharDoubleRectangularArrayExample() - Static method in class RectangularArrayExamples
 
getCharTripleRectangularArrayExample() - Static method in class RectangularArrayExamples
 
getClass(Class, String, boolean) - Static method in class RJavaTools
Returns an inner class of the class with the given simple name
getClasses(Object) - Static method in class RJavaTools
Returns the list of classes of the object
getClassForSignature(String, ClassLoader) - Static method in class RJavaArrayTools
 
getClassNames(Object) - Static method in class RJavaTools
Returns the list of class names of the object
getClassPath() - Method in class RJavaClassLoader
 
getCompletionName(Member) - Static method in class RJavaTools
Completion name of a member.
getConstructor(Class, Class[], boolean[]) - Static method in class RJavaTools
Attempts to find the best-matching constructor of the class o_clazz with the parameter types arg_clazz
getDimensionLength(Object) - Static method in class RJavaArrayTools
Returns the number of dimensions of an array
getDimensionLength(int) - Static method in class RJavaArrayTools
 
getDimensionLength(boolean) - Static method in class RJavaArrayTools
 
getDimensionLength(byte) - Static method in class RJavaArrayTools
 
getDimensionLength(long) - Static method in class RJavaArrayTools
 
getDimensionLength(short) - Static method in class RJavaArrayTools
 
getDimensionLength(double) - Static method in class RJavaArrayTools
 
getDimensionLength(char) - Static method in class RJavaArrayTools
 
getDimensionLength(float) - Static method in class RJavaArrayTools
 
getDimensions() - Method in class RJavaArrayIterator
 
getDimensions(Object) - Static method in class RJavaArrayTools
Returns the dimensions of an array
getDimensions(int) - Static method in class RJavaArrayTools
 
getDimensions(boolean) - Static method in class RJavaArrayTools
 
getDimensions(byte) - Static method in class RJavaArrayTools
 
getDimensions(long) - Static method in class RJavaArrayTools
 
getDimensions(short) - Static method in class RJavaArrayTools
 
getDimensions(double) - Static method in class RJavaArrayTools
 
getDimensions(char) - Static method in class RJavaArrayTools
 
getDimensions(float) - Static method in class RJavaArrayTools
 
getDouble(Object, int[]) - Static method in class RJavaArrayTools
 
getDouble(Object, int) - Static method in class RJavaArrayTools
 
getDoubleDoubleRectangularArrayExample() - Static method in class RectangularArrayExamples
 
getDoubleTripleRectangularArrayExample() - Static method in class RectangularArrayExamples
 
getDummyPointDoubleRectangularArrayExample() - Static method in class RectangularArrayExamples
 
getDummyPointTripleRectangularArrayExample() - Static method in class RectangularArrayExamples
 
getFieldNames(Class, boolean) - Static method in class RJavaTools
Returns the names of the fields of a given class
getFieldTypeName(Class, String) - Static method in class RJavaTools
 
getFloat(Object, int[]) - Static method in class RJavaArrayTools
 
getFloat(Object, int) - Static method in class RJavaArrayTools
 
getFloatDoubleRectangularArrayExample() - Static method in class RectangularArrayExamples
 
getFloatTripleRectangularArrayExample() - Static method in class RectangularArrayExamples
 
getInt(Object, int[]) - Static method in class RJavaArrayTools
 
getInt(Object, int) - Static method in class RJavaArrayTools
 
getIntDoubleRectangularArrayExample() - Static method in class RectangularArrayExamples
 
getIntTripleRectangularArrayExample() - Static method in class RectangularArrayExamples
 
getIterableContent(Iterable) - Static method in class RJavaArrayTools
 
getKnownClasses() - Method in class RJavaImport
 
getLong(Object, int[]) - Static method in class RJavaArrayTools
 
getLong(Object, int) - Static method in class RJavaArrayTools
 
getLongDoubleRectangularArrayExample() - Static method in class RectangularArrayExamples
 
getLongTripleRectangularArrayExample() - Static method in class RectangularArrayExamples
 
getMethod(Class, String, Class[], boolean[]) - Static method in class RJavaTools
Attempts to find the best-matching method of the class o_clazz with the method name name and arguments types defined by arg_clazz.
getMethodNames(Class, boolean) - Static method in class RJavaTools
Returns the completion names of the methods of a given class.
getObjectTypeName() - Method in class ArrayWrapper
 
getObjectTypeName(Object) - Static method in class RJavaArrayTools
Get the object type name of an multi dimensional array.
getObjectTypeName(int) - Static method in class RJavaArrayTools
 
getObjectTypeName(boolean) - Static method in class RJavaArrayTools
 
getObjectTypeName(byte) - Static method in class RJavaArrayTools
 
getObjectTypeName(long) - Static method in class RJavaArrayTools
 
getObjectTypeName(short) - Static method in class RJavaArrayTools
 
getObjectTypeName(double) - Static method in class RJavaArrayTools
 
getObjectTypeName(char) - Static method in class RJavaArrayTools
 
getObjectTypeName(float) - Static method in class RJavaArrayTools
 
getPrimaryLoader() - Static method in class RJavaClassLoader
Returns the singleton instance of RJavaClassLoader
getShort(Object, int[]) - Static method in class RJavaArrayTools
 
getShort(Object, int) - Static method in class RJavaArrayTools
 
getShortDoubleRectangularArrayExample() - Static method in class RectangularArrayExamples
 
getShortTripleRectangularArrayExample() - Static method in class RectangularArrayExamples
 
getSimpleClassNames(Object, boolean) - Static method in class RJavaTools
Returns the list of simple class names of the object
getStaticClasses(Class) - Static method in class RJavaTools
Returns the static inner classes of the class
getStaticFields(Class) - Static method in class RJavaTools
Returns the static fields of the class
getStaticMethods(Class) - Static method in class RJavaTools
Returns the static methods of the class
getStaticX() - Static method in class RJavaTools_Test
 
getStringDoubleRectangularArrayExample() - Static method in class RectangularArrayExamples
 
getStringTripleRectangularArrayExample() - Static method in class RectangularArrayExamples
 
getTrueLength(Object) - Static method in class RJavaArrayTools
Returns the true length of an array (the product of its dimensions)
getTrueLength(int) - Static method in class RJavaArrayTools
 
getTrueLength(boolean) - Static method in class RJavaArrayTools
 
getTrueLength(byte) - Static method in class RJavaArrayTools
 
getTrueLength(long) - Static method in class RJavaArrayTools
 
getTrueLength(short) - Static method in class RJavaArrayTools
 
getTrueLength(double) - Static method in class RJavaArrayTools
 
getTrueLength(char) - Static method in class RJavaArrayTools
 
getTrueLength(float) - Static method in class RJavaArrayTools
 
getX() - Method in class DummyPoint
 
getX() - Method in class RJavaTools_Test
 

H

hasClass(Object, String) - Static method in class RJavaTools
Checks if the class of the object has the given inner class.
hasField(Object, String) - Static method in class RJavaTools
Checks if the class of the object has the given field.
hasMethod(Object, String) - Static method in class RJavaTools
Checks if the class of the object has the given method.
hasNext() - Method in class RJavaArrayIterator
 

I

importPackage(String) - Method in class RJavaImport
Adds a package to the list of "imported" packages
importPackage(String[]) - Method in class RJavaImport
Adds a set of packages
increment - Variable in class RJavaArrayIterator
 
index - Variable in class RJavaArrayIterator
 
invokeMethod(Class, Object, String, Object[], Class[]) - Static method in class RJavaTools
Invoke a method of a given class First the appropriate method is resolved by getMethod and then invokes the method
isArray(Object) - Static method in class RJavaArrayTools
Deprecated.
use RJavaArrayTools#isArray
isArray(int) - Static method in class RJavaArrayTools
 
isArray(boolean) - Static method in class RJavaArrayTools
 
isArray(byte) - Static method in class RJavaArrayTools
 
isArray(long) - Static method in class RJavaArrayTools
 
isArray(short) - Static method in class RJavaArrayTools
 
isArray(double) - Static method in class RJavaArrayTools
 
isArray(char) - Static method in class RJavaArrayTools
 
isArray(float) - Static method in class RJavaArrayTools
 
isNA(double) - Static method in class RJavaArrayTools
 
isPrimitive() - Method in class ArrayWrapper
 
isPrimitiveTypeName(String) - Static method in class RJavaArrayTools
 
isRectangular() - Method in class ArrayWrapper
 
isRectangularArray(Object) - Static method in class RJavaArrayTools
Deprecated.
use new ArrayWrapper(o).isRectangular() instead
isRectangularArray(int) - Static method in class RJavaArrayTools
 
isRectangularArray(boolean) - Static method in class RJavaArrayTools
 
isRectangularArray(byte) - Static method in class RJavaArrayTools
 
isRectangularArray(long) - Static method in class RJavaArrayTools
 
isRectangularArray(short) - Static method in class RJavaArrayTools
 
isRectangularArray(double) - Static method in class RJavaArrayTools
 
isRectangularArray(char) - Static method in class RJavaArrayTools
 
isRectangularArray(float) - Static method in class RJavaArrayTools
 
isSingleDimensionArray(Object) - Static method in class RJavaArrayTools
 
isStatic(Class) - Static method in class RJavaTools
Indicates if a class is static
isStatic(Member) - Static method in class RJavaTools
Indicates if a member of a Class (field, method ) is static

L

loader - Variable in class RJavaImport
associated class loader
lookup(String) - Method in class RJavaImport
Look for the class in the set of packages
lookup(String, Set) - Static method in class RJavaImport
 

M

main(String[]) - Static method in class ArrayWrapper_Test
 
main(String[]) - Static method in class RectangularArrayBuilder_Test
 
main(String[]) - Static method in class RJavaArrayTools_Test
 
main(String[]) - Static method in class RJavaClassLoader
main method This uses the system properties: rjava.path : path of the rJava package rjava.lib : lib sub directory of the rJava package main.class : main class to "boot", assumes Main if not specified rjava.class.path : set of paths to populate the initiate the class path and boots the "main" method of the specified main.class, passing the args down to the booted class This makes sure R and rJava are known by the class loader
main(String[]) - Static method in class RJavaTools_Test
 
makeArraySignature(String, int) - Static method in class RJavaArrayTools
 
max(boolean) - Method in class RectangularArraySummary
Iterates over the array to find the maximum value (in the sense of the Comparable interface)
min(boolean) - Method in class RectangularArraySummary
Iterates over the array to find the minimum value (in the sense of the Comparable interface)
move(int, int) - Method in class DummyPoint
 

N

NA_INTEGER - Static variable in class RJavaArrayTools
 
NA_REAL - Static variable in class RJavaArrayTools
 
nd - Variable in class RJavaArrayIterator
 
newInstance(Class, Object[], Class[]) - Static method in class RJavaTools
Object creator.
next() - Method in class RJavaArrayIterator
 
NotAnArrayException - Exception in <Unnamed>
Exception indicating that an object is not a java array
NotAnArrayException(Class) - Constructor for exception NotAnArrayException
 
NotAnArrayException(String) - Constructor for exception NotAnArrayException
 
NotComparableException - Exception in <Unnamed>
Exception generated when two objects cannot be compared Such cases happen when an object does not implement the Comparable interface or when the comparison produces a ClassCastException
NotComparableException(Object, Object) - Constructor for exception NotComparableException
 
NotComparableException(Object) - Constructor for exception NotComparableException
 
NotComparableException(Class) - Constructor for exception NotComparableException
 
NotComparableException(String) - Constructor for exception NotComparableException
 

O

ObjectArrayException - Exception in <Unnamed>
Generated when one tries to access an array of primitive values as an array of Objects
ObjectArrayException(String) - Constructor for exception ObjectArrayException
 

P

position - Variable in class RJavaArrayIterator
 
primaryLoader - Static variable in class RJavaClassLoader
singleton
PrimitiveArrayException - Exception in <Unnamed>
Generated when one tries to convert an arrays into a primitive array of the wrong type
PrimitiveArrayException(String) - Constructor for exception PrimitiveArrayException
 

R

range(boolean) - Method in class RectangularArraySummary
Iterates over the array to find the range of the java array (in the sense of the Comparable interface)
RectangularArrayBuilder - Class in <Unnamed>
Builds rectangular java arrays
RectangularArrayBuilder(Object, int[]) - Constructor for class RectangularArrayBuilder
constructor
RectangularArrayBuilder(Object, int) - Constructor for class RectangularArrayBuilder
 
RectangularArrayBuilder(int, int[]) - Constructor for class RectangularArrayBuilder
 
RectangularArrayBuilder(boolean, int[]) - Constructor for class RectangularArrayBuilder
 
RectangularArrayBuilder(byte, int[]) - Constructor for class RectangularArrayBuilder
 
RectangularArrayBuilder(long, int[]) - Constructor for class RectangularArrayBuilder
 
RectangularArrayBuilder(short, int[]) - Constructor for class RectangularArrayBuilder
 
RectangularArrayBuilder(double, int[]) - Constructor for class RectangularArrayBuilder
 
RectangularArrayBuilder(char, int[]) - Constructor for class RectangularArrayBuilder
 
RectangularArrayBuilder(float, int[]) - Constructor for class RectangularArrayBuilder
 
RectangularArrayBuilder(int, int) - Constructor for class RectangularArrayBuilder
 
RectangularArrayBuilder(boolean, int) - Constructor for class RectangularArrayBuilder
 
RectangularArrayBuilder(byte, int) - Constructor for class RectangularArrayBuilder
 
RectangularArrayBuilder(long, int) - Constructor for class RectangularArrayBuilder
 
RectangularArrayBuilder(short, int) - Constructor for class RectangularArrayBuilder
 
RectangularArrayBuilder(double, int) - Constructor for class RectangularArrayBuilder
 
RectangularArrayBuilder(char, int) - Constructor for class RectangularArrayBuilder
 
RectangularArrayBuilder(float, int) - Constructor for class RectangularArrayBuilder
 
RectangularArrayBuilder_Test - Class in <Unnamed>
Test suite for RectangularArrayBuilder
RectangularArrayBuilder_Test() - Constructor for class RectangularArrayBuilder_Test
 
RectangularArrayExamples - Class in <Unnamed>
Utility class that makes example rectangular java arrays of 2 and 3 dimensions for all primitive types, String and Point (as an example of array of non primitive object)
RectangularArrayExamples() - Constructor for class RectangularArrayExamples
 
RectangularArraySummary - Class in <Unnamed>
Utility class to extract something from a rectangular array
RectangularArraySummary(Object, int[]) - Constructor for class RectangularArraySummary
Constructor
RectangularArraySummary(Object, int) - Constructor for class RectangularArraySummary
 
rep(Object, int) - Static method in class RJavaArrayTools
Creates a java array by cloning o several times
rev(Object[]) - Static method in class RJavaArrayTools
Returns a copy of the input array with elements in reverse order
RJavaArrayIterator - Class in <Unnamed>
 
RJavaArrayIterator() - Constructor for class RJavaArrayIterator
 
RJavaArrayIterator(int[]) - Constructor for class RJavaArrayIterator
 
RJavaArrayIterator(int) - Constructor for class RJavaArrayIterator
 
RJavaArrayTools - Class in <Unnamed>
 
RJavaArrayTools() - Constructor for class RJavaArrayTools
 
RJavaArrayTools.ArrayDimensionMismatchException - Exception in <Unnamed>
 
RJavaArrayTools.ArrayDimensionMismatchException(int, int) - Constructor for exception RJavaArrayTools.ArrayDimensionMismatchException
 
RJavaArrayTools_Test - Class in <Unnamed>
 
RJavaArrayTools_Test() - Constructor for class RJavaArrayTools_Test
 
RJavaClassLoader - Class in <Unnamed>
Class loader used internally by rJava The class manages the class paths and the native libraries (jri, ...)
RJavaClassLoader(String, String) - Constructor for class RJavaClassLoader
Constructor.
RJavaComparator - Class in <Unnamed>
Utility class to compare two objects in the sense of the java.lang.Comparable interface
RJavaComparator() - Constructor for class RJavaComparator
 
RJavaImport - Class in <Unnamed>
Utilities to manage java packages and how they are "imported" to R databases.
RJavaImport(ClassLoader) - Constructor for class RJavaImport
Constructor.
RJavaTools - Class in <Unnamed>
Tools used internally by rJava.
RJavaTools() - Constructor for class RJavaTools
 
RJavaTools_Test - Class in <Unnamed>
 
RJavaTools_Test() - Constructor for class RJavaTools_Test
 
RJavaTools_Test.DummyNonStaticClass - Class in <Unnamed>
 
RJavaTools_Test.DummyNonStaticClass() - Constructor for class RJavaTools_Test.DummyNonStaticClass
 
RJavaTools_Test.TestException - Exception in <Unnamed>
 
RJavaTools_Test.TestException(String) - Constructor for exception RJavaTools_Test.TestException
 
runtests() - Static method in class ArrayWrapper_Test
 
runtests() - Static method in class RectangularArrayBuilder_Test
 
runtests() - Static method in class RJavaArrayTools_Test
 
runtests() - Static method in class RJavaTools_Test
 

S

set(Object, int[], Object) - Static method in class RJavaArrayTools
Replaces a single value of the array
set(Object, int[], int) - Static method in class RJavaArrayTools
 
set(Object, int[], boolean) - Static method in class RJavaArrayTools
 
set(Object, int[], byte) - Static method in class RJavaArrayTools
 
set(Object, int[], long) - Static method in class RJavaArrayTools
 
set(Object, int[], short) - Static method in class RJavaArrayTools
 
set(Object, int[], double) - Static method in class RJavaArrayTools
 
set(Object, int[], char) - Static method in class RJavaArrayTools
 
set(Object, int[], float) - Static method in class RJavaArrayTools
 
set(Object, int, Object) - Static method in class RJavaArrayTools
 
set(Object, int, int) - Static method in class RJavaArrayTools
 
set(Object, int, boolean) - Static method in class RJavaArrayTools
 
set(Object, int, byte) - Static method in class RJavaArrayTools
 
set(Object, int, long) - Static method in class RJavaArrayTools
 
set(Object, int, short) - Static method in class RJavaArrayTools
 
set(Object, int, double) - Static method in class RJavaArrayTools
 
set(Object, int, char) - Static method in class RJavaArrayTools
 
set(Object, int, float) - Static method in class RJavaArrayTools
 
setDebug(int) - Static method in class RJavaClassLoader
Set the debug level.
setX(Integer) - Method in class RJavaTools_Test
 
sort(Object[], boolean) - Static method in class RJavaArrayTools
Returns a copy of the array where elements are sorted
start - Variable in class RJavaArrayIterator
 
static_x - Static variable in class RJavaTools_Test
 

T

TestException - Exception in <Unnamed>
Generated as part of testing rjava internal java tools
TestException(String) - Constructor for exception TestException
 
toByte(Object) - Static method in class RJavaClassLoader
Serialize an object to a byte array.
toObject(byte[]) - Method in class RJavaClassLoader
Deserialize an object from a byte array.
toObjectPL(byte[]) - Static method in class RJavaClassLoader
converts the byte array into an Object using the primary RJavaClassLoader

U

u2w(String) - Static method in class RJavaClassLoader
Utility to convert paths for windows.
unboxBooleans(Boolean[]) - Static method in class RJavaArrayTools
 
unboxDoubles(Double[]) - Static method in class RJavaArrayTools
 
unboxIntegers(Integer[]) - Static method in class RJavaArrayTools
 
unique(Object[]) - Static method in class RJavaArrayTools
 
useSystem - Variable in class RJavaClassLoader
Should the system class loader be used to resolve classes as well as this class loader

V

verbose - Static variable in class RJavaClassLoader
Print debug messages if is set to true

X

x - Variable in class DummyPoint
 
x - Variable in class RJavaTools_Test
 

Y

y - Variable in class DummyPoint
 
A B C D E F G H I L M N O P R S T U V X Y 
rJava/inst/javadoc/NotAnArrayException.html0000644000176200001440000001760312256051770020500 0ustar liggesusers NotAnArrayException

Class NotAnArrayException

  • java.lang.Object
    • java.lang.Throwable
      • java.lang.Exception
        • NotAnArrayException
  • All Implemented Interfaces:
    java.io.Serializable


    public class NotAnArrayException
    extends java.lang.Exception
    Exception indicating that an object is not a java array
    See Also:
    Serialized Form
    • Method Summary

      • Methods inherited from class java.lang.Throwable

        addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • NotAnArrayException

        public NotAnArrayException(java.lang.Class clazz)
      • NotAnArrayException

        public NotAnArrayException(java.lang.String message)
rJava/inst/javadoc/RJavaTools_Test.html0000644000176200001440000002735312256051770017631 0ustar liggesusers RJavaTools_Test

Class RJavaTools_Test

  • java.lang.Object
    • RJavaTools_Test


  • public class RJavaTools_Test
    extends java.lang.Object
    • Field Summary

      Fields 
      Modifier and Type Field and Description
      static int static_x 
      int x 
    • Constructor Summary

      Constructors 
      Constructor and Description
      RJavaTools_Test() 
    • Method Summary

      Methods 
      Modifier and Type Method and Description
      static int getStaticX() 
      int getX() 
      static void main(java.lang.String[] args) 
      static void runtests() 
      void setX(java.lang.Integer x) 
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • x

        public int x
      • static_x

        public static int static_x
    • Constructor Detail

      • RJavaTools_Test

        public RJavaTools_Test()
rJava/inst/javadoc/RectangularArrayExamples.html0000644000176200001440000004401512256051770021545 0ustar liggesusers RectangularArrayExamples

Class RectangularArrayExamples

  • java.lang.Object
    • RectangularArrayExamples


  • public class RectangularArrayExamples
    extends java.lang.Object
    Utility class that makes example rectangular java arrays of 2 and 3 dimensions for all primitive types, String and Point (as an example of array of non primitive object)
    • Constructor Detail

      • RectangularArrayExamples

        public RectangularArrayExamples()
    • Method Detail

      • getIntDoubleRectangularArrayExample

        public static int[][] getIntDoubleRectangularArrayExample()
      • getBooleanDoubleRectangularArrayExample

        public static boolean[][] getBooleanDoubleRectangularArrayExample()
      • getByteDoubleRectangularArrayExample

        public static byte[][] getByteDoubleRectangularArrayExample()
      • getLongDoubleRectangularArrayExample

        public static long[][] getLongDoubleRectangularArrayExample()
      • getShortDoubleRectangularArrayExample

        public static short[][] getShortDoubleRectangularArrayExample()
      • getDoubleDoubleRectangularArrayExample

        public static double[][] getDoubleDoubleRectangularArrayExample()
      • getCharDoubleRectangularArrayExample

        public static char[][] getCharDoubleRectangularArrayExample()
      • getFloatDoubleRectangularArrayExample

        public static float[][] getFloatDoubleRectangularArrayExample()
      • getStringDoubleRectangularArrayExample

        public static java.lang.String[][] getStringDoubleRectangularArrayExample()
      • getDummyPointDoubleRectangularArrayExample

        public static DummyPoint[][] getDummyPointDoubleRectangularArrayExample()
      • getIntTripleRectangularArrayExample

        public static int[][][] getIntTripleRectangularArrayExample()
      • getBooleanTripleRectangularArrayExample

        public static boolean[][][] getBooleanTripleRectangularArrayExample()
      • getByteTripleRectangularArrayExample

        public static byte[][][] getByteTripleRectangularArrayExample()
      • getLongTripleRectangularArrayExample

        public static long[][][] getLongTripleRectangularArrayExample()
      • getShortTripleRectangularArrayExample

        public static short[][][] getShortTripleRectangularArrayExample()
      • getDoubleTripleRectangularArrayExample

        public static double[][][] getDoubleTripleRectangularArrayExample()
      • getCharTripleRectangularArrayExample

        public static char[][][] getCharTripleRectangularArrayExample()
      • getFloatTripleRectangularArrayExample

        public static float[][][] getFloatTripleRectangularArrayExample()
      • getStringTripleRectangularArrayExample

        public static java.lang.String[][][] getStringTripleRectangularArrayExample()
      • getDummyPointTripleRectangularArrayExample

        public static DummyPoint[][][] getDummyPointTripleRectangularArrayExample()
rJava/inst/javadoc/allclasses-noframe.html0000644000176200001440000000555312256051770020357 0ustar liggesusers All Classes

All Classes

rJava/inst/javadoc/RJavaComparator.html0000644000176200001440000002175512256051770017641 0ustar liggesusers RJavaComparator

Class RJavaComparator

  • java.lang.Object
    • RJavaComparator


  • public class RJavaComparator
    extends java.lang.Object
    Utility class to compare two objects in the sense of the java.lang.Comparable interface
    • Constructor Summary

      Constructors 
      Constructor and Description
      RJavaComparator() 
    • Method Summary

      Methods 
      Modifier and Type Method and Description
      static int compare(java.lang.Object a, java.lang.Object b)
      compares a and b in the sense of the java.lang.Comparable if possible instances of the Number interface are treated specially, in order to allow comparing Numbers of different classes, for example it is allowed to compare a Double with an Integer. if the Numbers have the same class, they are compared normally, otherwise they are first converted to Doubles and then compared
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • RJavaComparator

        public RJavaComparator()
    • Method Detail

      • compare

        public static int compare(java.lang.Object a,
                  java.lang.Object b)
                           throws NotComparableException
        compares a and b in the sense of the java.lang.Comparable if possible

        instances of the Number interface are treated specially, in order to allow comparing Numbers of different classes, for example it is allowed to compare a Double with an Integer. if the Numbers have the same class, they are compared normally, otherwise they are first converted to Doubles and then compared

        Parameters:
        a - an object
        b - another object
        Returns:
        the result of a.compareTo(b) if this makes sense
        Throws:
        NotComparableException - if the two objects are not comparable
rJava/inst/javadoc/RJavaTools_Test.TestException.html0000644000176200001440000001731512256051770022423 0ustar liggesusers RJavaTools_Test.TestException

Class RJavaTools_Test.TestException

  • java.lang.Object
    • java.lang.Throwable
      • java.lang.Exception
        • RJavaTools_Test.TestException
  • All Implemented Interfaces:
    java.io.Serializable
    Enclosing class:
    RJavaTools_Test


    public static class RJavaTools_Test.TestException
    extends java.lang.Exception
    See Also:
    Serialized Form
    • Method Summary

      • Methods inherited from class java.lang.Throwable

        addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • RJavaTools_Test.TestException

        public RJavaTools_Test.TestException(java.lang.String message)
rJava/inst/javadoc/allclasses-frame.html0000644000176200001440000000651312256051770020017 0ustar liggesusers All Classes

All Classes

rJava/inst/javadoc/RJavaClassLoader.html0000644000176200001440000005723512256051770017730 0ustar liggesusers RJavaClassLoader

Class RJavaClassLoader

  • java.lang.Object
    • java.lang.ClassLoader
      • java.security.SecureClassLoader
        • java.net.URLClassLoader
          • RJavaClassLoader
  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable


    public class RJavaClassLoader
    extends java.net.URLClassLoader
    Class loader used internally by rJava The class manages the class paths and the native libraries (jri, ...)
    • Field Summary

      Fields 
      Modifier and Type Field and Description
      static RJavaClassLoader primaryLoader
      singleton
      boolean useSystem
      Should the system class loader be used to resolve classes as well as this class loader
      static boolean verbose
      Print debug messages if is set to true
    • Constructor Summary

      Constructors 
      Constructor and Description
      RJavaClassLoader(java.lang.String path, java.lang.String libpath)
      Constructor.
    • Method Summary

      Methods 
      Modifier and Type Method and Description
      void addClassPath(java.lang.String cp)
      adds an entry to the class path
      void addClassPath(java.lang.String[] cp)
      adds several entries to the class path
      void addRLibrary(java.lang.String name, java.lang.String path)
      add a library to path mapping for a native library
      void bootClass(java.lang.String cName, java.lang.String mName, java.lang.String[] args)
      Boots the specified method of the specified class
      protected java.lang.Class findClass(java.lang.String name) 
      protected java.lang.String findLibrary(java.lang.String name) 
      java.net.URL findResource(java.lang.String name) 
      java.lang.String[] getClassPath() 
      static RJavaClassLoader getPrimaryLoader()
      Returns the singleton instance of RJavaClassLoader
      static void main(java.lang.String[] args)
      main method This uses the system properties: rjava.path : path of the rJava package rjava.lib : lib sub directory of the rJava package main.class : main class to "boot", assumes Main if not specified rjava.class.path : set of paths to populate the initiate the class path and boots the "main" method of the specified main.class, passing the args down to the booted class This makes sure R and rJava are known by the class loader
      static void setDebug(int level)
      Set the debug level.
      static byte[] toByte(java.lang.Object object)
      Serialize an object to a byte array.
      java.lang.Object toObject(byte[] byteArray)
      Deserialize an object from a byte array.
      static java.lang.Object toObjectPL(byte[] byteArray)
      converts the byte array into an Object using the primary RJavaClassLoader
      static java.lang.String u2w(java.lang.String fn)
      Utility to convert paths for windows.
      • Methods inherited from class java.net.URLClassLoader

        addURL, close, definePackage, findResources, getPermissions, getResourceAsStream, getURLs, newInstance, newInstance
      • Methods inherited from class java.security.SecureClassLoader

        defineClass, defineClass
      • Methods inherited from class java.lang.ClassLoader

        clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findLoadedClass, findSystemClass, getClassLoadingLock, getPackage, getPackages, getParent, getResource, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, loadClass, registerAsParallelCapable, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • verbose

        public static boolean verbose
        Print debug messages if is set to true
      • useSystem

        public boolean useSystem
        Should the system class loader be used to resolve classes as well as this class loader
    • Constructor Detail

      • RJavaClassLoader

        public RJavaClassLoader(java.lang.String path,
                        java.lang.String libpath)
        Constructor. The first time an RJavaClassLoader is created, it is cached as the primary loader.
        Parameters:
        path - path of the rJava package
        libpath - lib sub directory of the rJava package
    • Method Detail

      • getPrimaryLoader

        public static RJavaClassLoader getPrimaryLoader()
        Returns the singleton instance of RJavaClassLoader
      • findClass

        protected java.lang.Class findClass(java.lang.String name)
                                     throws java.lang.ClassNotFoundException
        Overrides:
        findClass in class java.net.URLClassLoader
        Throws:
        java.lang.ClassNotFoundException
      • findResource

        public java.net.URL findResource(java.lang.String name)
        Overrides:
        findResource in class java.net.URLClassLoader
      • addRLibrary

        public void addRLibrary(java.lang.String name,
                       java.lang.String path)
        add a library to path mapping for a native library
      • addClassPath

        public void addClassPath(java.lang.String cp)
        adds an entry to the class path
      • addClassPath

        public void addClassPath(java.lang.String[] cp)
        adds several entries to the class path
      • getClassPath

        public java.lang.String[] getClassPath()
        Returns:
        the array of class paths used by this class loader
      • findLibrary

        protected java.lang.String findLibrary(java.lang.String name)
        Overrides:
        findLibrary in class java.lang.ClassLoader
      • bootClass

        public void bootClass(java.lang.String cName,
                     java.lang.String mName,
                     java.lang.String[] args)
                       throws java.lang.IllegalAccessException,
                              java.lang.reflect.InvocationTargetException,
                              java.lang.NoSuchMethodException,
                              java.lang.ClassNotFoundException
        Boots the specified method of the specified class
        Parameters:
        cName - class to boot
        mName - method to boot (typically main). The method must take a String[] as parameter
        args - arguments to pass to the method
        Throws:
        java.lang.IllegalAccessException
        java.lang.reflect.InvocationTargetException
        java.lang.NoSuchMethodException
        java.lang.ClassNotFoundException
      • setDebug

        public static void setDebug(int level)
        Set the debug level. At the moment, there is only verbose (level>0) or quiet
        Parameters:
        level - debug level. verbose (>0), quiet otherwise
      • u2w

        public static java.lang.String u2w(java.lang.String fn)
        Utility to convert paths for windows. Converts / to the path separator in use
        Parameters:
        fn - file name
      • main

        public static void main(java.lang.String[] args)
        main method

        This uses the system properties:

        • rjava.path : path of the rJava package
        • rjava.lib : lib sub directory of the rJava package
        • main.class : main class to "boot", assumes Main if not specified
        • rjava.class.path : set of paths to populate the initiate the class path

        and boots the "main" method of the specified main.class, passing the args down to the booted class

        This makes sure R and rJava are known by the class loader

      • toByte

        public static byte[] toByte(java.lang.Object object)
                             throws java.lang.Exception
        Serialize an object to a byte array. (code by CB)
        Parameters:
        object - object to serialize
        Returns:
        byte array that represents the object
        Throws:
        java.lang.Exception
      • toObject

        public java.lang.Object toObject(byte[] byteArray)
                                  throws java.lang.Exception
        Deserialize an object from a byte array. (code by CB)
        Parameters:
        byteArray -
        Returns:
        the object that is represented by the byte array
        Throws:
        java.lang.Exception
      • toObjectPL

        public static java.lang.Object toObjectPL(byte[] byteArray)
                                           throws java.lang.Exception
        converts the byte array into an Object using the primary RJavaClassLoader
        Throws:
        java.lang.Exception
rJava/inst/javadoc/RectangularArrayBuilder.html0000644000176200001440000005556512256051770021371 0ustar liggesusers RectangularArrayBuilder

Class RectangularArrayBuilder



  • public class RectangularArrayBuilder
    extends RJavaArrayIterator
    Builds rectangular java arrays
rJava/configure.ac0000644000176200001440000002471112256051760013614 0ustar liggesusers# Process this file with autoconf to produce a configure script. AC_INIT(rJava, 0.8, Simon.Urbanek@r-project.org) AC_CONFIG_SRCDIR([src/rJava.c]) AC_CONFIG_HEADER([src/config.h]) # find R home and set CC/CFLAGS : ${R_HOME=`R RHOME`} if test -z "${R_HOME}"; then echo "could not determine R_HOME" exit 1 fi RBIN="${R_HOME}/bin/R" CC=`"${RBIN}" CMD config CC`; CFLAGS=`"${RBIN}" CMD config CFLAGS` LIBS="${PKG_LIBS}" AC_SUBST(R_HOME) RLD=`"${RBIN}" CMD config --ldflags 2>/dev/null` has_R_shlib=no if test -n "$RLD"; then has_R_shlib=yes fi ## enable threads, i.e. Java is running is a separate thread AC_ARG_ENABLE([threads], [AC_HELP_STRING([--enable-threads], [enable the use of threads, i.e. Java is run on a separate thread. This is necessary for some implementations of AWT. This feature is highly experimental, becasue of synchronization issues, so use with care. @<:@no@:>@])], [want_threads="${enableval}"], [want_threads=no]) ## enable JNI-cache AC_ARG_ENABLE([jni-cache], [AC_HELP_STRING([--enable-jni-cache], [enable support for caching of the JNI environment. With this option turned on, the JNI state is stored locally and re-used for subsequent calls. This will work *only* if no threads are used, because each thread has a separate JNI state. Enabling this option can give some performance boost for applications that call JNI very often. If used in a threaded environment, it is bound to crash, so use with care. @<:@no@:>@])], [want_jni_cache="${enableval}"], [want_jni_cache=no]) ## enable JRI AC_ARG_ENABLE([jri], [AC_HELP_STRING([--enable-jri], [enable Java to R interface (JRI), which allows Java programs to embed R. @<:@auto@:>@])], [want_jri="${enableval}"], [want_jri=auto]) ## enable headless AC_ARG_ENABLE([headless], [AC_HELP_STRING([--enable-headless], [enable initialization in headless mode. @<:@auto@:>@])], [want_headless="${enableval}"], [want_headless=auto]) ## enable debug flags AC_ARG_ENABLE([debug], [AC_HELP_STRING([--enable-debug], [enable debug flags and output. @<:@no@:>@])], [want_debug="${enableval}"], [want_debug=no]) ## enable memory profiling AC_ARG_ENABLE([mem-profile], [AC_HELP_STRING([--enable-mem-profile], [enable memory profiling. @<:@debug@:>@])], [want_memprof="${enableval}"], [want_memprof=debug]) ## enable callbacks (experimental) AC_ARG_ENABLE([callbacks], [AC_HELP_STRING([--enable-callbacks], [enable the support for callbacks from Java into R. This requires JRI and is currently experimental/incomplete. @<:@no@:>@])], [want_callbacks="${enableval}"], [want_callbacks=no]) # Checks for programs. AC_PROG_CC # Checks for libraries. # Checks for header files. AC_HEADER_STDC AC_HEADER_SYS_WAIT AC_CHECK_HEADERS([string.h sys/time.h unistd.h]) # Checks for typedefs, structures, and compiler characteristics. AC_C_CONST AC_HEADER_TIME AC_CHECKING([whether ${CC} supports static inline]) can_inline=no AC_COMPILE_IFELSE([AC_LANG_SOURCE([ static inline int foo(int a, int b); static f = 1; static inline int foo(int a, int b) { return a+b; } int main(void) { return foo(f,-1); }])],can_inline=yes) AC_MSG_RESULT(${can_inline}) if test "${can_inline}" = yes; then AC_DEFINE(HAVE_STATIC_INLINE, 1, [Define to 1 when static inline works]) fi ### from R m4/R.m4 - needed to hack R 2.9.x AC_CACHE_CHECK([whether setjmp.h is POSIX.1 compatible], [r_cv_header_setjmp_posix], [AC_COMPILE_IFELSE([AC_LANG_PROGRAM( [[#include ]], [[sigjmp_buf b; sigsetjmp(b, 0); siglongjmp(b, 1);]])], [r_cv_header_setjmp_posix=yes], [r_cv_header_setjmp_posix=no])]) AC_CHECK_DECLS([sigsetjmp, siglongjmp], , , [#include ]) if test "$ac_cv_have_decl_sigsetjmp" = no; then r_cv_header_setjmp_posix=no fi if test "$ac_cv_have_decl_siglongjmp" = no; then r_cv_header_setjmp_posix=no fi if test "${r_cv_header_setjmp_posix}" = yes; then AC_DEFINE(HAVE_POSIX_SETJMP, 1, [Define if you have POSIX.1 compatible sigsetjmp/siglongjmp.]) fi AC_MSG_CHECKING([Java support in R]) R_JAVA_HOME=`"${RBIN}" CMD config JAVA_HOME` : ${JAVA_HOME="${R_JAVA_HOME}"} if test -z "${JAVA_HOME}"; then AC_MSG_ERROR([absent R was configured without Java support. Please run R CMD javareconf as root to add Java support to R. If you do not have root privileges, run R CMD javareconf -e to set all Java-related variables and then install rJava.]) fi : ${JAR=`"${RBIN}" CMD config JAR|sed 's/ERROR:.*//'`} : ${JAVA=`"${RBIN}" CMD config JAVA|sed 's/ERROR:.*//'`} : ${JAVAC=`"${RBIN}" CMD config JAVAC|sed 's/ERROR:.*//'`} : ${JAVAH=`"${RBIN}" CMD config JAVAH|sed 's/ERROR:.*//'`} : ${JAVA_CPPFLAGS=`"${RBIN}" CMD config JAVA_CPPFLAGS|sed 's/ERROR:.*//'`} : ${JAVA_LIBS=`"${RBIN}" CMD config JAVA_LIBS|sed 's/ERROR:.*//'`} AC_MSG_RESULT([present: interpreter : '${JAVA}' archiver : '${JAR}' compiler : '${JAVAC}' header prep.: '${JAVAH}' cpp flags : '${JAVA_CPPFLAGS}' java libs : '${JAVA_LIBS}']) java_error='One or more Java configuration variables are not set.' if test -z "${JAVA}"; then java_error='Java interpreter is missing or not registered in R' fi if test -z "${JAVAC}"; then java_error='Java Development Kit (JDK) is missing or not registered in R' fi have_all_flags=no if test -n "${JAVA}" && test -n "${JAVAC}" && test -n "${JAVAH}" && \ test -n "${JAVA_CPPFLAGS}" && test -n "${JAVA_LIBS}" && test -n "${JAR}"; then have_all_flags=yes; fi if test "${have_all_flags}" = no; then AC_MSG_ERROR([${java_error} Make sure R is configured with full Java support (including JDK). Run R CMD javareconf as root to add Java support to R. If you don't have root privileges, run R CMD javareconf -e to set all Java-related variables and then install rJava. ]) fi if test `echo foo | sed -e 's:foo:bar:'` = bar; then JAVA_CPPFLAGS0=`echo ${JAVA_CPPFLAGS} | sed -e 's:$(JAVA_HOME):'${JAVA_HOME}':g'` JAVA_LIBS0=`echo ${JAVA_LIBS} | sed -e 's:$(JAVA_HOME):'${JAVA_HOME}':g'` JAVA_LD_LIBRARY_PATH0=`echo ${JAVA_LD_LIBRARY_PATH} | sed -e 's:$(JAVA_HOME):'${JAVA_HOME}':g'` else AC_MSG_WARN([sed is not working properly - the configuration may fail]) JAVA_CPPFLAGS0="${JAVA_CPPFLAGS}" JAVA_LIBS0="${JAVA_LIBS}" JAVA_LD_LIBRARY_PATH0="${JAVA_LD_LIBRARY_PATH}" fi LIBS="${LIBS} ${JAVA_LIBS0}" CFLAGS="${CFLAGS} ${JAVA_CPPFLAGS0}" LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${JAVA_LD_LIBRARY_PATH0}" AC_MSG_CHECKING([whether Java run-time works]) if "$JAVA" getsp; then AC_MSG_RESULT(yes) else AC_MSG_RESULT(no) AC_MSG_ERROR([Java interpreter '$JAVA' does not work]) fi has_xrs=no AC_MSG_CHECKING([whether -Xrs is supported]) if "$JAVA" -Xrs getsp; then has_xrs=yes AC_DEFINE(HAVE_XRS, 1, [Set if the Java parameter -Xrs is supported]) fi AC_MSG_RESULT(${has_xrs}) AC_MSG_CHECKING([whether JNI programs can be compiled]) AC_LINK_IFELSE([AC_LANG_SOURCE([ #include int main(void) { jobject o; JNI_CreateJavaVM(0, 0, 0); return 0; } ])],[AC_MSG_RESULT(yes)], [AC_MSG_ERROR([Cannot compile a simple JNI program. See config.log for details. Make sure you have Java Development Kit installed and correctly registered in R. If in doubt, re-run "R CMD javareconf" as root. ])]) AC_MSG_CHECKING([JNI data types]) AC_TRY_RUN( [ #include int main(void) { return (sizeof(int)==sizeof(jint) && sizeof(long)==sizeof(long) && sizeof(jbyte)==sizeof(char) && sizeof(jshort)==sizeof(short) && sizeof(jfloat)==sizeof(float) && sizeof(jdouble)==sizeof(double))?0:1; } ], [AC_MSG_RESULT([ok])], [AC_MSG_ERROR([One or more JNI types differ from the corresponding native type. You may need to use non-standard compiler flags or a different compiler in order to fix this.])], [AC_MSG_RESULT([don't know (cross-compiling)])]) if test "${want_jri}" = auto; then AC_MSG_CHECKING([whether JRI should be compiled (autodetect)]) AC_MSG_RESULT([${has_R_shlib}]) want_jri=${has_R_shlib} fi AM_CONDITIONAL(WANT_JRI, [test "x${want_jri}" = xyes]) AC_MSG_CHECKING([whether debugging output should be enabled]) if test "${want_debug}" = yes; then JAVA_CPPFLAGS="-g -DRJ_DEBUG ${JAVA_CPPFLAGS}" AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) fi AC_MSG_CHECKING([whether memory profiling is desired]) if test "${want_memprof}" = debug; then want_memprof="${want_debug}" fi if test "${want_memprof}" = yes; then AC_DEFINE(MEMPROF, 1, [memory profiling is enabled when defined]) AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) fi AC_SUBST(JAVA_LIBS) AC_SUBST(JAVA_CPPFLAGS) AC_SUBST(JAVA_HOME) AC_SUBST(JAVA) AC_SUBST(JAVAC) AC_SUBST(JAVAH) use_threads=no AC_MSG_CHECKING([whether threads support is requested]) if test "${want_threads}" = yes; then AC_MSG_RESULT([yes]) AC_MSG_CHECKING([whether threads can be enabled]) # check whether we can add THREADS support UNAME=`uname` # we don't want to run full AC_CANONICAL_HOST, all we care about is OS X if test "x$UNAME" == "xDarwin"; then use_threads=yes AC_DEFINE(THREADS, 1, [Set if threading support should be enabled.]) fi AC_MSG_RESULT([${use_threads}]) else AC_MSG_RESULT([no]) fi ## enable callbacks if desired AC_MSG_CHECKING([whether callbacks support is requested]) if test "${want_callbacks}" = yes; then AC_MSG_RESULT([yes]) if test "${want_jri}" != yes; then AC_MSG_ERROR([Callbacks support can be only enabled if JRI is enabled as well.]) fi AC_DEFINE(ENABLE_JRICB, 1, [define if callbacks support is enabled.]) else AC_MSG_RESULT([no]) fi AC_MSG_CHECKING([whether JNI cache support is requested]) if test "${want_jni_cache}" = yes; then AC_MSG_RESULT([yes]) if test "${use_threads}" = yes; then AC_MSG_ERROR([Threads and JNI cache cannot be used at the same time, because JNI cache is by definition not thread-safe. Please disable either option.]) fi AC_DEFINE(JNI_CACHE, 1, [Set if caching JNI environment is enabled.]) else AC_MSG_RESULT([no]) fi AC_MSG_CHECKING([whether headless init is enabled]) if test "${want_headless}" = auto; then want_headless=no ## only Darwin defaults to headless if test x`uname -s 2>/dev/null` = xDarwin; then want_headless=yes fi fi AC_MSG_RESULT([${want_headless}]) if test "${want_headless}" = yes; then AC_DEFINE(USE_HEADLESS_INIT, 1, [Set if headless mode is to be used when starting the JVM]) fi AC_MSG_CHECKING([whether JRI is requested]) if test "${want_jri}" = yes; then AC_MSG_RESULT([yes]) export R_HOME export JAVA_HOME JAVA_CPPFLAGS JAVA_LIBS JAVA_LD_LIBRARY_PATH JAVA JAVAC JAVAH JAR CONFIGURED=1 export CONFIGURED AC_CONFIG_SUBDIRS(jri) else AC_MSG_RESULT([no]) fi AC_CONFIG_FILES([src/Makevars]) AC_CONFIG_FILES([R/zzz.R]) AC_OUTPUT rJava/getsp.java0000644000176200001440000000145012256051760013306 0ustar liggesuserspublic class getsp { public static void main(String[] args) { if (args!=null && args.length>0) { if (args[0].compareTo("-libs")==0) { String prefix="-L"; if (args.length>1) prefix=args[1]; String lp=System.getProperty("java.library.path"); // we're not using StringTokenizer in case the JVM is very crude int i=0,j,k=0; String r=null; String pss=System.getProperty("path.separator"); char ps=':'; if (pss!=null && pss.length()>0) ps=pss.charAt(0); j=lp.length(); while (i<=j) { if (i==j || lp.charAt(i)==ps) { String lib=lp.substring(k,i); k=i+1; if (lib.compareTo(".")!=0) r=(r==null)?(prefix+lib):(r+" "+prefix+lib); } i++; } if (r!=null) System.out.println(r); } else System.out.println(System.getProperty(args[0])); } } } rJava/src/0000755000176200001440000000000012256051760012110 5ustar liggesusersrJava/src/arrayc.c0000644000176200001440000002742612256051771013552 0ustar liggesusers/* R-callable functions to convert arrays into R objects * * rJava R/Java interface (C)Copyright 2003-2007 Simon Urbanek * (see rJava project root for licensing details) */ #include "rJava.h" /** get contents of the object array in the form of list of ext. pointers */ REPC SEXP RgetObjectArrayCont(SEXP e) { SEXP ar; jarray o; int l,i; JNIEnv *env=getJNIEnv(); profStart(); if (e==R_NilValue) return R_NilValue; if (TYPEOF(e)==EXTPTRSXP) { jverify(e); o=(jobject)EXTPTR_PTR(e); } else error("invalid object parameter"); _dbg(rjprintf("RgetObjectArrayCont: jarray %x\n",o)); if (!o) return R_NilValue; l=(int)(*env)->GetArrayLength(env, o); _dbg(rjprintf(" convert object array of length %d\n",l)); if (l<1) return R_NilValue; PROTECT(ar=allocVector(VECSXP,l)); i=0; while (iGetObjectArrayElement(env, o, i); _mp(MEM_PROF_OUT(" %08x LNEW object array element [%d]\n", (int) ae, i)) SET_VECTOR_ELT(ar, i, j2SEXP(env, ae, 1)); i++; } UNPROTECT(1); _prof(profReport("RgetObjectArrayCont[%d]:",o)); return ar; } /** get contents of the object array in the form of STRSXP vector */ REPC SEXP RgetStringArrayCont(SEXP e) { SEXP ar = R_NilValue ; if (e==R_NilValue) return R_NilValue; if (TYPEOF(e)==EXTPTRSXP) { jverify(e); ar = getStringArrayCont( (jarray)EXTPTR_PTR(e) ) ; } else error("invalid object parameter"); return ar; } /** get contents of the integer array object */ REPC SEXP RgetIntArrayCont(SEXP e) { SEXP ar; jarray o; int l; jint *ap; JNIEnv *env=getJNIEnv(); profStart(); if (e==R_NilValue) return e; if (TYPEOF(e)==EXTPTRSXP) { jverify(e); o=(jobject)EXTPTR_PTR(e); } else error("invalid object parameter"); _dbg(rjprintf("RgetIntArrayCont: jarray %x\n",o)); if (!o) return R_NilValue; l=(int)(*env)->GetArrayLength(env, o); _dbg(rjprintf(" convert int array of length %d\n",l)); if (l<0) return R_NilValue; ap=(jint*)(*env)->GetIntArrayElements(env, o, 0); if (!ap) error("cannot obtain integer array contents"); PROTECT(ar=allocVector(INTSXP,l)); if (l>0) memcpy(INTEGER(ar),ap,sizeof(jint)*l); UNPROTECT(1); (*env)->ReleaseIntArrayElements(env, o, ap, 0); _prof(profReport("RgetIntArrayCont[%d]:",o)); return ar; } /** get contents of the boolean array object */ REPC SEXP RgetBoolArrayCont(SEXP e) { SEXP ar; jarray o; int l; jboolean *ap; JNIEnv *env=getJNIEnv(); profStart(); if (e==R_NilValue) return e; if (TYPEOF(e)==EXTPTRSXP) { jverify(e); o=(jobject)EXTPTR_PTR(e); } else error("invalid object parameter"); _dbg(rjprintf("RgetBoolArrayCont: jarray %x\n",o)); if (!o) return R_NilValue; l=(int)(*env)->GetArrayLength(env, o); _dbg(rjprintf(" convert bool array of length %d\n",l)); if (l<0) return R_NilValue; ap=(jboolean*)(*env)->GetBooleanArrayElements(env, o, 0); if (!ap) error("cannot obtain boolean array contents"); PROTECT(ar=allocVector(LGLSXP,l)); { /* jboolean = byte, logical = int, need to convert */ int i = 0; while (i < l) { LOGICAL(ar)[i] = ap[i]; i++; } } UNPROTECT(1); (*env)->ReleaseBooleanArrayElements(env, o, ap, 0); _prof(profReport("RgetBoolArrayCont[%d]:",o)); return ar; } /** get contents of a character array object */ REPC SEXP RgetCharArrayCont(SEXP e) { SEXP ar; jarray o; int l; jchar *ap; JNIEnv *env=getJNIEnv(); profStart(); if (e==R_NilValue) return e; if (TYPEOF(e)==EXTPTRSXP) { jverify(e); o=(jobject)EXTPTR_PTR(e); } else error("invalid object parameter"); _dbg(rjprintf("RgetCharArrayCont: jarray %x\n",o)); if (!o) return R_NilValue; l=(int)(*env)->GetArrayLength(env, o); _dbg(rjprintf(" convert char array of length %d\n",l)); if (l<0) return R_NilValue; ap = (*env)->GetCharArrayElements(env, o, 0); if (!ap) error("cannot obtain char array contents"); PROTECT(ar=allocVector(INTSXP,l)); { /* jchar = 16-bit, need to convert */ int i = 0; while (i < l) { INTEGER(ar)[i] = ap[i]; i++; } } UNPROTECT(1); (*env)->ReleaseCharArrayElements(env, o, ap, 0); _prof(profReport("RgetCharArrayCont[%d]:",o)); return ar; } /** get contents of a short array object */ REPC SEXP RgetShortArrayCont(SEXP e) { SEXP ar; jarray o; int l; jshort *ap; JNIEnv *env=getJNIEnv(); profStart(); if (e==R_NilValue) return e; if (TYPEOF(e)==EXTPTRSXP) { jverify(e); o=(jobject)EXTPTR_PTR(e); } else error("invalid object parameter"); _dbg(rjprintf("RgetBoolArrayCont: jarray %x\n",o)); if (!o) return R_NilValue; l=(int)(*env)->GetArrayLength(env, o); _dbg(rjprintf(" convert short array of length %d\n",l)); if (l<0) return R_NilValue; ap = (*env)->GetShortArrayElements(env, o, 0); if (!ap) error("cannot obtain short array contents"); PROTECT(ar=allocVector(INTSXP,l)); { /* jshort = 16-bit, need to convert */ int i = 0; while (i < l) { INTEGER(ar)[i] = ap[i]; i++; } } UNPROTECT(1); (*env)->ReleaseShortArrayElements(env, o, ap, 0); _prof(profReport("RgetShortArrayCont[%d]:",o)); return ar; } /** get contents of the byte array object */ REPC SEXP RgetByteArrayCont(SEXP e) { SEXP ar; jarray o; int l; jbyte *ap; JNIEnv *env=getJNIEnv(); profStart(); if (e==R_NilValue) return e; if (TYPEOF(e)==EXTPTRSXP) { jverify(e); o = (jobject)EXTPTR_PTR(e); } else error("invalid object parameter"); _dbg(rjprintf("RgetByteArrayCont: jarray %x\n",o)); if (!o) return R_NilValue; l=(int)(*env)->GetArrayLength(env, o); _dbg(rjprintf(" convert byte array of length %d\n",l)); if (l<0) return R_NilValue; ap=(jbyte*)(*env)->GetByteArrayElements(env, o, 0); if (!ap) error("cannot obtain byte array contents"); PROTECT(ar=allocVector(RAWSXP,l)); if (l>0) memcpy(RAW(ar),ap,l); UNPROTECT(1); (*env)->ReleaseByteArrayElements(env, o, ap, 0); _prof(profReport("RgetByteArrayCont[%d]:",o)); return ar; } /** get contents of the double array object */ REPC SEXP RgetDoubleArrayCont(SEXP e) { SEXP ar; jarray o; int l; jdouble *ap; JNIEnv *env=getJNIEnv(); profStart(); if (e==R_NilValue) return e; if (TYPEOF(e)==EXTPTRSXP) { jverify(e); o = (jobject)EXTPTR_PTR(e); } else error("invalid object parameter"); _dbg(rjprintf("RgetDoubleArrayCont: jarray %x\n",o)); if (!o) return R_NilValue; l=(int)(*env)->GetArrayLength(env, o); _dbg(rjprintf(" convert double array of length %d\n",l)); if (l<0) return R_NilValue; ap=(jdouble*)(*env)->GetDoubleArrayElements(env, o, 0); if (!ap) error("cannot obtain double array contents"); PROTECT(ar=allocVector(REALSXP,l)); if (l>0) memcpy(REAL(ar),ap,sizeof(jdouble)*l); UNPROTECT(1); (*env)->ReleaseDoubleArrayElements(env, o, ap, 0); _prof(profReport("RgetDoubleArrayCont[%d]:",o)); return ar; } /** get contents of the float array object (double) */ REPC SEXP RgetFloatArrayCont(SEXP e) { SEXP ar; jarray o; int l; jfloat *ap; JNIEnv *env=getJNIEnv(); profStart(); if (e==R_NilValue) return e; if (TYPEOF(e)==EXTPTRSXP) { jverify(e); o = (jobject)EXTPTR_PTR(e); } else error("invalid object parameter"); _dbg(rjprintf("RgetFloatArrayCont: jarray %d\n",o)); if (!o) return R_NilValue; l=(int)(*env)->GetArrayLength(env, o); _dbg(rjprintf(" convert float array of length %d\n",l)); if (l<0) return R_NilValue; ap=(jfloat*)(*env)->GetFloatArrayElements(env, o, 0); if (!ap) error("cannot obtain float array contents"); PROTECT(ar=allocVector(REALSXP,l)); { /* jfloat must be coerced into double .. we use just a cast for each element */ int i=0; while (iReleaseFloatArrayElements(env, o, ap, 0); _prof(profReport("RgetFloatArrayCont[%d]:",o)); return ar; } /** get contents of the long array object (int) */ REPC SEXP RgetLongArrayCont(SEXP e) { SEXP ar; jarray o; int l; jlong *ap; JNIEnv *env=getJNIEnv(); profStart(); if (e==R_NilValue) return e; if (TYPEOF(e)==EXTPTRSXP) { jverify(e); o=(jobject)EXTPTR_PTR(e); } else error("invalid object parameter"); _dbg(rjprintf("RgetLongArrayCont: jarray %d\n",o)); if (!o) return R_NilValue; l=(int)(*env)->GetArrayLength(env, o); _dbg(rjprintf(" convert long array of length %d\n",l)); if (l<0) return R_NilValue; ap=(jlong*)(*env)->GetLongArrayElements(env, o, 0); if (!ap) error("cannot obtain long contents"); PROTECT(ar=allocVector(REALSXP,l)); { /* long must be coerced into double .. we use just a cast for each element, bad idea? */ int i=0; while (iReleaseLongArrayElements(env, o, ap, 0); _prof(profReport("RgetLongArrayCont[%d]:",o)); return ar; } /* these below have been factored out of the ones above so that they can also be used internally in jni code */ /** * get contents of the String array in the form of STRSXP vector * * @param e a pointer to a String[] object * * @return a STRSXP vector mirroring the java array */ HIDE SEXP getStringArrayCont(jarray o) { SEXP ar; int l,i; const char *c; JNIEnv *env=getJNIEnv(); profStart(); _dbg(rjprintf("RgetStringArrayCont: jarray %x\n",o)); if (!o) return R_NilValue; l=(int)(*env)->GetArrayLength(env, o); _dbg(rjprintf(" convert string array of length %d\n",l)); if (l<0) return R_NilValue; PROTECT(ar=allocVector(STRSXP,l)); i=0; while (iGetObjectArrayElement(env, o, i); _mp(MEM_PROF_OUT(" %08x LNEW object array element [%d]\n", (int) sobj, i)) c=0; if (sobj) { /* we could (should?) check the type here ... if (!(*env)->IsInstanceOf(env, sobj, javaStringClass)) { printf(" not a String\n"); } else */ c=(*env)->GetStringUTFChars(env, sobj, 0); } if (!c) SET_STRING_ELT(ar, i, R_NaString); else { SET_STRING_ELT(ar, i, mkCharUTF8(c)); (*env)->ReleaseStringUTFChars(env, sobj, c); } if (sobj) releaseObject(env, sobj); i++; } UNPROTECT(1); _prof(profReport("RgetStringArrayCont[%d]:",o)) return ar; } /** * Get the list of class names of a java object * This is a jni wrapper around the RJavaTools.getSimpleClassNames method */ HIDE jarray getSimpleClassNames( jobject o, jboolean addConditionClasses ){ JNIEnv *env=getJNIEnv(); jarray a ; profStart(); a = (jarray) (*env)->CallStaticObjectMethod(env, rj_RJavaTools_Class, mid_rj_getSimpleClassNames, o, addConditionClasses ) ; _prof(profReport("getSimpleClassNames[%d]:",o)) ; return a ; } /** * Get the list of class names of a java object, and * structure it as a STRSXP vector */ HIDE SEXP getSimpleClassNames_asSEXP( jobject o, jboolean addConditionClasses ){ if( !o ){ SEXP res = PROTECT( allocVector( STRSXP, 4) ) ; SET_STRING_ELT( res, 0, mkChar( "Exception" ) ) ; SET_STRING_ELT( res, 1, mkChar( "Throwable" ) ) ; SET_STRING_ELT( res, 2, mkChar( "error" ) ) ; SET_STRING_ELT( res, 3, mkChar( "condition" ) ) ; UNPROTECT(1); return res ; } else{ return getStringArrayCont( getSimpleClassNames( o, addConditionClasses ) ); } } /** * Returns the STRSXP vector of simple class names of the object o */ REPC SEXP RgetSimpleClassNames( SEXP e, SEXP addConditionClasses ){ SEXP ar = R_NilValue ; if (e==R_NilValue) return R_NilValue; jobject jobj ; if (TYPEOF(e)==EXTPTRSXP) { jverify(e); jobj = (jobject)EXTPTR_PTR(e) ; } else { error("invalid object parameter"); } Rboolean add ; switch(TYPEOF(addConditionClasses)) { case LGLSXP: add = LOGICAL(addConditionClasses)[0]; break; case INTSXP: add = INTEGER(addConditionClasses)[0]; break; default: add = asLogical(addConditionClasses); } ar = getSimpleClassNames_asSEXP( jobj , (jboolean)add ) ; return ar; } rJava/src/Rglue.c0000644000176200001440000007575212256051771013354 0ustar liggesusers#define USE_RINTERNALS 1 #include "rJava.h" #include #include #include #include #include /* max supported # of parameters to Java methdos */ #ifndef maxJavaPars #define maxJavaPars 32 #endif /* pre-2.4 have no S4SXP but used VECSXP instead */ #ifndef S4SXP #define S4SXP VECSXP #endif /** returns TRUE if JRI has callback support compiled in or FALSE otherwise */ REPC SEXP RJava_has_jri_cb() { SEXP r = allocVector(LGLSXP, 1); #ifdef ENABLE_JRICB LOGICAL(r)[0] = 1; #else LOGICAL(r)[0] = 0; #endif return r; } /* debugging output (enable with -DRJ_DEBUG) */ #ifdef RJ_DEBUG HIDE void rjprintf(char *fmt, ...) { va_list v; va_start(v,fmt); Rvprintf(fmt,v); va_end(v); } /* we can't assume ISO C99 (variadic macros), so we have to use one more level of wrappers */ #define _dbg(X) X #else #define _dbg(X) #endif /* profiling code (enable with -DRJ_PROFILE) */ #ifdef RJ_PROFILE #include HIDE long time_ms() { #ifdef Win32 return 0; /* in Win32 we have no gettimeofday :( */ #else struct timeval tv; gettimeofday(&tv,0); return (tv.tv_usec/1000)+(tv.tv_sec*1000); #endif } static long profilerTime; #define profStart() profilerTime=time_ms() HIDE void profReport(char *fmt, ...) { long npt=time_ms(); va_list v; va_start(v,fmt); Rvprintf(fmt,v); va_end(v); Rprintf(" %ld ms\n",npt-profilerTime); profilerTime=npt; } #define _prof(X) X #else #define profStart() #define _prof(X) #endif static void JRefObjectFinalizer(SEXP ref) { if (java_is_dead) return; if (TYPEOF(ref)==EXTPTRSXP) { JNIEnv *env=getJNIEnv(); jobject o = R_ExternalPtrAddr(ref); #ifdef RJ_DEBUG { jstring s=callToString(env, o); const char *c="???"; if (s) c=(*env)->GetStringUTFChars(env, s, 0); _dbg(rjprintf("Finalizer releases Java object [%s] reference %lx (SEXP@%lx)\n", c, (long)o, (long)ref)); if (s) { (*env)->ReleaseStringUTFChars(env, s, c); releaseObject(env, s); } } #endif if (env && o) { /* _dbg(rjprintf(" finalizer releases global reference %lx\n", (long)o);) */ _mp(MEM_PROF_OUT("R %08x FIN\n", (int)o)) releaseGlobal(env, o); } } } /* jobject to SEXP encoding - 0.2 and earlier use INTSXP */ SEXP j2SEXP(JNIEnv *env, jobject o, int releaseLocal) { if (!env) error("Invalid Java environment in j2SEXP"); if (o) { jobject go = makeGlobal(env, o); _mp(MEM_PROF_OUT("R %08x RNEW %08x\n", (int) go, (int) o)) if (!go) error("Failed to create a global reference in Java."); _dbg(rjprintf(" j2SEXP: %lx -> %lx (release=%d)\n", (long)o, (long)go, releaseLocal)); if (releaseLocal) releaseObject(env, o); o=go; } { SEXP xp = R_MakeExternalPtr(o, R_NilValue, R_NilValue); #ifdef RJ_DEBUG { JNIEnv *env=getJNIEnv(); jstring s=callToString(env, o); const char *c="???"; if (s) c=(*env)->GetStringUTFChars(env, s, 0); _dbg(rjprintf("New Java object [%s] reference %lx (SEXP@%lx)\n", c, (long)o, (long)xp)); if (s) { (*env)->ReleaseStringUTFChars(env, s, c); releaseObject(env, s); } } #endif R_RegisterCFinalizerEx(xp, JRefObjectFinalizer, TRUE); return xp; } } #if R_VERSION >= R_Version(2,7,0) /* returns string from a CHARSXP making sure that the result is in UTF-8 */ const char *rj_char_utf8(SEXP s) { if (Rf_getCharCE(s) == CE_UTF8) return CHAR(s); return Rf_reEnc(CHAR(s), getCharCE(s), CE_UTF8, 0); /* subst. invalid chars: 1=hex, 2=., 3=?, other=skip */ } #endif HIDE void deserializeSEXP(SEXP o) { _dbg(rjprintf("attempt to deserialize %p (clCL=%p, oCL=%p)\n", o, clClassLoader, oClassLoader)); SEXP s = EXTPTR_PROT(o); if (TYPEOF(s) == RAWSXP && EXTPTR_PTR(o) == NULL) { JNIEnv *env = getJNIEnv(); if (env && clClassLoader && oClassLoader) { jbyteArray ser = newByteArray(env, RAW(s), LENGTH(s)); if (ser) { jmethodID mid = (*env)->GetMethodID(env, clClassLoader, "toObject", "([B)Ljava/lang/Object;"); if (mid) { jobject res = (*env)->CallObjectMethod(env, oClassLoader, mid, ser); if (res) { jobject go = makeGlobal(env, res); _mp(MEM_PROF_OUT("R %08x RNEW %08x\n", (int) go, (int) res)) if (go) { _dbg(rjprintf(" - succeeded: %p\n", go)); /* set the deserialized object */ EXTPTR_PTR(o) = (SEXP) go; /* Note: currently we don't remove the serialized content, because it was created explicitly using .jcache to allow repeated saving. Once this is handled by a hook, we shall remove it. However, to assure compatibility TAG is always NULL for now, so we do clear the cache if TAG is non-null for future use. */ if (EXTPTR_TAG(o) != R_NilValue) { /* remove the serialized raw vector */ SETCDR(o, R_NilValue); /* Note: this is abuse of the API since it uses the fact that PROT is stored in CDR */ } } } } releaseObject(env, ser); } } } } #define addtmpo(T, X) { jobject _o = X; if (_o) { _dbg(rjprintf(" parameter to release later: %lx\n", (unsigned long) _o)); *T=_o; T++;} } #define fintmpo(T) { *T = 0; } /* concatenate a string to a signature buffer increasing it as necessary */ static void strcats(sig_buffer_t *sig, const char *add) { int l = strlen(add); int al = sig->len; if (al + l >= sig->maxsig - 1) { sig->maxsig += 8192; if (sig->sig == sig->sigbuf) { /* first-time allocation */ char *ns = (char*) malloc(sig->maxsig); memcpy(ns, sig->sig, al + 1); sig->sig = ns; } else /* re-allocation */ sig->sig = (char*) realloc(sig->sig, sig->maxsig); } strcpy(sig->sig + al, add); sig->len += l; } /* initialize a signature buffer */ HIDE void init_sigbuf(sig_buffer_t *sb) { sb->len = 0; sb->maxsig = sizeof(sb->sigbuf); sb->sig = sb->sigbuf; } /* free the content of a signature buffer (if necessary) */ HIDE void done_sigbuf(sig_buffer_t *sb) { if (sb->sig != sb->sigbuf) free(sb->sig); } /** converts parameters in SEXP list to jpar and sig. since 0.4-4 we ignore named arguments in par */ static int Rpar2jvalue(JNIEnv *env, SEXP par, jvalue *jpar, sig_buffer_t *sig, int maxpars, jobject *tmpo) { SEXP p=par; SEXP e; int jvpos=0; int i=0; while (p && TYPEOF(p)==LISTSXP && (e=CAR(p))) { /* skip all named arguments */ if (TAG(p) && TAG(p)!=R_NilValue) { p=CDR(p); continue; }; if (jvpos >= maxpars) { if (maxpars == maxJavaPars) Rf_error("Too many arguments in Java call. maxJavaPars is %d, recompile rJava with higher number if needed.", maxJavaPars); break; } _dbg(rjprintf("Rpar2jvalue: par %d type %d\n",i,TYPEOF(e))); if (TYPEOF(e)==STRSXP) { _dbg(rjprintf(" string vector of length %d\n",LENGTH(e))); if (LENGTH(e)==1) { strcats(sig,"Ljava/lang/String;"); addtmpo(tmpo, jpar[jvpos++].l=newString(env, CHAR_UTF8(STRING_ELT(e,0)))); } else { int j=0; jobjectArray sa=(*env)->NewObjectArray(env, LENGTH(e), javaStringClass, 0); _mp(MEM_PROF_OUT(" %08x LNEW string[%d]\n", (int) sa, LENGTH(e))) if (!sa) { fintmpo(tmpo); error("unable to create string array."); return -1; } addtmpo(tmpo, sa); while (jSetObjectArrayElement(env, sa, j, s); if (s) releaseObject(env, s); j++; } jpar[jvpos++].l=sa; strcats(sig,"[Ljava/lang/String;"); } } else if (TYPEOF(e)==RAWSXP) { _dbg(rjprintf(" raw vector of length %d\n", LENGTH(e))); strcats(sig,"[B"); addtmpo(tmpo, jpar[jvpos++].l=newByteArray(env, RAW(e), LENGTH(e))); } else if (TYPEOF(e)==INTSXP) { _dbg(rjprintf(" integer vector of length %d\n",LENGTH(e))); if (LENGTH(e)==1) { if (inherits(e, "jbyte")) { _dbg(rjprintf(" (actually a single byte 0x%x)\n", INTEGER(e)[0])); jpar[jvpos++].b=(jbyte)(INTEGER(e)[0]); strcats(sig,"B"); } else if (inherits(e, "jchar")) { _dbg(rjprintf(" (actually a single character 0x%x)\n", INTEGER(e)[0])); jpar[jvpos++].c=(jchar)(INTEGER(e)[0]); strcats(sig,"C"); } else if (inherits(e, "jshort")) { _dbg(rjprintf(" (actually a single short 0x%x)\n", INTEGER(e)[0])); jpar[jvpos++].s=(jshort)(INTEGER(e)[0]); strcats(sig,"S"); } else { strcats(sig,"I"); jpar[jvpos++].i=(jint)(INTEGER(e)[0]); _dbg(rjprintf(" single int orig=%d, jarg=%d [jvpos=%d]\n", (INTEGER(e)[0]), jpar[jvpos-1], jvpos)); } } else { if (inherits(e, "jbyte")) { strcats(sig,"[B"); addtmpo(tmpo, jpar[jvpos++].l=newByteArrayI(env, INTEGER(e), LENGTH(e))); } else if (inherits(e, "jchar")) { strcats(sig,"[C"); addtmpo(tmpo, jpar[jvpos++].l=newCharArrayI(env, INTEGER(e), LENGTH(e))); } else if (inherits(e, "jshort")) { strcats(sig,"[S"); addtmpo(tmpo, jpar[jvpos++].l=newShortArrayI(env, INTEGER(e), LENGTH(e))); } else { strcats(sig,"[I"); addtmpo(tmpo, jpar[jvpos++].l=newIntArray(env, INTEGER(e), LENGTH(e))); } } } else if (TYPEOF(e)==REALSXP) { if (inherits(e, "jfloat")) { _dbg(rjprintf(" jfloat vector of length %d\n", LENGTH(e))); if (LENGTH(e)==1) { strcats(sig,"F"); jpar[jvpos++].f=(jfloat)(REAL(e)[0]); } else { strcats(sig,"[F"); addtmpo(tmpo, jpar[jvpos++].l=newFloatArrayD(env, REAL(e),LENGTH(e))); } } else if (inherits(e, "jlong")) { _dbg(rjprintf(" jlong vector of length %d\n", LENGTH(e))); if (LENGTH(e)==1) { strcats(sig,"J"); jpar[jvpos++].j=(jlong)(REAL(e)[0]); } else { strcats(sig,"[J"); addtmpo(tmpo, jpar[jvpos++].l=newLongArrayD(env, REAL(e),LENGTH(e))); } } else { _dbg(rjprintf(" real vector of length %d\n",LENGTH(e))); if (LENGTH(e)==1) { strcats(sig,"D"); jpar[jvpos++].d=(jdouble)(REAL(e)[0]); } else { strcats(sig,"[D"); addtmpo(tmpo, jpar[jvpos++].l=newDoubleArray(env, REAL(e),LENGTH(e))); } } } else if (TYPEOF(e)==LGLSXP) { _dbg(rjprintf(" logical vector of length %d\n",LENGTH(e))); if (LENGTH(e)==1) { strcats(sig,"Z"); jpar[jvpos++].z=(jboolean)(LOGICAL(e)[0]); } else { strcats(sig,"[Z"); addtmpo(tmpo, jpar[jvpos++].l=newBooleanArrayI(env, LOGICAL(e),LENGTH(e))); } } else if (TYPEOF(e)==VECSXP || TYPEOF(e)==S4SXP) { _dbg(rjprintf(" generic vector of length %d\n", LENGTH(e))); if (IS_JOBJREF(e)) { jobject o=(jobject)0; const char *jc=0; SEXP n=getAttrib(e, R_NamesSymbol); if (TYPEOF(n)!=STRSXP) n=0; _dbg(rjprintf(" which is in fact a Java object reference\n")); if (TYPEOF(e)==VECSXP && LENGTH(e)>1) { /* old objects were lists */ fintmpo(tmpo); error("Old, unsupported S3 Java object encountered."); } else { /* new objects are S4 objects */ SEXP sref, sclass; sref=GET_SLOT(e, install("jobj")); if (sref && TYPEOF(sref)==EXTPTRSXP) { jverify(sref); o = (jobject)EXTPTR_PTR(sref); } else /* if jobj is anything else, assume NULL ptr */ o=(jobject)0; sclass=GET_SLOT(e, install("jclass")); if (sclass && TYPEOF(sclass)==STRSXP && LENGTH(sclass)==1) jc=CHAR_UTF8(STRING_ELT(sclass,0)); if (IS_JARRAYREF(e) && jc && !*jc) { /* if it's jarrayRef with jclass "" then it's an uncast array - use sig instead */ sclass=GET_SLOT(e, install("jsig")); if (sclass && TYPEOF(sclass)==STRSXP && LENGTH(sclass)==1) jc=CHAR_UTF8(STRING_ELT(sclass,0)); } } if (jc) { if (*jc!='[') { /* not an array, we assume it's an object of that class */ strcats(sig,"L"); strcats(sig,jc); strcats(sig,";"); } else /* array signature is passed as-is */ strcats(sig,jc); } else strcats(sig,"Ljava/lang/Object;"); jpar[jvpos++].l=o; } else { _dbg(rjprintf(" (ignoring)\n")); } } i++; p=CDR(p); } fintmpo(tmpo); return jvpos; } /** free parameters that were temporarily allocated */ static void Rfreejpars(JNIEnv *env, jobject *tmpo) { if (!tmpo) return; while (*tmpo) { _dbg(rjprintf("Rfreepars: releasing %lx\n", (unsigned long) *tmpo)); releaseObject(env, *tmpo); tmpo++; } } /** map one parameter into jvalue and determine its signature (unused in fields.c) */ HIDE jvalue R1par2jvalue(JNIEnv *env, SEXP par, sig_buffer_t *sig, jobject *otr) { jobject tmpo[4] = {0, 0}; jvalue v[4]; int p = Rpar2jvalue(env, CONS(par, R_NilValue), v, sig, 2, tmpo); /* this should never happen, but just in case - we can only assume responsibility for one value ... */ if (p != 1 || (tmpo[0] && tmpo[1])) { Rfreejpars(env, tmpo); error("invalid parameter"); } *otr = *tmpo; return *v; } /** call specified non-static method on an object object (int), return signature (string), method name (string) [, ..parameters ...] arrays and objects are returned as IDs (hence not evaluated) */ REPE SEXP RcallMethod(SEXP par) { SEXP p = par, e; sig_buffer_t sig; jvalue jpar[maxJavaPars]; jobject tmpo[maxJavaPars+1]; jobject o = 0; const char *retsig, *mnam, *clnam = 0; jmethodID mid = 0; jclass cls; JNIEnv *env = getJNIEnv(); profStart(); p=CDR(p); e=CAR(p); p=CDR(p); if (e==R_NilValue) error_return("RcallMethod: call on a NULL object"); if (TYPEOF(e)==EXTPTRSXP) { jverify(e); o = (jobject)EXTPTR_PTR(e); } else if (TYPEOF(e)==STRSXP && LENGTH(e)==1) clnam = CHAR_UTF8(STRING_ELT(e, 0)); else error_return("RcallMethod: invalid object parameter"); if (!o && !clnam) error_return("RcallMethod: attempt to call a method of a NULL object."); #ifdef RJ_DEBUG { SEXP de=CAR(CDR(p)); rjprintf("RcallMethod (env=%x):\n",env); if (TYPEOF(de)==STRSXP && LENGTH(de)>0) rjprintf(" method to call: %s on object 0x%x or class %s\n",CHAR_UTF8(STRING_ELT(de,0)),o,clnam); } #endif if (clnam) cls = findClass(env, clnam); else cls = objectClass(env,o); if (!cls) error_return("RcallMethod: cannot determine object class"); #ifdef RJ_DEBUG rjprintf(" class: "); printObject(env, cls); #endif e=CAR(p); p=CDR(p); if (TYPEOF(e)==STRSXP && LENGTH(e)==1) { /* signature */ retsig=CHAR_UTF8(STRING_ELT(e,0)); /* } else if (inherits(e, "jobjRef")) { method object SEXP mexp = GET_SLOT(e, install("jobj")); jobject mobj = (jobject)(INTEGER(mexp)[0]); _dbg(rjprintf(" signature is Java object %x - using reflection\n", mobj); mid = (*env)->FromReflectedMethod(*env, jobject mobj); retsig = getReturnSigFromMethodObject(mobj); */ } else error_return("RcallMethod: invalid return signature parameter"); e=CAR(p); p=CDR(p); if (TYPEOF(e)!=STRSXP || LENGTH(e)!=1) error_return("RcallMethod: invalid method name"); mnam = CHAR_UTF8(STRING_ELT(e,0)); init_sigbuf(&sig); strcats(&sig, "("); Rpar2jvalue(env, p, jpar, &sig, maxJavaPars, tmpo); strcats(&sig, ")"); strcats(&sig, retsig); _dbg(rjprintf(" method \"%s\" signature is %s\n", mnam, sig.sig)); mid=o? (*env)->GetMethodID(env, cls, mnam, sig.sig): (*env)->GetStaticMethodID(env, cls, mnam, sig.sig); if (!mid && o) { /* try static method as a fall-back */ checkExceptionsX(env, 1); o = 0; mid = (*env)->GetStaticMethodID(env, cls, mnam, sig.sig); } if (!mid) { checkExceptionsX(env, 1); Rfreejpars(env, tmpo); releaseObject(env, cls); done_sigbuf(&sig); error("method %s with signature %s not found", mnam, sig.sigbuf); } #if (RJ_PROFILE>1) profReport("Found CID/MID for %s %s:",mnam,sig.sig); #endif switch (*retsig) { case 'V': { BEGIN_RJAVA_CALL o? (*env)->CallVoidMethodA(env, o, mid, jpar): (*env)->CallStaticVoidMethodA(env, cls, mid, jpar); END_RJAVA_CALL Rfreejpars(env, tmpo); releaseObject(env, cls); _prof(profReport("Method \"%s\" returned:",mnam)); return R_NilValue; } case 'I': { BEGIN_RJAVA_CALL int r=o? (*env)->CallIntMethodA(env, o, mid, jpar): (*env)->CallStaticIntMethodA(env, cls, mid, jpar); e = allocVector(INTSXP, 1); INTEGER(e)[0] = r; END_RJAVA_CALL Rfreejpars(env, tmpo); releaseObject(env, cls); _prof(profReport("Method \"%s\" returned:",mnam)); return e; } case 'B': { BEGIN_RJAVA_CALL int r=(int) (o? (*env)->CallByteMethodA(env, o, mid, jpar): (*env)->CallStaticByteMethodA(env, cls, mid, jpar)); e = allocVector(INTSXP, 1); INTEGER(e)[0] = r; END_RJAVA_CALL Rfreejpars(env, tmpo); releaseObject(env, cls); _prof(profReport("Method \"%s\" returned:",mnam)); return e; } case 'C': { BEGIN_RJAVA_CALL int r=(int) (o? (*env)->CallCharMethodA(env, o, mid, jpar): (*env)->CallStaticCharMethodA(env, cls, mid, jpar)); e = allocVector(INTSXP, 1); INTEGER(e)[0] = r; END_RJAVA_CALL Rfreejpars(env, tmpo); releaseObject(env, cls); _prof(profReport("Method \"%s\" returned:",mnam)); return e; } case 'J': { BEGIN_RJAVA_CALL jlong r=o? (*env)->CallLongMethodA(env, o, mid, jpar): (*env)->CallStaticLongMethodA(env, cls, mid, jpar); e = allocVector(REALSXP, 1); REAL(e)[0]=(double)r; END_RJAVA_CALL Rfreejpars(env, tmpo); releaseObject(env, cls); _prof(profReport("Method \"%s\" returned:",mnam)); return e; } case 'S': { BEGIN_RJAVA_CALL jshort r=o? (*env)->CallShortMethodA(env, o, mid, jpar): (*env)->CallStaticShortMethodA(env, cls, mid, jpar); e = allocVector(INTSXP, 1); INTEGER(e)[0]=(int)r; END_RJAVA_CALL Rfreejpars(env, tmpo); releaseObject(env, cls); _prof(profReport("Method \"%s\" returned:",mnam)); return e; } case 'Z': { BEGIN_RJAVA_CALL jboolean r=o? (*env)->CallBooleanMethodA(env, o, mid, jpar): (*env)->CallStaticBooleanMethodA(env, cls, mid, jpar); e = allocVector(LGLSXP, 1); LOGICAL(e)[0]=(r)?1:0; END_RJAVA_CALL Rfreejpars(env, tmpo); releaseObject(env, cls); _prof(profReport("Method \"%s\" returned:",mnam)); return e; } case 'D': { BEGIN_RJAVA_CALL double r=o? (*env)->CallDoubleMethodA(env, o, mid, jpar): (*env)->CallStaticDoubleMethodA(env, cls, mid, jpar); e = allocVector(REALSXP, 1); REAL(e)[0]=r; END_RJAVA_CALL Rfreejpars(env, tmpo); releaseObject(env, cls); _prof(profReport("Method \"%s\" returned:",mnam)); return e; } case 'F': { BEGIN_RJAVA_CALL double r = (double) (o? (*env)->CallFloatMethodA(env, o, mid, jpar): (*env)->CallStaticFloatMethodA(env, cls, mid, jpar)); e = allocVector(REALSXP, 1); REAL(e)[0] = r; END_RJAVA_CALL Rfreejpars(env, tmpo); releaseObject(env, cls); _prof(profReport("Method \"%s\" returned:",mnam)); return e; } case 'L': case '[': { jobject r; BEGIN_RJAVA_CALL r = o? (*env)->CallObjectMethodA(env, o, mid, jpar): (*env)->CallStaticObjectMethodA(env, cls, mid, jpar); END_RJAVA_CALL Rfreejpars(env, tmpo); releaseObject(env, cls); _mp(MEM_PROF_OUT(" %08x LNEW object method \"%s\" result\n", (int) r, mnam)) if (!r) { _prof(profReport("Method \"%s\" returned NULL:",mnam)); return R_NilValue; } e = j2SEXP(env, r, 1); _prof(profReport("Method \"%s\" returned",mnam)); return e; } } /* switch */ _prof(profReport("Method \"%s\" has an unknown signature, not called:",mnam)); releaseObject(env, cls); error("unsupported/invalid mathod signature %s", retsig); return R_NilValue; } /** like RcallMethod but the call will be synchronized */ REPE SEXP RcallSyncMethod(SEXP par) { SEXP p=par, e; jobject o = 0; JNIEnv *env=getJNIEnv(); p=CDR(p); e=CAR(p); p=CDR(p); if (e==R_NilValue) error("RcallSyncMethod: call on a NULL object"); if (TYPEOF(e)==EXTPTRSXP) { jverify(e); o = (jobject)EXTPTR_PTR(e); } else error("RcallSyncMethod: invalid object parameter"); if (!o) error("RcallSyncMethod: attempt to call a method of a NULL object."); #ifdef RJ_DEBUG rjprintf("RcallSyncMethod: object: "); printObject(env, o); #endif if ((*env)->MonitorEnter(env, o) != JNI_OK) { REprintf("Rglue.warning: couldn't get monitor on the object, running unsynchronized.\n"); return RcallMethod(par); } e = RcallMethod(par); if ((*env)->MonitorExit(env, o) != JNI_OK) REprintf("Rglue.SERIOUS PROBLEM: MonitorExit failed, subsequent calls may cause a deadlock!\n"); return e; } /** create new object. fully-qualified class in JNI notation (string) [, constructor parameters] */ REPE SEXP RcreateObject(SEXP par) { SEXP p=par; SEXP e; int silent=0; const char *class; sig_buffer_t sig; jvalue jpar[maxJavaPars]; jobject tmpo[maxJavaPars+1]; jobject o; JNIEnv *env=getJNIEnv(); if (TYPEOF(p)!=LISTSXP) { _dbg(rjprintf("Parameter list expected but got type %d.\n",TYPEOF(p))); error_return("RcreateObject: invalid parameter"); } p=CDR(p); /* skip first parameter which is the function name */ e=CAR(p); /* second is the class name */ if (TYPEOF(e)!=STRSXP || LENGTH(e)!=1) error("RcreateObject: invalid class name"); class = CHAR_UTF8(STRING_ELT(e,0)); _dbg(rjprintf("RcreateObject: new object of class %s\n",class)); init_sigbuf(&sig); strcats(&sig, "("); p=CDR(p); Rpar2jvalue(env, p, jpar, &sig, maxJavaPars, tmpo); strcats(&sig, ")V"); _dbg(rjprintf(" constructor signature is %s\n",sig.sig)); /* look for named arguments */ while (TYPEOF(p)==LISTSXP) { if (TAG(p) && isSymbol(TAG(p))) { if (TAG(p)==install("silent") && isLogical(CAR(p)) && LENGTH(CAR(p))==1) silent=LOGICAL(CAR(p))[0]; } p=CDR(p); } BEGIN_RJAVA_CALL o = createObject(env, class, sig.sig, jpar, silent); END_RJAVA_CALL done_sigbuf(&sig); Rfreejpars(env, tmpo); if (!o) return R_NilValue; #ifdef RJ_DEBUG { jstring s=callToString(env, o); const char *c="???"; if (s) c=(*env)->GetStringUTFChars(env, s, 0); rjprintf(" new Java object [%s] reference %lx (local)\n", c, (long)o); if (s) { (*env)->ReleaseStringUTFChars(env, s, c); releaseObject(env, s); } } #endif return j2SEXP(env, o, 1); } /** returns the name of an object's class (in the form of R string) */ static SEXP getObjectClassName(JNIEnv *env, jobject o) { jclass cls; jobject r; char cn[128]; if (!o) return mkString("java/jang/Object"); cls = objectClass(env, o); if (!cls) return mkString("java/jang/Object"); r = (*env)->CallObjectMethod(env, cls, mid_getName); _mp(MEM_PROF_OUT(" %08x LNEW object getName result\n", (int) r)) if (!r) { releaseObject(env, cls); releaseObject(env, r); error("unable to get class name"); } cn[127]=0; *cn=0; { int sl = (*env)->GetStringLength(env, r); if (sl>127) { releaseObject(env, cls); releaseObject(env, r); error("class name is too long"); } if (sl) (*env)->GetStringUTFRegion(env, r, 0, sl, cn); } { char *c=cn; while(*c) { if (*c=='.') *c='/'; c++; } } releaseObject(env, cls); releaseObject(env, r); return mkString(cn); } /** creates a new jobjRef object. If klass is NULL then the class is determined from the object (if also o=NULL then the class is set to java/lang/Object) */ HIDE SEXP new_jobjRef(JNIEnv *env, jobject o, const char *klass) { SEXP oo = NEW_OBJECT(MAKE_CLASS("jobjRef")); if (!inherits(oo, "jobjRef")) error("unable to create jobjRef object"); PROTECT(oo); SET_SLOT(oo, install("jclass"), klass?mkString(klass):getObjectClassName(env, o)); SET_SLOT(oo, install("jobj"), j2SEXP(env, o, 1)); UNPROTECT(1); return oo; } /** * creates a new jclassName object. similar to what the jclassName * function does in the R side * * @param env pointer to the jni env * @param cl Class instance */ HIDE SEXP new_jclassName(JNIEnv *env, jobject/*Class*/ cl ) { SEXP oo = NEW_OBJECT(MAKE_CLASS("jclassName")); if (!inherits(oo, "jclassName")) error("unable to create jclassName object"); PROTECT(oo); SET_SLOT(oo, install("name"), getName(env, cl) ); SET_SLOT(oo, install("jobj"), new_jobjRef( env, cl, "java/lang/Class" ) ); UNPROTECT(1); return oo; } /** Calls the Class.getName method and return the result as an R STRSXP */ HIDE SEXP getName( JNIEnv *env, jobject/*Class*/ cl){ char cn[128]; jstring r = (*env)->CallObjectMethod(env, cl, mid_getName); cn[127]=0; *cn=0; int sl = (*env)->GetStringLength(env, r); if (sl>127) { error("class name is too long"); } if (sl) (*env)->GetStringUTFRegion(env, r, 0, sl, cn); char *c=cn; while(*c) { if (*c=='.') *c='/'; c++; } SEXP res = PROTECT( mkString(cn ) ); releaseObject(env, r); UNPROTECT(1); /* res */ return res; } static SEXP new_jarrayRef(JNIEnv *env, jobject a, const char *sig) { /* it is too tedious to try to do this in C, so we use 'new' R function instead */ /* SEXP oo = eval(LCONS(install("new"),LCONS(mkString("jarrayRef"),R_NilValue)), R_GlobalEnv); */ SEXP oo = NEW_OBJECT(MAKE_CLASS("jarrayRef")); /* .. and set the slots in C .. */ if (! IS_JARRAYREF(oo) ) error("unable to create an array"); PROTECT(oo); SET_SLOT(oo, install("jobj"), j2SEXP(env, a, 1)); SET_SLOT(oo, install("jclass"), mkString(sig)); SET_SLOT(oo, install("jsig"), mkString(sig)); UNPROTECT(1); return oo; } /** * Creates a reference to a rectangular java array. * * @param env * @param a the java object * @param sig signature (class of the array object) * @param dim dimension vector */ static SEXP new_jrectRef(JNIEnv *env, jobject a, const char *sig, SEXP dim ) { /* it is too tedious to try to do this in C, so we use 'new' R function instead */ /* SEXP oo = eval(LCONS(install("new"),LCONS(mkString("jrectRef"),R_NilValue)), R_GlobalEnv); */ SEXP oo = NEW_OBJECT(MAKE_CLASS("jrectRef")); /* .. and set the slots in C .. */ if (! IS_JRECTREF(oo) ) error("unable to create an array"); PROTECT(oo); SET_SLOT(oo, install("jobj"), j2SEXP(env, a, 1)); SET_SLOT(oo, install("jclass"), mkString(sig)); SET_SLOT(oo, install("jsig"), mkString(sig)); SET_SLOT(oo, install("dimension"), dim); UNPROTECT(1); /* oo */ return oo; } /* this does not take care of multi dimensional arrays properly */ /** * Creates a one dimensionnal java array * * @param an R list or vector * @param cl the class name */ REPC SEXP RcreateArray(SEXP ar, SEXP cl) { JNIEnv *env=getJNIEnv(); if (ar==R_NilValue) return R_NilValue; switch(TYPEOF(ar)) { case INTSXP: { if (inherits(ar, "jbyte")) { jbyteArray a = newByteArrayI(env, INTEGER(ar), LENGTH(ar)); if (!a) error("unable to create a byte array"); return new_jarrayRef(env, a, "[B" ) ; } else if (inherits(ar, "jchar")) { jcharArray a = newCharArrayI(env, INTEGER(ar), LENGTH(ar)); if (!a) error("unable to create a char array"); return new_jarrayRef(env, a, "[C" ); } else { jintArray a = newIntArray(env, INTEGER(ar), LENGTH(ar)); if (!a) error("unable to create an integer array"); return new_jarrayRef(env, a, "[I"); } } case REALSXP: { if (inherits(ar, "jfloat")) { jfloatArray a = newFloatArrayD(env, REAL(ar), LENGTH(ar)); if (!a) error("unable to create a float array"); return new_jarrayRef(env, a, "[F"); } else if (inherits(ar, "jlong")){ jlongArray a = newLongArrayD(env, REAL(ar), LENGTH(ar)); if (!a) error("unable to create a long array"); return new_jarrayRef(env, a, "[J"); } else { jdoubleArray a = newDoubleArray(env, REAL(ar), LENGTH(ar)); if (!a) error("unable to create double array"); return new_jarrayRef(env, a, "[D"); } } case STRSXP: { jobjectArray a = (*env)->NewObjectArray(env, LENGTH(ar), javaStringClass, 0); int i = 0; if (!a) error("unable to create a string array"); while (iSetObjectArrayElement(env, a, i, so); releaseObject(env, so); i++; } return new_jarrayRef(env, a, "[Ljava/lang/String;"); } case LGLSXP: { /* ASSUMPTION: LOGICAL()=int* */ jbooleanArray a = newBooleanArrayI(env, LOGICAL(ar), LENGTH(ar)); if (!a) error("unable to create a boolean array"); return new_jarrayRef(env, a, "[Z"); } case VECSXP: { int i=0; jclass ac = javaObjectClass; const char *sigName = 0; char buf[256]; while (i0) { const char *cname = CHAR_UTF8(STRING_ELT(cl, 0)); if (cname) { ac = findClass(env, cname); if (!ac) error("Cannot find class %s.", cname); if (strlen(cname)<253) { /* it's valid to have [* for class name (for mmulti-dim arrays), but then we cannot add [L..; */ if (*cname == '[') { /* we have to add [ prefix to the signature */ buf[0] = '['; strcpy(buf+1, cname); } else { buf[0] = '['; buf[1] = 'L'; strcpy(buf+2, cname); strcat(buf,";"); } sigName = buf; } } } /* if contents class specified */ { jobjectArray a = (*env)->NewObjectArray(env, LENGTH(ar), ac, 0); _mp(MEM_PROF_OUT(" %08x LNEW object[%d]\n", (int)a, LENGTH(ar))) if (ac != javaObjectClass) releaseObject(env, ac); i=0; if (!a) error("Cannot create array of objects."); while (i < LENGTH(ar)) { SEXP e = VECTOR_ELT(ar, i); jobject o = 0; if (e != R_NilValue) { SEXP sref = GET_SLOT(e, install("jobj")); if (sref && TYPEOF(sref) == EXTPTRSXP) { jverify(sref); o = (jobject)EXTPTR_PTR(sref); } } (*env)->SetObjectArrayElement(env, a, i, o); i++; } return new_jarrayRef(env, a, sigName?sigName:"[Ljava/lang/Object;"); } } case RAWSXP: { jbyteArray a = newByteArray(env, RAW(ar), LENGTH(ar)); if (!a) error("unable to create a byte array"); return new_jarrayRef(env, a, "[B"); } } error("Unsupported type to create Java array from."); return R_NilValue; } /** check whether there is an exception pending and return the exception if any (NULL otherwise) */ REPC SEXP RpollException() { JNIEnv *env=getJNIEnv(); jthrowable t; BEGIN_RJAVA_CALL t=(*env)->ExceptionOccurred(env); END_RJAVA_CALL _mp(MEM_PROF_OUT(" %08x LNEW RpollException throwable\n", (int)t)) return t?j2SEXP(env, t, 1):R_NilValue; } /** clear any pending exceptions */ REP void RclearException() { JNIEnv *env=getJNIEnv(); BEGIN_RJAVA_CALL (*env)->ExceptionClear(env); END_RJAVA_CALL } REPC SEXP javaObjectCache(SEXP o, SEXP what) { if (TYPEOF(o) != EXTPTRSXP) error("invalid object"); if (TYPEOF(what) == RAWSXP || what == R_NilValue) { /* set PROT to the serialization of NULL */ SETCDR(o, what); return what; } if (TYPEOF(what) == LGLSXP) return EXTPTR_PROT(o); error("invalid argument"); return R_NilValue; } REPC SEXP RthrowException(SEXP ex) { JNIEnv *env=getJNIEnv(); jthrowable t=0; SEXP exr; int tr=0; SEXP res; if (!inherits(ex, "jobjRef")) error("Invalid throwable object."); exr=GET_SLOT(ex, install("jobj")); if (exr && TYPEOF(exr)==EXTPTRSXP) { jverify(exr); t=(jthrowable)EXTPTR_PTR(exr); } if (!t) error("Throwable must be non-null."); BEGIN_RJAVA_CALL tr = (*env)->Throw(env, t); END_RJAVA_CALL res = allocVector(INTSXP, 1); INTEGER(res)[0]=tr; return res; } rJava/src/jvm-w32/0000755000176200001440000000000012256051760013315 5ustar liggesusersrJava/src/jvm-w32/Makefile0000644000176200001440000000151212256051771014756 0ustar liggesusers# helper tools and libs for building and running rJava for Windows # Author: Simon Urbanek # with contributions from Brian Ripley include $(R_HOME)/etc$(R_ARCH)/Makeconf TARGETS=libjvm.dll.a findjava.exe # libjvm.dll.a - wrapper lib for jvm.dll from Java # findjava.exe - helper tool to find the current JDK from the registry all: $(TARGETS) # detect 64-bit Windows ifeq ($(strip $(shell $(R_HOME)/bin/R --slave -e 'cat(.Machine$$sizeof.pointer)')),8) JVM64DEF=64 endif libjvm.dll.a: jvm$(JVM64DEF).def $(DLLTOOL) --input-def $^ --kill-at --dllname jvm.dll --output-lib $@ # compile findjava.exe from source - no magic here, no special libs necessary findjava.o: findjava.c $(CC) -O2 -c -o $@ $^ findjava.exe: findjava.o $(CC) -s -o $@ $^ # just cleanup everything clean: rm -f *.o *~ $(TARGETS) .PHONY: all clean rJava/src/jvm-w32/jvm.def0000644000176200001440000000016512256051760014573 0ustar liggesusersLIBRARY JVM.DLL EXPORTS JNI_CreateJavaVM@12 JNI_GetCreatedJavaVMs@12 JNI_GetDefaultJavaVMInitArgs@4 rJava/src/jvm-w32/config.h0000644000176200001440000000014712256051771014737 0ustar liggesusers/* fall-back setting on Widnows */ /* assume Sun/Oracle JVM which supports -Xrs */ #define HAVE_XRS 1 rJava/src/jvm-w32/findjava.c0000644000176200001440000000507312256051771015252 0ustar liggesusers#include #include #include static char RegStrBuf[32768], dbuf[32768]; int main(int argc, char **argv) { int i=0, doit=0; DWORD t,s=32767; HKEY k; HKEY root=HKEY_LOCAL_MACHINE; char *javakey="Software\\JavaSoft\\Java Runtime Environment"; /* JAVA_HOME can override our detection - but we still post-process it */ if (getenv("JAVA_HOME")) { strcpy(RegStrBuf,getenv("JAVA_HOME")); } else { #ifdef FINDJRE if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,javakey,0,KEY_QUERY_VALUE,&k)!=ERROR_SUCCESS || RegQueryValueEx(k,"CurrentVersion",0,&t,RegStrBuf,&s)!=ERROR_SUCCESS) { #endif javakey="Software\\JavaSoft\\Java Development Kit"; s=32767; if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,javakey,0,KEY_QUERY_VALUE,&k)!=ERROR_SUCCESS || RegQueryValueEx(k,"CurrentVersion",0,&t,RegStrBuf,&s)!=ERROR_SUCCESS) { fprintf(stderr, "ERROR*> JavaSoft\\{JRE|JDK} can't open registry keys.\n"); /* MessageBox(wh, "Can't find Sun's Java runtime.\nPlease install Sun's J2SE JRE or JDK 1.4.2 or later (see http://java.sun.com/).","Can't find Sun's Java",MB_OK|MB_ICONERROR); */ return -1; } #ifdef FINDJRE } #endif RegCloseKey(k); s=32767; strcpy(dbuf,javakey); strcat(dbuf,"\\"); strcat(dbuf,RegStrBuf); javakey=(char*) malloc(strlen(dbuf)+1); strcpy(javakey, dbuf); if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,javakey,0,KEY_QUERY_VALUE,&k)!=ERROR_SUCCESS || RegQueryValueEx(k,"JavaHome",0,&t,RegStrBuf,&s)!=ERROR_SUCCESS) { fprintf(stderr, "There's no JavaHome value in the JDK/JRE registry key.\n"); /* MessageBox(wh, "Can't find Java home path. Maybe your JRE is too old.\nPlease install Sun's J2SE JRE or SDK 1.4.2 (see http://java.sun.com/).","Can't find Sun's Java",MB_OK|MB_ICONERROR); */ return -1; } RegCloseKey(k); } /*--- post-processing according to supplied flags --*/ /* -a = automagic, i.e. use short name only if the name contains spaces */ i=1; while (i #ifdef WIN32 #include #include char RegStrBuf[32768]; SEXP RegGetStrValue(SEXP par) { SEXP res=R_NilValue; DWORD t,s=32767; HKEY k; char *key=CHAR(STRING_ELT(par, 0)); char *val=CHAR(STRING_ELT(par, 1)); RegStrBuf[32767]=*RegStrBuf=0; /* printf("RegGetStrValue(\"%s\",\"%s\")\n",key,val); */ if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,key,0,KEY_QUERY_VALUE,&k)!=ERROR_SUCCESS || RegQueryValueEx(k,val,0,&t,RegStrBuf,&s)!=ERROR_SUCCESS) return res; PROTECT(res = allocVector(STRSXP, 1)); SET_STRING_ELT(res, 0, mkChar(RegStrBuf)); UNPROTECT(1); return res; }; #else /* all functions return NULL since they are not supported on non-Win32 platforms */ SEXP RegGetStrValue(SEXP par) { return R_NilValue; }; #endif rJava/src/fields.c0000644000176200001440000002530312256051771013527 0ustar liggesusers/* R-callable functions to get/set fields * * rJava R/Java interface (C)Copyright 2003-2007 Simon Urbanek * (see rJava project root for licensing details) */ #include "rJava.h" #include static char *classToJNI(const char *cl) { if (*cl=='[') { char *d = strdup(cl); char *c = d; while (*c) { if (*c=='.') *c='/'; c++; } return d; } if (!strcmp(cl, "boolean")) return strdup("Z"); if (!strcmp(cl, "byte")) return strdup("B"); if (!strcmp(cl, "int")) return strdup("I"); if (!strcmp(cl, "long")) return strdup("J"); if (!strcmp(cl, "double")) return strdup("D"); if (!strcmp(cl, "short")) return strdup("S"); if (!strcmp(cl, "float")) return strdup("F"); if (!strcmp(cl, "char")) return strdup("C"); /* anything else is a real class -> wrap into L..; */ char *jc = malloc(strlen(cl)+3); *jc='L'; strcpy(jc+1, cl); strcat(jc, ";"); { char *c=jc; while (*c) { if (*c=='.') *c='/'; c++; } } return jc; } /* find field signature using reflection. Basically it is the same as: cls.getField(fnam).getType().getName() + class2JNI mangling */ /* TODO; use the mid_RJavaTools_getFieldTypeName method ID instead */ static char *findFieldSignature(JNIEnv *env, jclass cls, const char *fnam) { char *detsig = 0; jstring s = newString(env, fnam); if (s) { jobject f = (*env)->CallObjectMethod(env, cls, mid_getField, s); _mp(MEM_PROF_OUT(" %08x LNEW object getField result value\n", (int) f)) if (f) { jobject fcl = (*env)->CallObjectMethod(env, f, mid_getType); _mp(MEM_PROF_OUT(" %08x LNEW object getType result value\n", (int) f)) if (fcl) { jobject fcns = (*env)->CallObjectMethod(env, fcl, mid_getName); releaseObject(env, fcl); if (fcns) { const char *fcn = (*env)->GetStringUTFChars(env, fcns, 0); detsig = classToJNI(fcn); _dbg(Rprintf("class '%s' -> '%s' sig\n", fcn, detsig)); (*env)->ReleaseStringUTFChars(env, fcns, fcn); releaseObject(env, fcns); /* fid = (*env)->FromReflectedField(env, f); */ } } else releaseObject(env, fcl); releaseObject(env, f); } releaseObject(env, s); } return detsig; } /** get value of a field of an object or class object (int), return signature (string), field name (string) arrays and objects are returned as IDs (hence not evaluated) class name can be in either form / or . */ REPC SEXP RgetField(SEXP obj, SEXP sig, SEXP name, SEXP trueclass) { jobject o = 0; SEXP e; const char *retsig, *fnam; char *clnam = 0, *detsig = 0; jfieldID fid; jclass cls; int tc = asInteger(trueclass); JNIEnv *env=getJNIEnv(); if (obj == R_NilValue) return R_NilValue; if ( IS_JOBJREF(obj) ) obj = GET_SLOT(obj, install("jobj")); if (TYPEOF(obj)==EXTPTRSXP) { jverify(obj); o=(jobject)EXTPTR_PTR(obj); } else if (TYPEOF(obj)==STRSXP && LENGTH(obj)==1) clnam = strdup(CHAR(STRING_ELT(obj, 0))); else error("invalid object parameter"); if (!o && !clnam) error("cannot access a field of a NULL object"); #ifdef RJ_DEBUG if (o) { rjprintf("RgetField.object: "); printObject(env, o); } else { rjprintf("RgetField.class: %s\n", clnam); } #endif if (o) cls = objectClass(env, o); else { char *c = clnam; while(*c) { if (*c=='/') *c='.'; c++; } cls = findClass(env, clnam); free(clnam); if (!cls) { error("cannot find class %s", CHAR(STRING_ELT(obj, 0))); } } if (!cls) error("cannot determine object class"); #ifdef RJ_DEBUG rjprintf("RgetField.class: "); printObject(env, cls); #endif if (TYPEOF(name)!=STRSXP || LENGTH(name)!=1) { releaseObject(env, cls); error("invalid field name"); } fnam = CHAR(STRING_ELT(name,0)); if (sig == R_NilValue) { retsig = detsig = findFieldSignature(env, cls, fnam); if (!retsig) { releaseObject(env, cls); error("unable to detect signature for field '%s'", fnam); } } else { if (TYPEOF(sig)!=STRSXP || LENGTH(sig)!=1) { releaseObject(env, cls); error("invalid signature parameter"); } retsig = CHAR(STRING_ELT(sig,0)); } _dbg(rjprintf("field %s signature is %s\n",fnam,retsig)); if (o) { /* first try non-static fields */ fid = (*env)->GetFieldID(env, cls, fnam, retsig); checkExceptionsX(env, 1); if (!fid) { /* if that fails, try static ones */ o = 0; fid = (*env)->GetStaticFieldID(env, cls, fnam, retsig); } } else /* no choice if the object was a string */ fid = (*env)->GetStaticFieldID(env, cls, fnam, retsig); if (!fid) { checkExceptionsX(env, 1); releaseObject(env, cls); if (detsig) free(detsig); error("RgetField: field %s not found", fnam); } switch (*retsig) { case 'I': { int r=o? (*env)->GetIntField(env, o, fid): (*env)->GetStaticIntField(env, cls, fid); e = allocVector(INTSXP, 1); INTEGER(e)[0] = r; releaseObject(env, cls); if (detsig) free(detsig); return e; } case 'S': { jshort r=o? (*env)->GetShortField(env, o, fid): (*env)->GetStaticShortField(env, cls, fid); e = allocVector(INTSXP, 1); INTEGER(e)[0] = r; releaseObject(env, cls); if (detsig) free(detsig); return e; } case 'C': { int r=(int) (o? (*env)->GetCharField(env, o, fid): (*env)->GetStaticCharField(env, cls, fid)); e = allocVector(INTSXP, 1); INTEGER(e)[0] = r; releaseObject(env, cls); if (detsig) free(detsig); return e; } case 'B': { int r=(int) (o? (*env)->GetByteField(env, o, fid): (*env)->GetStaticByteField(env, cls, fid)); e = allocVector(INTSXP, 1); INTEGER(e)[0] = r; releaseObject(env, cls); if (detsig) free(detsig); return e; } case 'J': { jlong r=o? (*env)->GetLongField(env, o, fid): (*env)->GetStaticLongField(env, cls, fid); e = allocVector(REALSXP, 1); REAL(e)[0] = (double)r; releaseObject(env, cls); if (detsig) free(detsig); return e; } case 'Z': { jboolean r=o? (*env)->GetBooleanField(env, o, fid): (*env)->GetStaticBooleanField(env, cls, fid); e = allocVector(LGLSXP, 1); LOGICAL(e)[0] = r?1:0; releaseObject(env, cls); if (detsig) free(detsig); return e; } case 'D': { double r=o? (*env)->GetDoubleField(env, o, fid): (*env)->GetStaticDoubleField(env, cls, fid); e = allocVector(REALSXP, 1); REAL(e)[0] = r; releaseObject(env, cls); if (detsig) free(detsig); return e; } case 'F': { double r = (double) (o? (*env)->GetFloatField(env, o, fid): (*env)->GetStaticFloatField(env, cls, fid)); e = allocVector(REALSXP, 1); REAL(e)[0] = r; releaseObject(env, cls); if (detsig) free(detsig); return e; } case 'L': case '[': { SEXP rv; jobject r = o? (*env)->GetObjectField(env, o, fid): (*env)->GetStaticObjectField(env, cls, fid); _mp(MEM_PROF_OUT(" %08x LNEW field value\n", (int) r)) releaseObject(env, cls); if (tc) { if (detsig) free(detsig); return new_jobjRef(env, r, 0); } if (*retsig=='L') { /* need to fix the class name */ char *d = strdup(retsig), *c = d; while (*c) { if (*c==';') { *c=0; break; }; c++; } rv = new_jobjRef(env, r, d+1); free(d); } else rv = new_jobjRef(env, r, retsig); if (detsig) free(detsig); return rv; } } /* switch */ releaseObject(env, cls); if (detsig) { free(detsig); error("unknown field signature"); } error("unknown field signature '%s'", retsig); return R_NilValue; } REPC SEXP RsetField(SEXP ref, SEXP name, SEXP value) { jobject o = 0, otr; SEXP obj = ref; const char *fnam; sig_buffer_t sig; char *clnam = 0; jfieldID fid; jclass cls; jvalue jval; JNIEnv *env=getJNIEnv(); if (TYPEOF(name)!=STRSXP && LENGTH(name)!=1) error("invalid field name"); fnam = CHAR(STRING_ELT(name, 0)); if (obj == R_NilValue) error("cannot set a field of a NULL object"); if (IS_JOBJREF(obj)) obj = GET_SLOT(obj, install("jobj")); if (TYPEOF(obj)==EXTPTRSXP) { jverify(obj); o=(jobject)EXTPTR_PTR(obj); } else if (TYPEOF(obj)==STRSXP && LENGTH(obj)==1) clnam = strdup(CHAR(STRING_ELT(obj, 0))); else error("invalid object parameter"); if (!o && !clnam) error("cannot set a field of a NULL object"); #ifdef RJ_DEBUG if (o) { rjprintf("RsetField.object: "); printObject(env, o); } else { rjprintf("RsetField.class: %s\n", clnam); } #endif if (o) cls = objectClass(env, o); else { char *c = clnam; while(*c) { if (*c=='/') *c='.'; c++; } cls = findClass(env, clnam); if (!cls) { error("cannot find class %s", CHAR(STRING_ELT(obj, 0))); } } if (!cls) error("cannot determine object class"); #ifdef RJ_DEBUG rjprintf("RsetField.class: "); printObject(env, cls); #endif init_sigbuf(&sig); jval = R1par2jvalue(env, value, &sig, &otr); if (o) { fid = (*env)->GetFieldID(env, cls, fnam, sig.sig); if (!fid) { checkExceptionsX(env, 1); o = 0; fid = (*env)->GetStaticFieldID(env, cls, fnam, sig.sig); } } else fid = (*env)->GetStaticFieldID(env, cls, fnam, sig.sig); if (!fid) { checkExceptionsX(env, 1); releaseObject(env, cls); if (otr) releaseObject(env, otr); done_sigbuf(&sig); error("cannot find field %s with signature %s", fnam, sig.sigbuf); } switch(sig.sig[0]) { case 'Z': o?(*env)->SetBooleanField(env, o, fid, jval.z): (*env)->SetStaticBooleanField(env, cls, fid, jval.z); break; case 'C': o?(*env)->SetCharField(env, o, fid, jval.c): (*env)->SetStaticCharField(env, cls, fid, jval.c); break; case 'B': o?(*env)->SetByteField(env, o, fid, jval.b): (*env)->SetStaticByteField(env, cls, fid, jval.b); break; case 'I': o?(*env)->SetIntField(env, o, fid, jval.i): (*env)->SetStaticIntField(env, cls, fid, jval.i); break; case 'D': o?(*env)->SetDoubleField(env, o, fid, jval.d): (*env)->SetStaticDoubleField(env, cls, fid, jval.d); break; case 'F': o?(*env)->SetFloatField(env, o, fid, jval.f): (*env)->SetStaticFloatField(env, cls, fid, jval.f); break; case 'J': o?(*env)->SetLongField(env, o, fid, jval.j): (*env)->SetStaticLongField(env, cls, fid, jval.j); break; case 'S': o?(*env)->SetShortField(env, o, fid, jval.s): (*env)->SetStaticShortField(env, cls, fid, jval.s); break; case '[': case 'L': o?(*env)->SetObjectField(env, o, fid, jval.l): (*env)->SetStaticObjectField(env, cls, fid, jval.l); break; default: releaseObject(env, cls); if (otr) releaseObject(env, otr); done_sigbuf(&sig); error("unknown field sighanture %s", sig.sigbuf); } done_sigbuf(&sig); releaseObject(env, cls); if (otr) releaseObject(env, otr); return ref; } rJava/src/config.h.in0000644000176200001440000000473712256051760014146 0ustar liggesusers/* src/config.h.in. Generated from configure.ac by autoheader. */ /* define if callbacks support is enabled. */ #undef ENABLE_JRICB /* Define to 1 if you have the declaration of `siglongjmp', and to 0 if you don't. */ #undef HAVE_DECL_SIGLONGJMP /* Define to 1 if you have the declaration of `sigsetjmp', and to 0 if you don't. */ #undef HAVE_DECL_SIGSETJMP /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H /* Define if you have POSIX.1 compatible sigsetjmp/siglongjmp. */ #undef HAVE_POSIX_SETJMP /* Define to 1 when static inline works */ #undef HAVE_STATIC_INLINE /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H /* Define to 1 if you have the header file. */ #undef HAVE_STRINGS_H /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STAT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TIME_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H /* Define to 1 if you have that is POSIX.1 compatible. */ #undef HAVE_SYS_WAIT_H /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H /* Set if the Java parameter -Xrs is supported */ #undef HAVE_XRS /* Set if caching JNI environment is enabled. */ #undef JNI_CACHE /* memory profiling is enabled when defined */ #undef MEMPROF /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT /* Define to the full name of this package. */ #undef PACKAGE_NAME /* Define to the full name and version of this package. */ #undef PACKAGE_STRING /* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME /* Define to the home page for this package. */ #undef PACKAGE_URL /* Define to the version of this package. */ #undef PACKAGE_VERSION /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS /* Set if threading support should be enabled. */ #undef THREADS /* Define to 1 if you can safely include both and . */ #undef TIME_WITH_SYS_TIME /* Set if headless mode is to be used when starting the JVM */ #undef USE_HEADLESS_INIT /* Define to empty if `const' does not conform to ANSI C. */ #undef const rJava/src/install.libs.R0000644000176200001440000000526112256051760014635 0ustar liggesusers## the first part just replicates the default installation of libs libarch <- if (nzchar(R_ARCH)) paste("libs", R_ARCH, sep='') else "libs" dest <- file.path(R_PACKAGE_DIR, libarch) files <- Sys.glob(paste("*", SHLIB_EXT, sep='')) if (length(files)) { dir.create(dest, recursive = TRUE, showWarnings = FALSE) file.copy(files, dest, overwrite = TRUE) if (nzchar(Sys.getenv("PKG_MAKE_DSYM")) && length(grep("^darwin", R.version$os))) { message('generating debug symbols (dSYM)') dylib <- Sys.glob(paste(dest, "/*", SHLIB_EXT, sep='')) if (length(dylib)) for (file in dylib) system(paste("dsymutil ", file, sep='')) } } # just a wrapper to system() that shows what we are doing ... sys <- function(x, ...) { message(x) s <- system(x, ...) # if (!isTRUE(s == 0L)) message("-> FAILED") s } ## the next part is about JRI ## on OS X we need to merge architectures into one fat file if (length(grep("^darwin", R.version$os))) { is.fat <- function(fn) { a <- 0L; try({f <- file(fn, "rb"); a <- readBin(f, 1L, 1L); close(f)}, silent=TRUE); isTRUE(a[1] == -1095041334L || a[1] == -889275714L) } ## fat magic is 0xCAFEBABE - either endianness jni <- "../jri/libjri.jnilib" if (isTRUE(file.exists(jni))) { ## continue only if JRI was actually compiled dir.create(file.path(R_PACKAGE_DIR, "jri"), recursive = TRUE, showWarnings = FALSE) dest <- file.path(R_PACKAGE_DIR, "jri", "libjri.jnilib") if (is.fat(jni) || !file.exists(dest)) { ## if the new file is fat we assume it has all archs so we copy; if there is no dest, copy as well file.copy(jni, dest, overwrite = TRUE) } else { ## new file is single arch, so merge ## we try lipo -create first and fall back to -replace if it doesn't work (becasue the arch exists already) if (sys(paste("/usr/bin/lipo -create", shQuote(dest), jni, "-o", shQuote(dest), ">/dev/null 2>&1")) != 0) { if (is.fat(dest)) { # if the file is fat, replace, otherwise it means we have the same arch so copy arch <- gsub("/", "", R_ARCH, fixed=TRUE) sys(paste("/usr/bin/lipo -replace", arch, jni, shQuote(dest), "-o", shQuote(dest), ">/dev/null 2>&1")) } else file.copy(jni, dest, overwrite = TRUE) } } } } else { ## on other platforms we simply install in jri$(R_ARCH) jri <- if (WINDOWS) "jri.dll" else "libjri.so" jni <- file.path("..", "jri", jri) if (isTRUE(file.exists(jni))) { ## continue only if JRI was actually compiled libarch <- if (nzchar(R_ARCH)) paste("jri", R_ARCH, sep='') else "jri" dir.create(file.path(R_PACKAGE_DIR, libarch), recursive = TRUE, showWarnings = FALSE) dest <- file.path(R_PACKAGE_DIR, libarch, jri) file.copy(jni, dest, overwrite = TRUE) } } rJava/src/jri_glue.c0000644000176200001440000000537712256051771014072 0ustar liggesusers#include #include #include "rJava.h" /* creates a reference to an R object on the Java side 1) lock down the object in R 2) call new Rengine(eng,robj) {or any other class such as REXPReference for REngine API} */ REPC SEXP PushToREXP(SEXP clname, SEXP eng, SEXP engCl, SEXP robj, SEXP doConv) { char sig[128]; jvalue jpar[4]; jobject o; int convert = (doConv == R_NilValue) ? -1 : asInteger(doConv); JNIEnv *env=getJNIEnv(); const char *cName; if (!isString(clname) || LENGTH(clname)!=1) error("invalid class name"); if (!isString(engCl) || LENGTH(engCl)!=1) error("invalid engine class name"); if (TYPEOF(eng)!=EXTPTRSXP) error("invalid engine object"); R_PreserveObject(robj); sig[127]=0; cName = CHAR(STRING_ELT(clname,0)); jpar[0].l = (jobject)EXTPTR_PTR(eng); jpar[1].j = (jlong) robj; if (convert == -1) snprintf(sig,127,"(L%s;J)V",CHAR(STRING_ELT(engCl,0))); else { snprintf(sig,127,"(L%s;JZ)V",CHAR(STRING_ELT(engCl,0))); jpar[2].z = (jboolean) convert; } o = createObject(env, cName, sig, jpar, 1); if (!o) error("Unable to create Java object"); return j2SEXP(env, o, 1); /* ok, some thoughts on mem mgmt - j2SEXP registers a finalizer. But I believe that is ok, because the pushed reference is useless until it is passed as an argument to some Java method. And then, it will have another reference which will prevent the Java side from being collected. The R-side reference may be gone, but that's ok, because it's the Java finalizer that needs to clean up the pushed R object and for that it doesn't need the proxy object at all. This is the reason why RReleaseREXP uses EXTPTR - all the Java finalizaer has to do is to call RReleaseREXP(self). For that it can create a fresh proxy object containing the REXP. But here comes he crux - this proxy cannot again create a reference - it must be plain pass-through, so this part needs to be verified. Note: as of REngine API the references assume protected objects and use rniRelease to clean up, so RReleaseREXP won't be called and is not needed. That is good, because RReleaseREXP assumes JRI objects whereas REngine will create REXPReference (no xp there). However, if we ever change that REXPReference assumption we will be in trouble. */ } /* this is pretty much hard-coded for now - it's picking "xp" attribute */ REPC SEXP RReleaseREXP(SEXP ptr) { jobject o; if (TYPEOF(ptr)==EXTPTRSXP) error("invalid object"); o = (jobject)EXTPTR_PTR(ptr); { JNIEnv *env = getJNIEnv(); jclass cls = (*env)->GetObjectClass(env, o); if (cls) { jfieldID fid=(*env)->GetFieldID(env,cls,"xp","J"); if (fid) { jlong r = (*env)->GetLongField(env, o, fid); SEXP x = (SEXP) r; if (x) R_ReleaseObject(x); } } } return R_NilValue; } rJava/src/loader.c0000644000176200001440000000534512256051771013533 0ustar liggesusers/* functions dealing with the rJava class loader * * rJava R/Java interface (C)Copyright 2003-2007 Simon Urbanek * (see rJava project root for licensing details) */ #include "rJava.h" jclass clClassLoader = (jclass) 0; jobject oClassLoader = (jobject) 0; HIDE int initClassLoader(JNIEnv *env, jobject cl) { clClassLoader = (*env)->NewGlobalRef(env, (*env)->GetObjectClass(env, cl)); /* oClassLoader = (*env)->NewGlobalRef(env, cl); */ oClassLoader = cl; #ifdef DEBUG_CL printf("initClassLoader: cl=%x, clCl=%x, jcl=%x\n", oClassLoader, clClassLoader, javaClassClass); #endif return 0; } REPC SEXP RJava_set_class_loader(SEXP ldr) { JNIEnv *env=getJNIEnv(); if (TYPEOF(ldr) != EXTPTRSXP) error("invalid type"); if (!env) error("VM not initialized"); jverify(ldr); initClassLoader(env, (jobject)EXTPTR_PTR(ldr)); return R_NilValue; } REPC SEXP RJava_primary_class_loader() { JNIEnv *env=getJNIEnv(); jclass cl = (*env)->FindClass(env, "RJavaClassLoader"); _dbg(Rprintf("RJava_primary_class_loader, cl = %x\n", (int) cl)); if (cl) { jmethodID mid = (*env)->GetStaticMethodID(env, cl, "getPrimaryLoader", "()LRJavaClassLoader;"); _dbg(Rprintf(" - mid = %d\n", (int) mid)); if (mid) { jobject o = (*env)->CallStaticObjectMethod(env, cl, mid); _dbg(Rprintf(" - call result = %x\n", (int) o)); if (o) { return j2SEXP(env, o, 1); } } } checkExceptionsX(env, 1); #ifdef NEW123 jclass cl = (*env)->FindClass(env, "JRIBootstrap"); Rprintf("RJava_primary_class_loader, cl = %x\n", (int) cl); if (cl) { jmethodID mid = (*env)->GetStaticMethodID(env, cl, "getBootRJavaLoader", "()Ljava/lang/Object;"); Rprintf(" - mid = %d\n", (int) mid); if (mid) { jobject o = (*env)->CallStaticObjectMethod(env, cl, mid); Rprintf(" - call result = %x\n", (int) o); if (o) { return j2SEXP(env, o, 1); } } } checkExceptionsX(env, 1); #endif return R_NilValue; } REPC SEXP RJava_new_class_loader(SEXP p1, SEXP p2) { JNIEnv *env=getJNIEnv(); const char *c1 = CHAR(STRING_ELT(p1, 0)); const char *c2 = CHAR(STRING_ELT(p2, 0)); jstring s1 = newString(env, c1); jstring s2 = newString(env, c2); jclass cl = (*env)->FindClass(env, "RJavaClassLoader"); _dbg(Rprintf("find rJavaClassLoader: %x\n", (int) cl)); jmethodID mid = (*env)->GetMethodID(env, cl, "", "(Ljava/lang/String;Ljava/lang/String;)V"); _dbg(Rprintf("constructor mid: %x\n", mid)); jobject o = (*env)->NewObject(env, cl, mid, s1, s2); _dbg(Rprintf("new object: %x\n", o)); o = makeGlobal(env, o); _dbg(Rprintf("calling initClassLoader\n")); initClassLoader(env, o); releaseObject(env, s1); releaseObject(env, s2); releaseObject(env, cl); return R_NilValue; } rJava/src/rJava.h0000644000176200001440000001620312256051771013330 0ustar liggesusers#ifndef __RJAVA_H__ #define __RJAVA_H__ #define RJAVA_VER 0x000906 /* rJava v0.9-6 */ /* important changes between versions: 3.0 - adds compiler 2.0 1.0 0.9 - rectangular arrays, flattening, import (really introduced in later 0.8 versions but they broke the API compatibility so 0.9 attempts to fix that) 0.8 - new exception handling using Exception condition 0.7 - new reflection code, new REngine API (JRI) 0.6 - adds serialization, (auto-)deserialization and cache 0.5 - integrates JRI, adds callbacks and class-loader 0.4 - includes JRI 0.3 - uses EXTPTR in jobj slot, adds finalizers 0.2 - uses S4 classes 0.1 - first public release */ #include #include #include #include #include #include /* flags used in function declarations: HIDE - hidden (used internally in rJava only) REP - R Entry Point - .C convention REPE - R Entry Point - .External convention REPC - R Entry Point - .Call convention - inline and/or hide functions that are not externally visible - automatically generate symbol registration table */ #ifdef ONEFILE #ifdef HAVE_STATIC_INLINE #define HIDE static inline #else #define HIDE static #endif #else #define HIDE #endif #define REP #define REPE #define REPC #if defined WIN32 && ! defined Win32 #define Win32 #endif #if defined Win32 && ! defined WIN32 #define WIN32 #endif #include "config.h" #ifdef MEMPROF #include #include extern FILE* memprof_f; #define _mp(X) X #define MEM_PROF_OUT(X ...) { if (memprof_f) { long t = time(0); fprintf(memprof_f, "<%08x> %x:%02d ", (int) env, t/60, t%60); fprintf(memprof_f, X); }; } #else #define _mp(X) #endif /* debugging output (enable with -DRJ_DEBUG) */ #ifdef RJ_DEBUG void rjprintf(char *fmt, ...); /* in Rglue.c */ /* we can't assume ISO C99 (variadic macros), so we have to use one more level of wrappers */ #define _dbg(X) X #else #define _dbg(X) #endif /* profiling */ #ifdef RJ_PROFILE #define profStart() profilerTime=time_ms() #define _prof(X) X long time_ms(); /* those are acutally in Rglue.c */ void profReport(char *fmt, ...); #else #define profStart() #define _prof(X) #endif #ifdef ENABLE_JRICB #define BEGIN_RJAVA_CALL { int save_in_RJava = RJava_has_control; RJava_has_control=1; { #define END_RJAVA_CALL }; RJava_has_control = save_in_RJava; } #else #define BEGIN_RJAVA_CALL { #define END_RJAVA_CALL }; #endif /* define mkCharUTF8 in a compatible fashion */ #if R_VERSION < R_Version(2,7,0) #define mkCharUTF8(X) mkChar(X) #define CHAR_UTF8(X) CHAR(X) #else #define mkCharUTF8(X) mkCharCE(X, CE_UTF8) #define CHAR_UTF8(X) rj_char_utf8(X) extern const char *rj_char_utf8(SEXP); #endif /* signatures are stored in a local buffer if they fit. Only if they don't fit a heap buffer is allocated and used. */ typedef struct sig_buffer { char *sig; /* if sig doesn't point to sigbuf then it's allocated from heap */ int maxsig, len; char sigbuf[256]; /* default size of the local buffer (on the stack) */ } sig_buffer_t; /* in callbacks.c */ extern int RJava_has_control; /* in rJava.c */ extern JNIEnv *eenv; /* should NOT be used since not thread-safe; use getJNIEnv instead */ HIDE JNIEnv* getJNIEnv(); HIDE void ckx(JNIEnv *env); HIDE void clx(JNIEnv *env); HIDE SEXP getStringArrayCont(jarray) ; HIDE jarray getSimpleClassNames( jobject, jboolean ) ; HIDE SEXP getSimpleClassNames_asSEXP( jobject, jboolean ) ; REPC SEXP RgetSimpleClassNames( SEXP, SEXP ); /* in init.c */ extern JavaVM *jvm; extern int rJava_initialized; extern int java_is_dead; extern jclass javaStringClass; extern jclass javaObjectClass; extern jclass javaClassClass; extern jclass javaFieldClass; extern jclass rj_RJavaTools_Class ; extern jmethodID mid_forName; extern jmethodID mid_getName; extern jmethodID mid_getSuperclass; extern jmethodID mid_getType; extern jmethodID mid_getField; extern jmethodID mid_rj_getSimpleClassNames; extern jmethodID mid_RJavaTools_getFieldTypeName; /* RJavaImport */ extern jclass rj_RJavaImport_Class ; extern jmethodID mid_RJavaImport_getKnownClasses ; extern jmethodID mid_RJavaImport_lookup ; extern jmethodID mid_RJavaImport_exists ; HIDE void init_rJava(void); /* in otables.c */ // turn this for debugging in otables.c // #define LOOKUP_DEBUG REPC SEXP newRJavaLookupTable(SEXP) ; HIDE SEXP R_getUnboundValue() ; HIDE SEXP rJavaLookupTable_objects(R_ObjectTable *) ; HIDE SEXP rJavaLookupTable_assign(const char * const, SEXP, R_ObjectTable * ) ; HIDE Rboolean rJavaLookupTable_canCache(const char * const, R_ObjectTable *) ; HIDE int rJavaLookupTable_remove(const char * const, R_ObjectTable *) ; HIDE SEXP rJavaLookupTable_get(const char * const, Rboolean *, R_ObjectTable *) ; HIDE Rboolean rJavaLookupTable_exists(const char * const, Rboolean *, R_ObjectTable *) ; HIDE jobject getImporterReference(R_ObjectTable *) ; HIDE SEXP getKnownClasses( R_ObjectTable * ); HIDE SEXP classNameLookup( R_ObjectTable *, const char * const ) ; HIDE Rboolean classNameLookupExists(R_ObjectTable *, const char * const ) ; /* in loader.c */ extern jclass clClassLoader; extern jobject oClassLoader; /* in Rglue */ HIDE SEXP j2SEXP(JNIEnv *env, jobject o, int releaseLocal); HIDE SEXP new_jobjRef(JNIEnv *env, jobject o, const char *klass); HIDE jvalue R1par2jvalue(JNIEnv *env, SEXP par, sig_buffer_t *sig, jobject *otr); HIDE void init_sigbuf(sig_buffer_t *sb); HIDE void done_sigbuf(sig_buffer_t *sb); HIDE SEXP getName( JNIEnv *, jobject/*Class*/ ); HIDE SEXP new_jclassName(JNIEnv *, jobject/*Class*/ ) ; /* in tools.c */ HIDE jstring callToString(JNIEnv *env, jobject o); /* in callJNI */ HIDE jobject createObject(JNIEnv *env, const char *class, const char *sig, jvalue *par, int silent); HIDE jclass findClass(JNIEnv *env, const char *class); HIDE jclass objectClass(JNIEnv *env, jobject o); HIDE jdoubleArray newDoubleArray(JNIEnv *env, double *cont, int len); HIDE jintArray newIntArray(JNIEnv *env, int *cont, int len); HIDE jbooleanArray newBooleanArrayI(JNIEnv *env, int *cont, int len); HIDE jstring newString(JNIEnv *env, const char *cont); HIDE jcharArray newCharArrayI(JNIEnv *env, int *cont, int len); HIDE jshortArray newShortArrayI(JNIEnv *env, int *cont, int len); HIDE jfloatArray newFloatArrayD(JNIEnv *env, double *cont, int len); HIDE jlongArray newLongArrayD(JNIEnv *env, double *cont, int len); HIDE jintArray newByteArray(JNIEnv *env, void *cont, int len); HIDE jbyteArray newByteArrayI(JNIEnv *env, int *cont, int len); HIDE jobject makeGlobal(JNIEnv *env, jobject o); HIDE void releaseObject(JNIEnv *env, jobject o); HIDE void releaseGlobal(JNIEnv *env, jobject o); HIDE void printObject(JNIEnv *env, jobject o); HIDE int checkExceptionsX(JNIEnv *env, int silent); HIDE int initClassLoader(JNIEnv *env, jobject cl); HIDE void deserializeSEXP(SEXP o); /* this is a hook for de-serialization */ #define jverify(X) if (EXTPTR_PROT(X) != R_NilValue) deserializeSEXP(X) #define IS_JOBJREF(obj) ( inherits(obj, "jobjRef") || inherits(obj, "jarrayRef") || inherits(obj,"jrectRef") ) #define IS_JARRAYREF(obj) ( inherits(obj, "jobjRef") || inherits(obj, "jarrayRef") || inherits(obj, "jrectRef") ) #define IS_JRECTREF(obj) ( inherits(obj,"jrectRef") ) #endif rJava/src/java/0000755000176200001440000000000012256051770013032 5ustar liggesusersrJava/src/java/FlatException.class0000644000176200001440000000042212256051764016627 0ustar liggesusers.   ()VCodeLineNumberTable SourceFileFlatException.java#Can only flatten rectangular arrays  FlatExceptionjava/lang/Exception(Ljava/lang/String;)V!#*   rJava/src/java/Makefile0000644000176200001440000000127112256051771014474 0ustar liggesusersJAVA_SRC=$(wildcard *.java) JFLAGS=-source 1.2 -target 1.2 JAVAC=javac JAVA=java JAVADOC=javadoc JAVADOCFLAGS=-author -version -breakiterator -link http://java.sun.com/j2se/1.4.2/docs/api all: compile test compile: $(JAVA_SRC) $(JAVAC) $(JFLAGS) $(JAVA_SRC) test_RJavaTools: compile $(JAVA) RJavaTools_Test test_RJavaArrayTools: compile $(JAVA) RJavaArrayTools_Test test_ArrayWrapper: $(JAVA) ArrayWrapper_Test test_RectangularArrayBuilder: $(JAVA) RectangularArrayBuilder_Test test: compile test_RJavaTools test_RJavaArrayTools test_ArrayWrapper test_RectangularArrayBuilder javadoc: $(JAVADOC) $(JAVADOCFLAGS) -d javadoc $(JAVA_SRC) clean: rm -rfv *.class *~ .PHONY: all clean rJava/src/java/RJavaTools_Test$TestException.class0000644000176200001440000000047012256051764021673 0ustar liggesusers.   (Ljava/lang/String;)VCodeLineNumberTable SourceFileRJavaTools_Test.java RJavaTools_Test$TestException TestException InnerClassesjava/lang/ExceptionRJavaTools_Test!"*+    rJava/src/java/ObjectArrayException.java0000644000176200001440000000040112256051760017753 0ustar liggesusers/** * Generated when one tries to access an array of primitive * values as an array of Objects */ public class ObjectArrayException extends Exception{ public ObjectArrayException(String type){ super( "array is of primitive type : " + type ) ; } } rJava/src/java/RJavaClassLoader.class0000644000176200001440000002626512256051764017217 0ustar liggesusers.A                ! "#$% &'()  *+ ! ,-. $/ !0 1 234 */ *567 89:;<=>?@A BC BDE F GH IJ IKLM NOP !Q RST RUV WXYZ [ \]^_`abcd ef Xghijk *lm *no cpq rst u v rwxyz r{|}~     X *  *  X/ *  !    ! !         Z       S    {     {  RJavaObjectInputStream InnerClasses UnixDirectory UnixJarFileUnixFile rJavaPathLjava/lang/String; rJavaLibPathlibMapLjava/util/HashMap; classPathLjava/util/Vector; primaryLoaderLRJavaClassLoader;verboseZ useSystemarray$Ljava$lang$StringLjava/lang/Class; SyntheticgetPrimaryLoader()LRJavaClassLoader;CodeLineNumberTable'(Ljava/lang/String;Ljava/lang/String;)VclassNameToFile&(Ljava/lang/String;)Ljava/lang/String; findClass%(Ljava/lang/String;)Ljava/lang/Class; Exceptions findResource"(Ljava/lang/String;)Ljava/net/URL; addRLibrary addClassPath(Ljava/lang/String;)V([Ljava/lang/String;)V getClassPath()[Ljava/lang/String; findLibrary bootClass:(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;)VsetDebug(I)Vu2wmaintoByte(Ljava/lang/Object;)[BtoObject([B)Ljava/lang/Object; toObjectPLclass$()V SourceFileRJavaClassLoader.java  java/lang/ClassNotFoundExceptionjava/lang/NoClassDefFoundError   java/net/URL   rJava.debug  0  java/lang/StringBuffer RJavaClassLoader(" ","")   - primary loader - NOT primrary (this=  , primary=)java/util/HashMap java/util/Vector RJavaClassLoader$UnixDirectory/java   RJavaClassLoader$UnixFile /rJava.so  /rJava.dllrJava /jri/libjri.sor.arch/jri /libjri.so/jri.dll/jri/libjri.jnilib /jri/jri.dlljri - registered JRI:   4RJavaClassLoader initialized. Registered libraries:     : ' ' Registered class paths:   ' ! -- end of class loader report --  .findClass(RJavaClassLoader  RJavaClassLoader: found class  using URL loaderjava/lang/Exception - URL loader did not find it: RJavaClassLoader.findClass(" - trying class path ""RJavaClassLoader$UnixJarFile .class    JAR file, can get ''? NOYES  /  java/io/FileInputStream   Directory, can get ' " loading class file, initial n =    next n =  (rp=, al= RJavaClassLoader: loaded class ,  bytes  defineClass(' ') returned FClass not found - candidate class binary found but could not be loaded  >> ClassNotFoundException  RJavaClassLoader: findResource('') $RJavaClassLoader: found resource in  using URL loader.9 - resource not found with URL loader, trying alternative  - found in a JAR file, URL  - find as a file:  RJavaClassLoader: added '' to the URL class path loader .jar  .JAR,RJavaClassLoader: adding Java archive file '' to the internal class path !*RJavaClassLoader: adding class directory ' "WARNING: the path 'Z' is neither a directory nor a .jar file, it will NOT be added to the internal class path!B' does NOT exist, it will NOT be added to the internal class path! #java.class.path$ % &' (java/lang/String )*RJavaClassLoader.findLibrary(" - mapping to  +,java/lang/Class [Ljava.lang.String;  -.java/lang/Object/ 01 23 rjava.pathERROR: rjava.path is not set 4 rjava.lib 5libs  main.class2WARNING: main.class not specified, assuming 'Main'Mainrjava.class.pathjava/util/StringTokenizer 6 7 "ERROR: while running main method: 8java/io/ByteArrayOutputStreamjava/io/ObjectOutputStream 9 :; <=java/io/ByteArrayInputStream >'RJavaClassLoader$RJavaObjectInputStream ? @ java/net/URLClassLoader java/lang/IllegalAccessException+java/lang/reflect/InvocationTargetExceptionjava/lang/NoSuchMethodExceptionforName getMessage()Ljava/lang/String;([Ljava/net/URL;)Vjava/lang/System getPropertylength()Iequals(Ljava/lang/Object;)ZoutLjava/io/PrintStream;append,(Ljava/lang/String;)Ljava/lang/StringBuffer;toStringjava/io/PrintStreamprintln,(Ljava/lang/Object;)Ljava/lang/StringBuffer;'(LRJavaClassLoader;Ljava/lang/String;)Vaddexists()Zput8(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;java/lang/Thread currentThread()Ljava/lang/Thread;setContextClassLoader(Ljava/lang/ClassLoader;)VkeySet()Ljava/util/Set; java/util/Setiterator()Ljava/util/Iterator;java/util/IteratorhasNextnext()Ljava/lang/Object;get&(Ljava/lang/Object;)Ljava/lang/Object;elements()Ljava/util/Enumeration;java/util/EnumerationhasMoreElements nextElementreplace(CC)Ljava/lang/String;getClass()Ljava/lang/Class;getResourceAsStream)(Ljava/lang/String;)Ljava/io/InputStream;getPathisFile(Ljava/io/File;)Vjava/io/InputStreamread([B)I(I)Ljava/lang/StringBuffer; arraycopy*(Ljava/lang/Object;ILjava/lang/Object;II)V([BII)Iclose defineClass)(Ljava/lang/String;[BII)Ljava/lang/Class;*(Ljava/lang/String;Ljava/lang/Throwable;)V getResourcetoURL()Ljava/net/URL;addURL(Ljava/net/URL;)VgetNameendsWith(Ljava/lang/String;)Z isDirectoryerrcontains java/io/File pathSeparator setProperty8(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;size elementAt(I)Ljava/lang/Object; resolveClass(Ljava/lang/Class;)V getMethod@(Ljava/lang/String;[Ljava/lang/Class;)Ljava/lang/reflect/Method;java/lang/reflect/Methodinvoke9(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object; separatorCharCexit separator hasMoreTokens nextTokenprintStackTrace(Ljava/io/OutputStream;)V writeObject(Ljava/lang/Object;)V toByteArray()[B([B)V*(LRJavaClassLoader;Ljava/io/InputStream;)V readObject!   **  N-- - *Y+,*=2,Y**Y *!Y"#*#$Y*Y+%&'W*+(*,)*Y*Y*)+,:-#*Y*Y*).,:-* /0W*Y*Y+1,:2 :t l*Y*Y+34,:- :6*Y*Y+35,:-:- *Y*Y+6,:- *Y*Y+7,:-/* 80WY9* :*;<* =>:??@:YAB* CDE*#F:G*YHIDҲJ/: +X^bs -5A^er%-9Y`gmu      ! +./K VM*YL*M+N+*O* V*+PM,)!YQ+R,#NYT-!YU+N:*#F:GYI*:"YVWNX\XY*+YZ[NY\*+Y]-^_~$v*Y*Y`a*+YZ,:b cYdN0Ye]-^_->f6:-g6  6 Yh i  -h6  jj6  :  k : 6-  dl6 6Ym in ioi   `6 u-p 6 +Yq+r is*+ tM :  :5%Yu+v,,:Ywx y, Yz,DswSS$S $S? /!=$D&J'N(r)t-w+x,/345679;=>.?g@oABCERSTUVWX!Y(Z.[9\?]J^N_Rabbcefginjlmoq!u$s&v)y.z:}H~LT'!Y{+|* 7*+}M,)!Y~,,M *#FM,G,I*N-X8-X+:&Y\-$U*Y*Y-`a+,:b)Y:S+Z^S S Sj$+15Y[^_mu~ "%/* +*Y*,,0W O*Y*+,M* 3*,!Y+NN,bL,,4XY*+NY+,4$Y*+&NjY+IC,-Y+Y+-<*#-1*#-'WY -`W=@SN =@ACbl )N6=+*+2]-*#<M>,*#*`S, %+l!Y+* +C*MN,,-,`N%Y---$02BjiA*+:*,YYS:Y-SW 1@  )   ! ./*/K*+ N L+ M,Y+MY+,N :  : :,Y::--*$:YSfBC DEGH I:KJLQM_NgOkQrRwSTUVWZ^[\]_ GYLY+M,*,+Űxyz{|SH Y+MY*,N-:- S  *ͰS2*LY+%  /4 "$X*rJava/src/java/RJavaTools.java0000644000176200001440000005171312256051760015727 0ustar liggesusers// RJavaTools.java: rJava - low level R to java interface // // Copyright (C) 2009 - 2010 Simon Urbanek and Romain Francois // // This file is part of rJava. // // rJava is free software: you can redistribute it and/or modify it // under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 2 of the License, or // (at your option) any later version. // // rJava is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with rJava. If not, see . import java.lang.reflect.Method ; import java.lang.reflect.Field ; import java.lang.reflect.Constructor ; import java.lang.reflect.InvocationTargetException ; import java.lang.reflect.Modifier ; import java.lang.reflect.Member ; import java.util.Vector ; /** * Tools used internally by rJava. * * The method lookup code is heavily based on ReflectionTools * by Romain Francois licensed under GPL v2 or higher. */ public class RJavaTools { /** * Returns an inner class of the class with the given simple name * * @param cl class * @param name simple name of the inner class * @param staticRequired boolean, if true the inner class is required to be static */ public static Class getClass(Class cl, String name, boolean staticRequired){ Class[] clazzes = cl.getClasses(); for( int i=0; iFor fields, it just returns the name of the fields * *

For methods, this returns the name of the method * plus a suffix that depends on the number of arguments of the method. * *

The string "()" is added * if the method has no arguments, and the string "(" is added * if the method has one or more arguments. */ public static String getCompletionName(Member m){ if( m instanceof Field ) return m.getName(); if( m instanceof Method ){ String suffix = ( ((Method)m).getParameterTypes().length == 0 ) ? ")" : "" ; return m.getName() + "(" + suffix ; } return "" ; } /** * Indicates if a member of a Class (field, method ) is static * * @param member class member * @return true if the member is static */ public static boolean isStatic( Member member ){ return (member.getModifiers() & Modifier.STATIC) != 0 ; } /** * Checks if the class of the object has the given field. The * getFields method of Class is used so only public fields are * checked * * @param o object * @param name name of the field * * @return true if the class of o has the field name */ public static boolean hasField(Object o, String name) { return classHasField(o.getClass(), name, false); } /** * Checks if the class of the object has the given inner class. The * getClasses method of Class is used so only public classes are * checked * * @param o object * @param name (simple) name of the inner class * * @return true if the class of o has the class name */ public static boolean hasClass(Object o, String name) { return classHasClass(o.getClass(), name, false); } /** * Checks if the specified class has the given field. The * getFields method of Class is used so only public fields are * checked * * @param cl class object * @param name name of the field * @param staticRequired if true then the field is required to be static * * @return true if the class cl has the field name */ public static boolean classHasField(Class cl, String name, boolean staticRequired) { Field[] fields = cl.getFields(); for (int i = 0; i < fields.length; i++) if(name.equals(fields[i].getName()) && (!staticRequired || ((fields[i].getModifiers() & Modifier.STATIC) != 0))) return true; return false; } /** * Checks if the specified class has the given method. The * getMethods method of Class is used so only public methods are * checked * * @param cl class * @param name name of the method * @param staticRequired if true then the method is required to be static * * @return true if the class cl has the method name */ public static boolean classHasMethod(Class cl, String name, boolean staticRequired) { Method[] methodz = cl.getMethods(); for (int i = 0; i < methodz.length; i++) if (name.equals(methodz[i].getName()) && (!staticRequired || ((methodz[i].getModifiers() & Modifier.STATIC) != 0))) return true; return false; } /** * Checks if the specified class has the given inner class. The * getClasses method of Class is used so only public classes are * checked * * @param cl class * @param name name of the inner class * @param staticRequired if true then the method is required to be static * * @return true if the class cl has the field name */ public static boolean classHasClass(Class cl, String name, boolean staticRequired) { Class[] clazzes = cl.getClasses(); for (int i = 0; i < clazzes.length; i++) if (name.equals( getSimpleName(clazzes[i].getName()) ) && (!staticRequired || isStatic( clazzes[i] ) ) ) return true; return false; } /** * Checks if the class of the object has the given method. The * getMethods method of Class is used so only public methods are * checked * * @param o object * @param name name of the method * * @return true if the class of o has the field name */ public static boolean hasMethod(Object o, String name) { return classHasMethod(o.getClass(), name, false); } /** * Object creator. Find the best constructor based on the parameter classes * and invoke newInstance on the resolved constructor */ public static Object newInstance( Class o_clazz, Object[] args, Class[] clazzes ) throws Throwable { boolean[] is_null = new boolean[args.length]; for( int i=0; iFirst the appropriate method is resolved by getMethod and * then invokes the method */ public static Object invokeMethod( Class o_clazz, Object o, String name, Object[] args, Class[] clazzes) throws Throwable { Method m = getMethod( o_clazz, name, clazzes, arg_is_null(args) ); /* enforcing accessibility (workaround for bug 128) */ boolean access = m.isAccessible(); m.setAccessible( true ); Object out; try{ out = m.invoke( o, args ) ; } catch( InvocationTargetException e){ /* the target exception is much more useful than the reflection wrapper */ throw e.getTargetException() ; } finally{ m.setAccessible( access ); } return out ; } /** * Attempts to find the best-matching constructor of the class * o_clazz with the parameter types arg_clazz * * @param o_clazz Class to look for a constructor * @param arg_clazz parameter types * @param arg_is_null indicates if each argument is null * * @return null if no constructor is found, or the constructor * */ public static Constructor getConstructor( Class o_clazz, Class[] arg_clazz, boolean[] arg_is_null) throws SecurityException, NoSuchMethodException { if (o_clazz == null) return null; Constructor cons = null ; /* if there is no argument, try to find a direct match */ if (arg_clazz == null || arg_clazz.length == 0) { cons = o_clazz.getConstructor( (Class[] )null ); return cons ; } /* try to find an exact match */ try { cons = o_clazz.getConstructor(arg_clazz); if (cons != null) return cons ; } catch (NoSuchMethodException e) { /* we catch this one because we want to further search */ } /* ok, no exact match was found - we have to walk through all methods */ cons = null; Constructor[] candidates = o_clazz.getConstructors(); for (int k = 0; k < candidates.length; k++) { Constructor c = candidates[k]; Class[] param_clazz = c.getParameterTypes(); if (arg_clazz.length != param_clazz.length) // number of parameters must match continue; int n = arg_clazz.length; boolean ok = true; for (int i = 0; i < n; i++) { if( arg_is_null[i] ){ /* then the class must not be a primitive type */ if( isPrimitive(arg_clazz[i]) ){ ok = false ; break ; } } else{ if (arg_clazz[i] != null && !param_clazz[i].isAssignableFrom(arg_clazz[i])) { ok = false; break; } } } // it must be the only match so far or more specific than the current match if (ok && (cons == null || isMoreSpecific(c, cons))) cons = c; } if( cons == null ){ throw new NoSuchMethodException( "No constructor matching the given parameters" ) ; } return cons; } static boolean isPrimitive(Class cl){ return cl.equals(Boolean.TYPE) || cl.equals(Integer.TYPE) || cl.equals(Double.TYPE) || cl.equals(Float.TYPE) || cl.equals(Long.TYPE) || cl.equals(Short.TYPE) || cl.equals(Character.TYPE) ; } /** * Attempts to find the best-matching method of the class o_clazz with the method name name and arguments types defined by arg_clazz. * The lookup is performed by finding the most specific methods that matches the supplied arguments (see also {@link #isMoreSpecific}). * * @param o_clazz class in which to look for the method * @param name method name * @param arg_clazz an array of classes defining the types of arguments * @param arg_is_null indicates if each argument is null * * @return null if no matching method could be found or the best matching method. */ public static Method getMethod(Class o_clazz, String name, Class[] arg_clazz, boolean[] arg_is_null) throws SecurityException, NoSuchMethodException { if (o_clazz == null) return null; /* if there is no argument, try to find a direct match */ if (arg_clazz == null || arg_clazz.length == 0) { return o_clazz.getMethod(name, (Class[])null); } /* try to find an exact match */ Method met; try { met = o_clazz.getMethod(name, arg_clazz); if (met != null) return met; } catch (NoSuchMethodException e) { /* we want to search further */ } /* ok, no exact match was found - we have to walk through all methods */ met = null; Method[] ml = o_clazz.getMethods(); for (int k = 0; k < ml.length; k++) { Method m = ml[k]; if (!m.getName().equals(name)) // the name must match continue; Class[] param_clazz = m.getParameterTypes(); if (arg_clazz.length != param_clazz.length) // number of parameters must match continue; int n = arg_clazz.length; boolean ok = true; for (int i = 0; i < n; i++) { if( arg_is_null[i] ){ /* then the class must not be a primitive type */ if( isPrimitive(arg_clazz[i]) ){ ok = false ; break ; } } else{ if (arg_clazz[i] != null && !param_clazz[i].isAssignableFrom(arg_clazz[i])) { ok = false; break; } } } if (ok && (met == null || isMoreSpecific(m, met))) // it must be the only match so far or more specific than the current match met = m; } if( met == null ){ throw new NoSuchMethodException( "No suitable method for the given parameters" ) ; } return met; } /** * Returns true if m1 is more specific than m2. * The measure used is described in the isMoreSpecific( Class[], Class[] ) method * * @param m1 method to compare * @param m2 method to compare * * @return true if m1 is more specific (in arguments) than m2. */ private static boolean isMoreSpecific(Method m1, Method m2) { Class[] m1_param_clazz = m1.getParameterTypes(); Class[] m2_param_clazz = m2.getParameterTypes(); return isMoreSpecific( m1_param_clazz, m2_param_clazz ); } /** * Returns true if cons1 is more specific than cons2. * The measure used is described in the isMoreSpecific( Class[], Class[] ) method * * @param cons1 constructor to compare * @param cons2 constructor to compare * * @return true if cons1 is more specific (in arguments) than cons2. */ private static boolean isMoreSpecific(Constructor cons1, Constructor cons2) { Class[] cons1_param_clazz = cons1.getParameterTypes(); Class[] cons2_param_clazz = cons2.getParameterTypes(); return isMoreSpecific( cons1_param_clazz, cons2_param_clazz ); } /** * Returns true if c1 is more specific than c2. * * The measure used is the sum of more specific arguments minus the sum of less specific arguments * which in total must be positive to qualify as more specific. * (More specific means the argument is a subclass of the other argument). * * Both set of classes must have signatures fully compatible in the arguments * (more precisely incompatible arguments are ignored in the comparison). * * @param c1 set of classes to compare * @param c2 set of classes to compare */ private static boolean isMoreSpecific( Class[] c1, Class[] c2){ int n = c1.length ; int res = 0; for (int i = 0; i < n; i++) if( c1[i] != c2[i]) { if( c1[i].isAssignableFrom(c2[i])) res--; else if( c2[i].isAssignableFrom(c2[i]) ) res++; } return res > 0; } /** * Returns the list of classes of the object * * @param o an Object */ public static Class[] getClasses(Object o){ Vector/*>*/ vec = new Vector(); Class cl = o.getClass(); while( cl != null ){ vec.add( cl ) ; cl = cl.getSuperclass() ; } Class[] res = new Class[ vec.size() ] ; vec.toArray( res) ; return res ; } /** * Returns the list of class names of the object * * @param o an Object */ public static String[] getClassNames(Object o){ Vector/**/ vec = new Vector(); Class cl = o.getClass(); while( cl != null ){ vec.add( cl.getName() ) ; cl = cl.getSuperclass() ; } String[] res = new String[ vec.size() ] ; vec.toArray( res) ; return res ; } /** * Returns the list of simple class names of the object * * @param o an Object */ public static String[] getSimpleClassNames(Object o, boolean addConditionClasses){ boolean hasException = false ; Vector/**/ vec = new Vector(); Class cl = o.getClass(); String name ; while( cl != null ){ name = getSimpleName( cl.getName() ) ; if( "Exception".equals( name) ){ hasException = true ; } vec.add( name ) ; cl = cl.getSuperclass() ; } if( addConditionClasses ){ if( !hasException ){ vec.add( "Exception" ) ; } vec.add( "error" ) ; vec.add( "condition" ) ; } String[] res = new String[ vec.size() ] ; vec.toArray( res) ; return res ; } /* because Class.getSimpleName is java 5 API */ private static String getSimpleClassName( Object o ){ return getSimpleName( o.getClass().getName() ) ; } private static String getSimpleName( String s ){ int lastsquare = s.lastIndexOf( '[' ) ; if( lastsquare >= 0 ){ if( s.charAt( s.lastIndexOf( '[' ) + 1 ) == 'L' ){ s = s.substring( s.lastIndexOf( '[' ) + 2, s.lastIndexOf( ';' ) ) ; } else { char first = s.charAt( 0 ); if( first == 'I' ) { s = "int" ; } else if( first == 'D' ){ s = "double" ; } else if( first == 'Z' ){ s = "boolean" ; } else if( first == 'B' ){ s = "byte" ; } else if( first == 'J' ){ s = "long" ; } else if( first == 'F' ){ s = "float" ; } else if( first == 'S' ){ s = "short" ; } else if( first == 'C' ){ s = "char" ; } } } int lastdollar = s.lastIndexOf( '$' ) ; if( lastdollar >= 0 ){ s = s.substring( lastdollar + 1); } int lastdot = s.lastIndexOf( '.' ) ; if( lastdot >= 0 ){ s = s.substring( lastdot + 1); } if( lastsquare >= 0 ){ StringBuffer buf = new StringBuffer( s ); int i ; for( i=0; i<=lastsquare; i++){ buf.append( "[]" ); } return buf.toString(); } else { return s ; } } /** * @param cl class * @param field name of the field * * @return the class name of the field of the class (or null) * if the class does not have the given field) */ public static String getFieldTypeName( Class cl, String field){ String res = null ; try{ res = cl.getField( field ).getType().getName() ; } catch( NoSuchFieldException e){ /* just return null */ res = null ; } return res ; } } rJava/src/java/FlatException.java0000644000176200001440000000032212256051760016436 0ustar liggesusers /** * Generated when one attemps to flatten an array that is not rectangular */ public class FlatException extends Exception{ public FlatException(){ super( "Can only flatten rectangular arrays" ); } } rJava/src/java/RJavaClassLoader$UnixDirectory.class0000644000176200001440000000066212256051764022005 0ustar liggesusers.  this$0LRJavaClassLoader; Synthetic'(LRJavaClassLoader;Ljava/lang/String;)VCodeLineNumberTable SourceFileRJavaClassLoader.java  RJavaClassLoader$UnixDirectory UnixDirectory InnerClassesRJavaClassLoader$UnixFileUnixFileRJavaClassLoader   , *+,*+    rJava/src/java/ArrayDimensionException.class0000644000176200001440000000036612256051764020674 0ustar liggesusers.    (Ljava/lang/String;)VCodeLineNumberTable SourceFileArrayDimensionException.java ArrayDimensionExceptionjava/lang/Exception!"*+  rJava/src/java/RJavaComparator.java0000644000176200001440000000313012256051760016724 0ustar liggesusersimport java.lang.Comparable ; /** * Utility class to compare two objects in the sense * of the java.lang.Comparable interface * */ public class RJavaComparator { /** * compares a and b in the sense of the java.lang.Comparable if possible * *

instances of the Number interface are treated specially, in order to * allow comparing Numbers of different classes, for example it is allowed * to compare a Double with an Integer. if the Numbers have the same class, * they are compared normally, otherwise they are first converted to Doubles * and then compared

* * @param a an object * @param b another object * * @return the result of a.compareTo(b) if this makes sense * @throws NotComparableException if the two objects are not comparable */ public static int compare( Object a, Object b ) throws NotComparableException{ int res ; if( a.equals( b ) ) return 0 ; // treat Number s separately if( a instanceof Number && b instanceof Number && !( a.getClass() == b.getClass() ) ){ Double _a = new Double( ((Number)a).doubleValue() ); Double _b = new Double( ((Number)b).doubleValue() ); return _a.compareTo( _b ); } if( ! ( a instanceof Comparable ) ) throw new NotComparableException( a ); if( ! ( b instanceof Comparable ) ) throw new NotComparableException( b ); try{ res = ( (Comparable)a ).compareTo( b ) ; } catch( ClassCastException e){ try{ res = - ((Comparable)b).compareTo( a ) ; } catch( ClassCastException f){ throw new NotComparableException( a, b ); } } return res ; } } rJava/src/java/RJavaArrayTools_Test.class0000644000176200001440000005440512256051764020116 0ustar liggesusers.O                             Z              !"#$%&'()*+,-./01234567 89: ;<= >?@ ABC DEFGH IJK LMNOP QRSTUVWXYZ[\] ^_` abc def ghi jklmn opq rstuvw xyz {|} ~                     t  t@$()VCodeLineNumberTablemain([Ljava/lang/String;)Vruntests Exceptionsfails(LTestException;)Vsuccessisarray getdimlengthgetdims gettruelengthisrect gettypenameisprimrep SourceFileRJavaArrayTools_Test.java  Test suite for RJavaArrayTools  !  TestException  "#Testing RJavaArrayTools.isArray  *Testing RJavaArrayTools.isRectangularArray *Testing RJavaArrayTools.getDimensionLength %Testing RJavaArrayTools.getDimensions %Testing RJavaArrayTools.getTrueLength )Testing RJavaArrayTools.getObjectTypeName +Testing RJavaArrayTools.isPrimitiveTypeName Testing RJavaTools.rep  $ %FAILEDPASSED isArray( int ) &!' () isArray( int ) ! false : ok isArray( boolean ) (* isArray( boolean )  isArray( byte ) (+ isArray( byte )  isArray( long ) (, isArray( long )  isArray( short ) (- isArray( short )  isArray( double ) isArray( double )  isArray( char ) (. isArray( char )  isArray( float ) (/ isArray( float )  isArray( String )dd (0 isArray( String )  isArray( int[] ) !isArray( int[] )  true : ok/ isArray( double[] (but declared as 0bject) )' !isArray( Object o = new double[2]; )  isArray( null ) isArray( null)  >> actual arrays int[] o = new int[10] ; 12"getDimensionLength( int[10] ) != 1NotAnArrayExceptionnot an array int[10] 1 : ok  int[] o = new int[0] ;!getDimensionLength( int[0] ) != 1not an array int[0][[Ljava/lang/Object; new Object[10][10]-getDimensionLength( new Object[10][10] ) != 2not an array Object[10][10] 2 : ok [[[Ljava/lang/Object; new Object[10][10][10]0getDimensionLength( new Object[10][10][3] ) != 3not an array Object[10][10][3] 3 : ok  >> Object new Double('10.2') java/lang/Double10.3 !2getDimensionLength(Double) did not throw exception -> NotAnArrayException : ok  >> Testing primitive types getDimensionLength( int ) 131 getDimensionLength( int ) not throwing exception ok getDimensionLength( boolean ) 145 getDimensionLength( boolean ) not throwing exception : ok getDimensionLength( byte ) 152 getDimensionLength( byte ) not throwing exception getDimensionLength( long ) 162 getDimensionLength( long ) not throwing exception getDimensionLength( short ) 173 getDimensionLength( short ) not throwing exception : ok getDimensionLength( double )4 getDimensionLength( double ) not throwing exception getDimensionLength( char ) 183 getDimensionLength( char ) not throwing exception  getDimensionLength( float ) 194 getDimensionLength( float ) not throwing exception  getDimensionLength( null )java/lang/NullPointerException;getDimensionLength( null ) throwing wrong kind of exception3 getDimensionLength( null ) not throwing exception :;#getDimensions( int[10]).length != 1 getDimensions( int[10])[0] != 10 c( 10 ) : ok +getDimensions( Object[10][10] ).length != 2(getDimensions( Object[10][10] )[0] != 10(getDimensions( Object[10][10] )[1] != 10 c(10,10) : ok /getDimensions( Object[10][10][10] ).length != 3,getDimensions( Object[10][10][10] )[0] != 10,getDimensions( Object[10][10][10] )[1] != 10not an array Object[10][10][10] c(10,10,10) : ok  >> zeroes "getDimensions( int[0]).length != 1getDimensions( int[0])[0] != 0 c(0) : ok  new Object[10][10][0].getDimensions( Object[10][10][0] ).length != 3+getDimensions( Object[10][10][0] )[0] != 10+getDimensions( Object[10][10][0] )[1] != 10*getDimensions( Object[10][10][0] )[1] != 0not an array Object[10][10][0] c(10,10,0) : ok  new Object[10][0][10]-getDimensions( Object[10][0][0] ).length != 3*getDimensions( Object[10][0][0] )[0] != 10)getDimensions( Object[10][0][0] )[1] != 0not an array Object[10][0][10] c(10,0,0) : ok -getDimensions(Double) did not throw exception getDimensions( int ) :<, getDimensions( int ) not throwing exception getDimensions( boolean ) :=0 getDimensions( boolean ) not throwing exception getDimensions( byte ) :>- getDimensions( byte ) not throwing exception getDimensions( long ) :?- getDimensions( long ) not throwing exception getDimensions( short ) :@. getDimensions( short ) not throwing exception getDimensions( double )/ getDimensions( double ) not throwing exception getDimensions( char ) :A. getDimensions( char ) not throwing exception  getDimensions( float ) :B/ getDimensions( float ) not throwing exception  getDimensions( null )6getDimensions( null ) throwing wrong kind of exception. getDimensions( null ) not throwing exception C2getTrueLength( int[10]) != 10 10 : ok &getTrueLength( Object[10][10] ) != 100 100 : ok +getTrueLength( Object[10][10][10] ) != 1000 1000 : ok getTrueLength( int[0]) != 0'getTrueLength( Object[10][10][0] ) != 0 0 : ok &getTrueLength( Object[10][0][0] ) != 0-getTrueLength(Double) did not throw exception getTrueLength( int ) C3, getTrueLength( int ) not throwing exception getTrueLength( boolean ) C40 getTrueLength( boolean ) not throwing exception getTrueLength( byte ) C5- getTrueLength( byte ) not throwing exception getTrueLength( long ) C6- getTrueLength( long ) not throwing exception getTrueLength( short ) C7. getTrueLength( short ) not throwing exception getTrueLength( double )/ getTrueLength( double ) not throwing exception getTrueLength( char ) C8. getTrueLength( char ) not throwing exception  getTrueLength( float ) C9/ getTrueLength( float ) not throwing exception  getTrueLength( null )6getTrueLength( null ) throwing wrong kind of exception. getTrueLength( null ) not throwing exception  isRectangularArray( int ) D) isRectangularArray( int )  isRectangularArray( boolean ) D* isRectangularArray( boolean )  isRectangularArray( byte ) D+ isRectangularArray( byte )  isRectangularArray( long ) D, isRectangularArray( long )  isRectangularArray( short ) D- isRectangularArray( short )  isRectangularArray( double ) isRectangularArray( double )  isRectangularArray( char ) D. isRectangularArray( char )  isRectangularArray( float ) D/ isRectangularArray( float )  isRectangularArray( String ) D0 isRectangularArray( String )  isRectangularArray( int[] ) !isRectangularArray( int[] ) : isRectangularArray( double[] (but declared as 0bject) )2 !isRectangularArray( Object o = new double[2]; )  isRectangularArray( null ) isRectangularArray( null) [[I$ isRectangularArray( new int[3][4] )& !isRectangularArray( new int[3][4] ) [I& isRectangularArray( new int[2][2,4] )( !isRectangularArray( new int[2][2,4] ) + isRectangularArray( new int[2][2][10,25] )- !isRectangularArray( new int[2][2][10,25] ) EFIG H0 getObjectTypeName(int[]) != 'I'  I : ok  boolean[]Z$getObjectTypeName(boolean[]) != 'Z' not an array boolean[10] Z : ok  byte[]B!getObjectTypeName(byte[]) != 'B' not an array byte[10] B : ok  long[]J!getObjectTypeName(long[]) != 'J' not an array long[10] J : ok  short[]S"getObjectTypeName(short[]) != 'S' not an array short[10] S : ok  double[]D#getObjectTypeName(double[]) != 'D' not an array double[10] D : ok  char[]C!getObjectTypeName(char[]) != 'C' not an array char[10] C : ok  float[]F"getObjectTypeName(float[]) != 'F' not an array float[10] F : ok  >> multi dim primitive arrays int[][] ; boolean[][][[Z byte[][][[B long[][][[J short[][][[S double[][][[D char[][][[C float[][][[Fjava.lang.Object4getObjectTypeName(Object[][]) != 'java.lang.Object'  : ok >getObjectTypeName( Object[10][10][10] ) != 'java.lang.Object' !getObjectTypeName(int[0]) != 'I' =getObjectTypeName( Object[10][10][0] ) != 'java.lang.Object' ? %  DE w ! Y"#$% & Y'#$( ) Y*#$+ , Y-#$. / Y0#$1 / Y2#$3 a4 Y5#$6 7 Y8#$9 :; Y<#$ K= *; Y>#?L@ +; YA#?B ; YC#$3LMNP!T)U0V:XB\J]Q^[`cdkerf|hlmnptuvx|}~ #+/7>HPT\cmu} 2ƲD KE *F YG#LYI#J KK *F YL#LYM#J  NLO +F YP#MYQ#R   SMT ,F YU#NYV#WXY >ZY[\FW:> Y]#^_` >aW:> Yb#cd >eW:> Yf#gh >iW:> Yj#gk > lW:> Ym#cn >oW:> Yp#qr >oW:> Ys#gt >auW:> Yv#gw > xW:> Yy#gz >FW:>:Y|# Y}#g'*HI[^HHHH38;H_dgHHHHH;ADHhmpH{Hx '*+5=AIQ[^_iqz  !)138;=?MU ] _ dgiky"#%(&')*./142356: ;=@>?A)B1F9G;IALDJFKHMVN^RfShUmXpVrWtYZ`achdehfgijm RK LE +~K* Y#*. Y#MYI#  NMO ,~K* Y#*. Y#*. Y#NYQ#   SNT -~K* Y#*. Y#*. Y#*. Y#:Y# LK +~K* Y#*. Y#:YM#  SN -~K* Y#*. Y#*. Y#*. Y#:Y#  SN -~K* Y#*. Y#*. Y#*. Y#:Y#XY 6ZY[\~K:6 Y#^_ 6W:6 Y#c 6W:6 Y#g 6W:6 Y#g 6 W:6 Y#c 6W:6 Y#q 6W:6 Y#g 6aW:6 Y#g 6 W:6 Y#g 6~W:6:Y# Y#g69H]H  H5Z]HH<?HfsvHHH H27:HafiHHHH#&{#.Hrvwyz{$},~69:DLU]bhrz  !)-5:@JPZ]_iq{ ",2<?AKS[cfsvx{   "#%( & ')*'.//2174:2<3?5N6V:^;a=f@i>k?nA}BFGILJKMNRSUXVWYZ^_adbce flmo#t&p(q+t.r0s:uIvQz Ck; LE +; Y#MYI#  NMO ,;d Y#NYQ#   SNT -; Y#:Y# LK +; Y#:YM#  SN -; Y#:Y#  SN -; Y#:Y#XY 6ZY[\;:6 Y·#^_ö 6W:6 Yŷ#cƶ 6W:6 Yȷ#gɶ 6W:6 Y˷#g̶ 6 W:6 Yη#c϶ 6W:6 Yѷ#qҶ 6W:6 Yӷ#gԶ 6aW:6 Yַ#g׶ 6 W:6 Yٷ#gڶ 6W:6:Y۷# Yܷ#g$'HK`cHHHHBUXHHHH!$HKPSHzHHH H7<?{7<GH>$'(2:CKPV`cdnv (0:BGKUXZdlt|    !$&)8@HKPSUXgo"w#z%(&')*./142356:;=@>?ABFGI LJKM$N,T4U7W<\?XAYD\GZI[S]b^jb g7ݶ ޙ Y߷#$  Y#$  Y#$ Y#$  Y#$  Y#$ a Y#$ Y#$ : Y#$ K * Y#?L + Y#?  Y#$M , Y#?N- S- S -Y#$:S2 S2 S Y#$Gijkm!q)r0s:uByJzQ{[}ckr| #+/7>HPT\cmu} #.6  SE  K*Y#LYI#  K* Y #LY # K*Y#LY#  K*Y#LY#  K*Y#LY# K*Y #LY!#"# K*$Y%#LY&#'( K*)Y*#LY+#,-. K*Y#LYI# / 0K* Y #LY #1 2K*Y#LY#3 4K*Y#LY#5 6K*Y#LY#7 8K*Y #LY!#"9 :K*$Y%#LY&#'; <K*)Y*#LY+#,  NLO +K*=Y>#MYQ#?   SMT ,K*=Y@#NY# NK -K*YA#:YM#?  SM ,K*=YB#:Y#?  SM ,K*=YC#:Y#XY 6ZY[\K:6YD#^_E 6FW:6YG#cH 6IW:6YJ#gK 6LW:6YM#gN 6 OW:6YP#cQ 6RW:6YS#qT 6RW:6YU#gV 6aWW:6YX#gY 6 ZW:6Y[#g\ 6W:6:Y]#Y^#g $'HD`cHHHH8TWHuHHH7VYHwHHH7VYHwHHHC]`HHH),HS`cHHHH',/HX]`HHHH"%{"-H$'(2;DKU` cdo x#!"$(*+ ,0./&1/587?8I9T=W;X<c>lBuD|EFJHIKOQRSWUVX[^`a bfde%g.k7mAnKoVsYqZretnxwz{|~ %.7AKVYZenw'0;CHR]`aks{  ), . 8@HPS`cehmx!%()+.,-/0457:89;<@ACFDEGHL$M'O,R/P1Q4SDTLXUYX[]^`\b]e_u`}degjhiklpqsvtuwx|} "%'*-/:JR W_ `Ya#bc  `Yd#be `Yf#bg `Yh#bi `Yj#bk `Yl#bm $`Yn#bo )`Yp#bq =`Yr#s2 &Lr 09MV gtY  uKLv * wxxLMYz#+ Y{#+2|}Y#$'y6  $'(3:ER]frJava/src/java/NotAnArrayException.java0000644000176200001440000000043612256051760017574 0ustar liggesusers/** * Exception indicating that an object is not a java array */ public class NotAnArrayException extends Exception{ public NotAnArrayException(Class clazz){ super( "not an array : " + clazz.getName() ) ; } public NotAnArrayException(String message){ super( message ) ; } } rJava/src/java/RectangularArrayBuilder_Test.class0000644000176200001440000003343712256051765021653 0ustar liggesusers.                              ! "# $% &' () *+ ,- ./ 01 2 3 J456 789 J:; U< U= U>? U@ ABC UD EFG HIJ KLM NOP QRS TUV WXYZ [ \]^ _ `a bcdefghijklmn opqrstuvwxyz{|}~ dim1d[Idim2ddim3d()VCodeLineNumberTablemain([Ljava/lang/String;)Vruntests Exceptions fill_int_1fill_boolean_1 fill_byte_1 fill_long_1 fill_short_1 fill_double_1 fill_char_1 fill_float_1 fill_String_1 fill_Point_1 fill_int_2fill_boolean_2 fill_byte_2 fill_long_2 fill_short_2 fill_double_2 fill_char_2 fill_float_2 fill_String_2 fill_Point_2 fill_int_3fill_boolean_3 fill_byte_3 fill_long_3 fill_short_3 fill_double_3 fill_char_3 fill_float_3 fill_String_3 fill_Point_3ints(I)[Ibooleans(I)[Zbytes(I)[Blongs(I)[Jshorts(I)[Sdoubles(I)[Dchars(I)[Cfloats(I)[Fstrings(I)[Ljava/lang/String;points(I)[LDummyPoint; SourceFile!RectangularArrayBuilder_Test.java  TestException    ALL PASSED   >> 1 d fill int[]   : okfill boolean[]  fill byte[]  fill long[]  fill short[]  fill double[]  fill char[]  fill float[]  fill String[]  fill Point[]  >> 2 d fill int[][] fill boolean[][]  fill byte[][]  fill long[][] fill short[][] fill double[][]  fill char[][] fill float[][] fill String[][] fill Point[][]  >> 3 dfill int[][][] fill boolean[][][] fill byte[][][] fill long[][][] fill short[][][] fill double[][][] fill char[][][] fill float[][][] fill String[][][] fill Point[][][] RectangularArrayBuilder NotAnArrayExceptionnot an array int[10] ArrayDimensionExceptionarray dimensionexception java/lang/StringBufferdata[  ] !=  not an array boolean[10][Z  not an array byte[10][B not an array long[10][J not an array short[10][S not an array double[10][D not an array char[10][C not an array float[10][F not an array String[10][Ljava/lang/String;  not an array DummyPoint[10] [LDummyPoint;  ].x != [[I][[[Z[[B[[J[[S[[D[[C[[F[[Ljava/lang/String;not an array Point[10][[LDummyPoint; not an array int[30][[[I] != not an array boolean[30][[[Znot an array byte[30][[[Bnot an array long[30][[[Jnot an array short[30][[[Snot an array double[30][[[Dnot an array char[30][[[Cnot an array float[30][[[Fnot an array String[30][[[Ljava/lang/String;not an array Point[30][[[LDummyPoint;java/lang/String DummyPoint RectangularArrayBuilder_Testjava/lang/ObjectprintStackTracejava/lang/Systemexit(I)VoutLjava/io/PrintStream;java/io/PrintStreamprintln(Ljava/lang/String;)Vprint(Ljava/lang/Object;[I)VgetArray()Ljava/lang/Object;append,(Ljava/lang/String;)Ljava/lang/StringBuffer;(I)Ljava/lang/StringBuffer;toString()Ljava/lang/String;(Z)Ljava/lang/StringBuffer;equals(Ljava/lang/Object;)ZxIy(II)V! ,* X L+"  S                      ! " # $ % & ' ( ) * + , - . / 0 1 2 3 4 56 7 8 9 : ; < = > ? @ A B C D E F G H I ". A!T"g#z$%&'+,-./0-1@2S3f4y59:;<=>?@A,B?CRF xKJY KLMKLYOPLYRP*STTL=>L.7+.'YUYVWXYZXY[PƱN Q:KMRNO P!Q+T6U8VCWJXnVw\ KJY \LMKLY]PLYRP*S^^L=>L.>+3'YUYVWXYZX_[P=N Q:_afbc d!e+h6i8kClJmnk~q xKJY `LMKLYaPLYRP*SbbL=>L.7+3'YUYVWXYZXY[PƱN Q:tv{wx y!z+}6~8CJnw zKJY cLMKLYdPLYRP*SeeL=>L.9+/'YUYVWXYZXY[PıN Q: !+68CLpy xKJY fLMKLYgPLYRP*ShhL=>L.7+5'YUYVWXYZXY[PƱN Q: !+68CJnw zKJY iLMKLYjPLYRP*SkkL=>L.9+1'YUYVWXYZXY[PıN Q: !+68CLpy xKJY lLMKLYmPLYRP*SnnL=>L.7+4'YUYVWXYZXY[PƱN Q: !+68CJnw zKJY oLMKLYpPLYRP*SqqL=>L.9+0'YUYVWXYZXY[PıN Q: !+68CLpy KJY rLMKLYsPLYRP*SttL=>L.L+2UYVYuX[v'YUYVWXYZXY[PN Q: !+68C_ KJY wLMKLYxPLYRP*SyyL=>L.G+2:z {'YUYVWXY|XY[PN Q> !+ 6 8 C H Z~  KJY K}MKLYOPLYRP*S~~L=>}.W6}.D+2.1YUYVWXYXYZXY[PN QB !+!6"8#C$P%Z&$#+ KJY \}MKLY]PLYRP*SL=>}.^6}.K+231YUYVWXYXYZX_[P=N QB.0512 3!4+76889C:P;Z<:9A KJY `}MKLYaPLYRP*SL=>}.W6}.D+231YUYVWXYXYZXY[PN QBDFKGH I!J+M6N8OCPPQZRPOW KJY c}MKLYdPLYRP*SL=>}.Y6}.F+2/1YUYVWXYXYZXY[PN QBZ\a]^ _!`+c6d8eCfPg\hfem KJY f}MKLYgPLYRP*SL=>}.W6}.D+251YUYVWXYXYZXY[PN QBprwst u!v+y6z8{C|P}Z~|{ KJY i}MKLYjPLYRP*SL=>}.Y6}.F+211YUYVWXYXYZXY[PN QB !+68CP\ KJY l}MKLYmPLYRP*SL=>}.W6}.D+241YUYVWXYXYZXY[PN QB !+68CPZ KJY o}MKLYpPLYRP*SL=>}.Y6}.F+201YUYVWXYXYZXY[PN QB !+68CP\ KJY r}MKLYsPLYRP*SL=>}.l6}.Y+22UYVYuX[v1YUYVWXYXYZXY[PN QB !+68CPo KJY w}MKLYPLYRP*SL=>}.g6}.T+22:z {1YUYVWXYXY|XY[PN QF !+68CPXj $KJYKMKLYPLYRP*SL=>.w6.d6.Q+22.;YUYVWXYXYXYXY[PN QJ !+68CP]j  +KJY\MKLYPLYRP*SL=>.~6.k6.X+223;YUYVWXYXYXYX_[P=N QJ !+68CP]j$ $KJY`MKLYPLYRP*SL=>.w6.d6.Q+223;YUYVWXYXYXYXY[PN QJ').*+ ,!-+06182C3P4]5j6432; &KJYcMKLYPLYRP*SL=>.y6.f6.S+22/;YUYVWXYXYXYXY[PN QJ>@EAB C!D+G6H8ICJPK]LlMKJIR $KJYfMKLYPLYRP*SL=>.w6.d6.Q+225;YUYVWXYXYXYXY[PN QJUW\XY Z![+^6_8`CaPb]cjdba`i &KJYiMKLYPLYRP*SL=>.y6.f6.S+221;YUYVWXYXYXYXY[PN QJlnsop q!r+u6v8wCxPy]zl{yxw $KJYlMKLYPLYRP*SL=>.w6.d6.Q+224;YUYVWXYXYXYXY[PN QJ !+68CP]j &KJYoMKLYPLYRP*SL=>.y6.f6.S+220;YUYVWXYXYXYXY[PN QJ !+68CP]l 9KJYrMKLYPLYRP*SL=>.6.y6.f+222UYVYuX[v;YUYVWXYXYXYXY[PqN QJ !+68CP] 8KJYwMKLYPLYRP*SL=>.6.t6.a+222:z {;YUYVWXYXYXY|XY[PvN QN !+68CP]hz ? L= +O+  O#L=>+T=+ ! @L=+T+  @ L=+P+  @ L=+V+  BL=+cR+     @L=+U+  BL=+ bQ+  R*L=+UYVuXY[S+#$ %"$(' H L=+YS++, -,/L, Y OL YOYO} YOYOYO  rJava/src/java/RJavaTools_Test.java0000644000176200001440000006423012256051760016724 0ustar liggesusers // :tabSize=2:indentSize=2:noTabs=false:folding=explicit:collapseFolds=1: import java.lang.reflect.Constructor ; import java.lang.reflect.* ; import java.util.Map ; import java.util.Set ; import java.util.HashMap; public class RJavaTools_Test { private static class ExampleClass { public ExampleClass( Object o1, String o2, boolean o3, boolean o4){} public ExampleClass( Object o1, String o2, boolean o3){} public ExampleClass(){} } /* so that we can check about access to private fields and methods */ private int bogus = 0 ; private int getBogus(){ return bogus ; } private static int staticbogus ; private static int getStaticBogus(){ return staticbogus ; } public int x = 0 ; public static int static_x = 0; public int getX(){ return x ; } public static int getStaticX(){ return static_x ; } public void setX( Integer x ){ this.x = x.intValue(); } // {{{ main public static void main( String[] args){ try{ runtests() ; } catch( TestException e){ fails( e ) ; System.exit(1); } } public static void runtests() throws TestException { System.out.println( "Testing RJavaTools.getConstructor" ) ; constructors() ; success() ; System.out.println( "Testing RJavaTools.classHasField" ) ; classhasfield() ; success(); System.out.println( "Testing RJavaTools.classHasMethod" ) ; classhasmethod() ; success() ; System.out.println( "Testing RJavaTools.classHasClass" ) ; classhasclass() ; success(); System.out.println( "Testing RJavaTools.hasField" ) ; hasfield() ; success(); System.out.println( "Testing RJavaTools.hasClass" ) ; hasclass() ; success(); System.out.println( "Testing RJavaTools.getClass" ) ; getclass() ; success() ; System.out.println( "Testing RJavaTools.hasMethod" ) ; hasmethod() ; success() ; System.out.println( "Testing RJavaTools.isStatic" ) ; isstatic() ; success() ; System.out.println( "Testing RJavaTools.getCompletionName" ) ; getcompletionname() ; success(); System.out.println( "Testing RJavaTools.getFieldNames" ) ; getfieldnames() ; success() ; System.out.println( "Testing RJavaTools.getMethodNames" ) ; getmethodnames() ; success() ; System.out.println( "Testing RJavaTools.getStaticFields" ) ; getstaticfields() ; success() ; System.out.println( "Testing RJavaTools.getStaticMethods" ) ; getstaticmethods() ; success() ; System.out.println( "Testing RJavaTools.getStaticClasses" ) ; getstaticclasses() ; success() ; System.out.println( "Testing RJavaTools.invokeMethod" ) ; invokemethod() ; success() ; System.out.println( "Testing RJavaTools.getFieldTypeName" ) ; getfieldtypename(); success() ; System.out.println( "Testing RJavaTools.getMethod" ) ; System.out.println( "NOT YET AVAILABLE" ) ; System.out.println( "Testing RJavaTools.newInstance" ) ; System.out.println( "NOT YET AVAILABLE" ) ; } // }}} // {{{ fails private static void fails( TestException e ){ System.err.println( "\n" ) ; e.printStackTrace() ; System.err.println( "FAILED" ) ; } // }}} // {{{ success private static void success(){ System.out.println( "PASSED" ) ; } // }}} // {{{ @Test getFieldNames private static void getfieldnames() throws TestException{ String[] names; // {{{ getFieldNames(DummyPoint, false) -> c('x', 'y' ) System.out.print( " * getFieldNames(DummyPoint, false)" ) ; names = RJavaTools.getFieldNames( DummyPoint.class, false ) ; if( names.length != 2 ){ throw new TestException( "getFieldNames(DummyPoint, false).length != 2" ) ; } for( int i=0; i<2; i++){ if( !( "x".equals(names[i]) || "y".equals(names[i] ) ) ){ throw new TestException( "getFieldNames(DummyPoint, false).length != c('x','y') " ) ; } } System.out.println( " : ok " ) ; // }}} // {{{ getFieldNames(Point, true ) --> character(0) System.out.print( " * getFieldNames(DummyPoint, true )" ) ; names = RJavaTools.getFieldNames( DummyPoint.class, true ) ; if( names.length != 0 ){ throw new TestException( "getFieldNames(DummyPoint, true ) != character(0)" ); } System.out.println( " : ok " ) ; // }}} // {{{ getFieldNames(RJavaTools_Test, true ) --> static_x System.out.print( " * getFieldNames(RJavaTools_Test, true )" ) ; names = RJavaTools.getFieldNames( RJavaTools_Test.class, true ) ; if( names.length != 1 ){ throw new TestException( "getFieldNames(RJavaTools_Test, true ).length != 1" ); } if( ! "static_x".equals( names[0] ) ){ throw new TestException( "getFieldNames(RJavaTools_Test, true )[0] != 'static_x' " ); } System.out.println( " : ok " ) ; // }}} // {{{ getFieldNames(RJavaTools_Test, false ) --> c('x', 'static_x') System.out.print( " * getFieldNames(RJavaTools_Test, false )" ) ; names = RJavaTools.getFieldNames( RJavaTools_Test.class, false ) ; if( names.length != 2 ){ throw new TestException( "getFieldNames(RJavaTools_Test, false ).length != 2" ); } for( int i=0; i<2; i++){ if( ! ( "x".equals( names[i] ) || "static_x".equals(names[i]) ) ){ throw new TestException( "getFieldNames(RJavaTools_Test, false ) != c('x', 'static_x') " ); } } System.out.println( " : ok " ) ; // }}} } // }}} // {{{ @Test getMethodNames private static void getmethodnames() throws TestException{ String[] names ; String[] expected ; int cpt = 0; // {{{ getMethodNames(RJavaTools_Test, true) -> c('getStaticX()', 'main(', 'runtests' ) System.out.print( " * getMethodNames(RJavaTools_Test, true)" ) ; names = RJavaTools.getMethodNames( RJavaTools_Test.class, true ) ; if( names.length != 3 ){ throw new TestException( "getMethodNames(RJavaTools_Test, true).length != 3 (" + names.length + ")" ) ; } expected= new String[]{ "getStaticX()", "main(", "runtests()" }; cpt = 0; for( int i=0; i character(0) ) System.out.print( " * getMethodNames(Object, true)" ) ; names = RJavaTools.getMethodNames( Object.class, true ) ; if( names.length != 0 ){ throw new TestException( "getMethodNames(Object, true).length != 0 (" + names.length + ")" ) ; } System.out.println( " : ok " ) ; // }}} // {{{ getMethodNames(RJavaTools_Test, false) %contains% { "getX()", "getStaticX()", "setX(", "main(" } System.out.print( " * getMethodNames(RJavaTools_Test, false)" ) ; names = RJavaTools.getMethodNames( RJavaTools_Test.class, false ) ; cpt = 0; expected = new String[]{ "getX()", "getStaticX()", "setX(", "main(" }; for( int i=0; i false try{ System.out.print( " * isStatic(RJavaTools_Test.x)" ) ; f = RJavaTools_Test.class.getField("x") ; if( RJavaTools.isStatic( f) ){ throw new TestException( "isStatic(RJavaTools_Test.x) == true" ) ; } System.out.println( " = false : ok " ) ; } catch( NoSuchFieldException e){ throw new TestException( e.getMessage() ) ; } // }}} // {{{ isStatic(RJavaTools_Test.getX) -> true try{ System.out.print( " * isStatic(RJavaTools_Test.getX() )" ) ; m = RJavaTools_Test.class.getMethod("getX", (Class[])null ) ; if( RJavaTools.isStatic( m ) ){ throw new TestException( "isStatic(RJavaTools_Test.getX() ) == false" ) ; } System.out.println( " = false : ok " ) ; } catch( NoSuchMethodException e){ throw new TestException( e.getMessage() ) ; } // }}} // {{{ isStatic(RJavaTools_Test.static_x) -> true try{ System.out.print( " * isStatic(RJavaTools_Test.static_x)" ) ; f = RJavaTools_Test.class.getField("static_x") ; if( ! RJavaTools.isStatic( f) ){ throw new TestException( "isStatic(RJavaTools_Test.static_x) == false" ) ; } System.out.println( " = true : ok " ) ; } catch( NoSuchFieldException e){ throw new TestException( e.getMessage() ) ; } // }}} // {{{ isStatic(RJavaTools_Test.getStaticX) -> true try{ System.out.print( " * isStatic(RJavaTools_Test.getStaticX() )" ) ; m = RJavaTools_Test.class.getMethod("getStaticX", (Class[])null ) ; if( ! RJavaTools.isStatic( m ) ){ throw new TestException( "isStatic(RJavaTools_Test.getStaticX() ) == false" ) ; } System.out.println( " = true : ok " ) ; } catch( NoSuchMethodException e){ throw new TestException( e.getMessage() ) ; } // }}} /* classes */ // {{{ isStatic(RJavaTools_Test.TestException) -> true System.out.print( " * isStatic(RJavaTools_Test.TestException )" ) ; Class cl = RJavaTools_Test.TestException.class ; if( ! RJavaTools.isStatic( cl ) ){ throw new TestException( "isStatic(RJavaTools_Test.TestException) == false" ) ; } System.out.println( " = true : ok " ) ; // }}} // {{{ isStatic(RJavaTools_Test.DummyNonStaticClass) -> false System.out.print( " * isStatic(RJavaTools_Test.DummyNonStaticClass )" ) ; cl = RJavaTools_Test.DummyNonStaticClass.class ; if( RJavaTools.isStatic( cl ) ){ throw new TestException( "isStatic(RJavaTools_Test.DummyNonStaticClass) == true" ) ; } System.out.println( " = false : ok " ) ; // }}} } // }}} // {{{ @Test constructors private static void constructors() throws TestException { /* constructors */ Constructor cons ; boolean error ; // {{{ getConstructor( String, null ) System.out.print( " * getConstructor( String, null )" ) ; try{ cons = RJavaTools.getConstructor( String.class, (Class[])null, (boolean[])null ) ; } catch( Exception e ){ throw new TestException( "getConstructor( String, null )" ) ; } System.out.println( " : ok " ) ; // }}} // {{{ getConstructor( Integer, { String.class } ) System.out.print( " * getConstructor( Integer, { String.class } )" ) ; try{ cons = RJavaTools.getConstructor( Integer.class, new Class[]{ String.class }, new boolean[]{false} ) ; } catch( Exception e){ throw new TestException( "getConstructor( Integer, { String.class } )" ) ; } System.out.println( " : ok " ) ; // }}} // disabled for now // // {{{ getConstructor( JButton, { String.class, ImageIcon.class } ) // System.out.print( " * getConstructor( JButton, { String.class, ImageIcon.class } )" ) ; // try{ // cons = RJavaTools.getConstructor( JButton.class, // new Class[]{ String.class, ImageIcon.class }, // new boolean[]{ false, false} ) ; // } catch( Exception e){ // throw new TestException( "getConstructor( JButton, { String.class, ImageIcon.class } )" ) ; // } // System.out.println( " : ok " ) ; // // }}} // {{{ getConstructor( Integer, null ) -> exception error = false ; System.out.print( " * getConstructor( Integer, null )" ) ; try{ cons = RJavaTools.getConstructor( Integer.class, (Class[])null, (boolean[])null ) ; } catch( Exception e){ error = true ; } if( !error ){ throw new TestException( "getConstructor( Integer, null ) did not generate error" ) ; } System.out.println( " -> exception : ok " ) ; // }}} // disabled for now // // {{{ getConstructor( JButton, { String.class, JButton.class } ) -> exception // error = false ; // System.out.print( " * getConstructor( JButton, { String.class, JButton.class } )" ) ; // try{ // cons = RJavaTools.getConstructor( JButton.class, // new Class[]{ String.class, JButton.class }, // new boolean[]{ false, false } ) ; // } catch( Exception e){ // error = true ; // } // if( !error ){ // throw new TestException( "getConstructor( JButton, { String.class, JButton.class } ) did not generate error" ) ; // } // System.out.println( " -> exception : ok " ) ; // // }}} Object o1 = null ; Object o2 = null ; ExampleClass foo = new ExampleClass(o1,(String)o2,false) ; // {{{ getConstructor( ExampleClass, { null, null, false } error = false ; System.out.print( " * getConstructor( ExampleClass, {Object.class, Object.class, boolean}) : " ) ; try{ cons = RJavaTools.getConstructor( ExampleClass.class, new Class[]{ Object.class, Object.class, Boolean.TYPE}, new boolean[]{ true, true, false} ); } catch(Exception e){ error = true ; e.printStackTrace() ; } if( error ){ throw new TestException( "getConstructor( ExampleClass, {Object.class, Object.class, boolean}) : exception " ) ; } System.out.println( " ok" ) ; // }}} } // }}} // {{{ @Test methods private static void methods() throws TestException{ } // }}} // {{{ @Test hasfields private static void hasfield() throws TestException{ DummyPoint p = new DummyPoint() ; System.out.println( " java> DummyPoint p = new DummyPoint()" ) ; System.out.print( " * hasField( p, 'x' ) " ) ; if( !RJavaTools.hasField( p, "x" ) ){ throw new TestException( " hasField( DummyPoint, 'x' ) == false" ) ; } System.out.println( " true : ok" ) ; System.out.print( " * hasField( p, 'iiiiiiiiiiiii' ) " ) ; if( RJavaTools.hasField( p, "iiiiiiiiiiiii" ) ){ throw new TestException( " hasField( DummyPoint, 'iiiiiiiiiiiii' ) == true" ) ; } System.out.println( " false : ok" ) ; /* testing a private field */ RJavaTools_Test ob = new RJavaTools_Test(); System.out.print( " * testing a private field " ) ; if( RJavaTools.hasField( ob, "bogus" ) ){ throw new TestException( " hasField returned true on private field" ) ; } System.out.println( " false : ok" ) ; } // }}} // {{{ @Test hasmethod private static void hasmethod() throws TestException{ DummyPoint p = new DummyPoint() ; System.out.println( " java> DummyPoint p = new DummyPoint()" ) ; System.out.print( " * hasMethod( p, 'move' ) " ) ; if( !RJavaTools.hasMethod( p, "move" ) ){ throw new TestException( " hasField( DummyPoint, 'move' ) == false" ) ; } System.out.println( " true : ok" ) ; System.out.print( " * hasMethod( p, 'iiiiiiiiiiiii' ) " ) ; if( RJavaTools.hasMethod( p, "iiiiiiiiiiiii" ) ){ throw new TestException( " hasMethod( Point, 'iiiiiiiiiiiii' ) == true" ) ; } System.out.println( " false : ok" ) ; /* testing a private method */ RJavaTools_Test ob = new RJavaTools_Test(); System.out.print( " * testing a private method " ) ; if( RJavaTools.hasField( ob, "getBogus" ) ){ throw new TestException( " hasMethod returned true on private method" ) ; } System.out.println( " false : ok" ) ; } // }}} // {{{ @Test hasclass private static void hasclass() throws TestException{ RJavaTools_Test ob = new RJavaTools_Test(); System.out.print( " * hasClass( RJavaTools_Test, 'TestException' ) " ) ; if( ! RJavaTools.hasClass( ob, "TestException" ) ){ throw new TestException( " hasClass( RJavaTools_Test, 'TestException' ) == false" ) ; } System.out.println( " true : ok" ) ; System.out.print( " * hasClass( RJavaTools_Test, 'DummyNonStaticClass' ) " ) ; if( ! RJavaTools.hasClass( ob, "DummyNonStaticClass" ) ){ throw new TestException( " hasClass( RJavaTools_Test, 'DummyNonStaticClass' ) == false" ) ; } System.out.println( " true : ok" ) ; } // }}} // {{{ @Test hasclass private static void getclass() throws TestException{ Class cl ; System.out.print( " * getClass( RJavaTools_Test, 'TestException', true ) " ) ; cl = RJavaTools.getClass( RJavaTools_Test.class, "TestException", true ); if( cl != RJavaTools_Test.TestException.class ){ throw new TestException( " getClass( RJavaTools_Test, 'TestException', true ) != TestException" ) ; } System.out.println( " : ok" ) ; System.out.print( " * getClass( RJavaTools_Test, 'DummyNonStaticClass', true ) " ) ; cl = RJavaTools.getClass( RJavaTools_Test.class, "DummyNonStaticClass", true ); if( cl != null ){ throw new TestException( " getClass( RJavaTools_Test, 'DummyNonStaticClass', true ) != null" ) ; } System.out.println( " : ok" ) ; System.out.print( " * getClass( RJavaTools_Test, 'DummyNonStaticClass', false ) " ) ; cl = RJavaTools.getClass( RJavaTools_Test.class, "DummyNonStaticClass", false ); if( cl != RJavaTools_Test.DummyNonStaticClass.class ){ throw new TestException( " getClass( RJavaTools_Test, 'DummyNonStaticClass', true ) != null" ) ; } System.out.println( " : ok" ) ; } // }}} // {{{ @Test classhasfield private static void classhasfield() throws TestException{ } // }}} // {{{ @Test classhasclass private static void classhasclass() throws TestException{ System.out.print( " * classHasClass( RJavaTools_Test, 'TestException', true ) " ) ; if( ! RJavaTools.classHasClass( RJavaTools_Test.class , "TestException", true ) ){ throw new TestException( " classHasClass( RJavaTools_Test, 'TestException', true ) == false" ) ; } System.out.println( " true : ok" ) ; System.out.print( " * classHasClass( RJavaTools_Test, 'DummyNonStaticClass', true ) " ) ; if( RJavaTools.classHasClass( RJavaTools_Test.class , "DummyNonStaticClass", true ) ){ throw new TestException( " classHasClass( RJavaTools_Test, 'DummyNonStaticClass', true ) == true" ) ; } System.out.println( " false : ok" ) ; System.out.print( " * classHasClass( RJavaTools_Test, 'DummyNonStaticClass', false ) " ) ; if( ! RJavaTools.classHasClass( RJavaTools_Test.class , "DummyNonStaticClass", false ) ){ throw new TestException( " classHasClass( RJavaTools_Test, 'DummyNonStaticClass', false ) == false" ) ; } System.out.println( " true : ok" ) ; } // }}} // {{{ @Test classhasmethod private static void classhasmethod() throws TestException{ System.out.print( " * classHasMethod( RJavaTools_Test, 'getX', false ) " ) ; if( ! RJavaTools.classHasMethod( RJavaTools_Test.class, "getX", false ) ){ throw new TestException( " classHasMethod( RJavaTools_Test, 'getX', false ) == false" ) ; } System.out.println( " true : ok" ) ; System.out.print( " * classHasMethod( RJavaTools_Test, 'getStaticX', false ) " ) ; if( ! RJavaTools.classHasMethod( RJavaTools_Test.class, "getStaticX", false ) ){ throw new TestException( " classHasMethod( RJavaTools_Test, 'getStaticX', false ) == false" ) ; } System.out.println( " true : ok" ) ; System.out.print( " * classHasMethod( RJavaTools_Test, 'getX', true ) " ) ; if( RJavaTools.classHasMethod( RJavaTools_Test.class, "getX", true ) ){ throw new TestException( " classHasMethod( RJavaTools_Test, 'getX', true ) == true (non static method)" ) ; } System.out.println( " false : ok" ) ; System.out.print( " * classHasMethod( RJavaTools_Test, 'getStaticX', true ) " ) ; if( ! RJavaTools.classHasMethod( RJavaTools_Test.class, "getStaticX", true ) ){ throw new TestException( " classHasMethod( RJavaTools_Test, 'getStaticX', true ) == false (static)" ) ; } System.out.println( " true : ok" ) ; System.out.print( " * classHasMethod( RJavaTools_Test, 'getBogus', false ) " ) ; if( RJavaTools.classHasMethod( RJavaTools_Test.class, "getBogus", false ) ){ throw new TestException( " classHasMethod( RJavaTools_Test, 'getBogus', false ) == true (private method)" ) ; } System.out.println( " false : ok" ) ; System.out.print( " * classHasMethod( RJavaTools_Test, 'getStaticBogus', true ) " ) ; if( RJavaTools.classHasMethod( RJavaTools_Test.class, "getStaticBogus", true ) ){ throw new TestException( " classHasMethod( RJavaTools_Test, 'getBogus', true ) == true (private method)" ) ; } System.out.println( " false : ok" ) ; } // }}} // {{{ @Test getstaticfields private static void getstaticfields() throws TestException{ Field[] f ; System.out.print( " * getStaticFields( RJavaTools_Test ) " ) ; f = RJavaTools.getStaticFields( RJavaTools_Test.class ) ; if( f.length != 1 ){ throw new TestException( " getStaticFields( RJavaTools_Test ).length != 1" ) ; } if( ! "static_x".equals( f[0].getName() ) ){ throw new TestException( " getStaticFields( RJavaTools_Test )[0] != 'static_x'" ) ; } System.out.println( " : ok" ) ; System.out.print( " * getStaticFields( Object ) " ) ; f = RJavaTools.getStaticFields( Object.class ) ; if( f != null ){ throw new TestException( " getStaticFields( Object ) != null" ) ; } System.out.println( " : ok" ) ; } // }}} // {{{ @Test getstaticmethods private static void getstaticmethods() throws TestException{ Method[] m ; // {{{ getStaticMethods( RJavaTools_Test ) System.out.print( " * getStaticMethods( RJavaTools_Test ) " ) ; m = RJavaTools.getStaticMethods( RJavaTools_Test.class ) ; String[] expected = new String[]{ "getStaticX" , "main", "runtests" }; int count = 0; if( m.length != expected.length ){ throw new TestException( " getStaticMethods( RJavaTools_Test ).length != 2" ) ; } for( int i=0; i 0 ) { smallest = current ; } } } return smallest ; } /** * returns the minimum (in the sense of Comparable) of the * objects in the one dimensioned array */ private static Object max( Object[] x, boolean narm ){ int n = x.length ; Object biggest = null ; Object current ; boolean found_min = false; // find somewhere to start from () for( int i=0; i 0 ) { range[0] = current ; } } } } return range ; } public void checkComparableObjects() throws NotComparableException { if( ! containsComparableObjects() ) throw new NotComparableException( typeName ) ; } public boolean containsComparableObjects(){ return Comparable.class.isAssignableFrom( componentType ) ; } // TODO : use these private static boolean smaller( Object x, Object y){ return ( (Comparable)x ).compareTo(y) < 0 ; } private static boolean bigger( Object x, Object y){ return ( (Comparable)x ).compareTo(y) > 0 ; } } rJava/src/java/RJavaImport.java0000644000176200001440000001032212256051760016070 0ustar liggesusers import java.util.regex.Pattern ; import java.util.regex.Matcher ; import java.util.Vector; import java.util.HashMap; import java.util.Map; import java.util.Collection; import java.util.Set ; import java.util.Iterator ; import java.io.Serializable; /** * Utilities to manage java packages and how they are "imported" to R * databases. This is the back door of the javaImport * system in the R side * * @author Romain Francois */ public class RJavaImport implements Serializable { /** * Debug flag. Prints some messages if it is set to TRUE */ public static boolean DEBUG = false ; /** * list of imported packages */ /* TODO: vector is not good enough, we need to control the order in which the packages appear */ private Vector/**/ importedPackages ; /** * maps a simple name to a fully qualified name */ /* String -> java.lang.String */ /* should we cache the Class instead ? */ private Map/**/ cache ; /** * associated class loader */ public ClassLoader loader ; /** * Constructor. Initializes the imported package vector and the cache */ public RJavaImport( ClassLoader loader ){ this.loader = loader ; importedPackages = new Vector/**/(); cache = new HashMap/**/() ; } /** * Look for the class in the set of packages * * @param clazz the simple class name * * @return an instance of Class representing the actual class */ public Class lookup( String clazz){ Class res = lookup_(clazz) ; if( DEBUG ) System.out.println( " [J] lookup( '" + clazz + "' ) = " + (res == null ? " " : ("'" + res.getName() + "'" ) ) ) ; return res ; } private Class lookup_( String clazz ){ Class res = null ; if( cache.containsKey( clazz ) ){ try{ String fullname = (String)cache.get( clazz ) ; Class cl = Class.forName( fullname ) ; return cl ; } catch( Exception e ){ /* does not happen */ } } /* first try to see if the class does not exist verbatim */ try{ res = Class.forName( clazz ) ; } catch( Exception e){} if( res != null ) { cache.put( clazz, clazz ) ; return res; } int npacks = importedPackages.size() ; if( DEBUG ) System.out.println( " [J] " + npacks + " packages" ) ; if( npacks > 0 ){ for( int i=0; i*/ set = cache.keySet() ; int size = set.size() ; String[] res = new String[size]; set.toArray( res ); if( DEBUG ) System.out.println( " [J] getKnownClasses().length = " + res.length ) ; return res ; } public static Class lookup( String clazz , Set importers ){ Class res ; Iterator iterator = importers.iterator() ; while( iterator.hasNext()){ RJavaImport importer = (RJavaImport)iterator.next() ; res = importer.lookup( clazz ) ; if( res != null ) return res ; } return null ; } } rJava/src/java/RJavaArrayIterator.java0000644000176200001440000000321712256051760017413 0ustar liggesusersimport java.lang.reflect.Array ; public abstract class RJavaArrayIterator { protected int[] dimensions; protected int nd ; protected int[] index ; protected int[] dimprod ; protected Object array ; protected int increment; protected int position ; protected int start ; public Object getArray(){ return array ; } /** * @return the class name of the array */ public String getArrayClassName(){ return array.getClass().getName(); } public int[] getDimensions(){ return dimensions; } public RJavaArrayIterator(){ dimensions = null; index = null ; dimprod = null ; array = null ; } public RJavaArrayIterator(int[] dimensions){ this.dimensions = dimensions ; nd = dimensions.length ; if( nd > 1){ index = new int[ nd-1 ] ; dimprod = new int[ nd-1 ] ; for( int i=0; i<(nd-1); i++){ index[i] = 0 ; dimprod[i] = (i==0) ? dimensions[i] : ( dimensions[i]*dimprod[i-1] ); increment = dimprod[i] ; } } position = 0 ; start = 0; } public RJavaArrayIterator(int d1){ this( new int[]{ d1} ) ; } protected Object next( ){ /* get the next array and the position of the first elemtn in the flat array */ Object o = array ; for( int i=0; i=0; i--){ if( (index[i] + 1) == dimensions[i] ){ index[i] = 0 ; } else{ index[i] = index[i] + 1 ; } } position++ ; return o; } protected boolean hasNext( ){ return position < increment ; } } rJava/src/java/TestException.java0000644000176200001440000000025312256051760016472 0ustar liggesusers/** * Generated as part of testing rjava internal java tools */ public class TestException extends Exception{ public TestException(String message){super(message);} } rJava/src/java/RJavaArrayIterator.class0000644000176200001440000000274412256051764017607 0ustar liggesusers.D , - ./ 0 1 2 3 4 5 6 7 8 9:;< dimensions[IndIindexdimprodarrayLjava/lang/Object; incrementpositionstartgetArray()Ljava/lang/Object;CodeLineNumberTablegetArrayClassName()Ljava/lang/String; getDimensions()[I()V([I)V(I)VnexthasNext()Z SourceFileRJavaArrayIterator.java  =>? @  #$       #%A BCRJavaArrayIteratorjava/lang/ObjectgetClass()Ljava/lang/Class;java/lang/ClassgetNamejava/lang/reflect/Arrayget'(Ljava/lang/Object;I)Ljava/lang/Object;!* # *!"*#$E*****  !"#%y**+*+*Z**d **d =*d6*O* +.+.*d.hO**. * * :$% &'(#)/*;+B,^-h*n0s1x2#&( * YO  4 5'*L=*=+*. L**. *Y *.*d.h` *d=2*.`*. *O**.`O*Y ` +::;<=>,@D;JEVFgGqIEMN())* * R*+rJava/src/java/RJavaTools_Test$ExampleClass.class0000644000176200001440000000071112256051764021454 0ustar liggesusers.  )(Ljava/lang/Object;Ljava/lang/String;ZZ)VCodeLineNumberTable((Ljava/lang/Object;Ljava/lang/String;Z)V()V SourceFileRJavaTools_Test.java  RJavaTools_Test$ExampleClass ExampleClass InnerClassesjava/lang/ObjectRJavaTools_Test * *  *     rJava/src/java/RectangularArrayBuilder.class0000644000176200001440000001133012256051764020637 0ustar liggesusers. @k lmn op q lrst uv w x y z ?{ l| }~ l   ? ? ? ? ? ? ? ? ? ? @u z ? ? ? ?(Ljava/lang/Object;[I)VCodeLineNumberTable Exceptions(Ljava/lang/Object;I)V(I[I)V(Z[I)V(B[I)V(J[I)V(S[I)V(D[I)V(C[I)V(F[I)V(II)V(ZI)V(BI)V(JI)V(SI)V(DI)V(CI)V(FI)Vfill_int([I)V fill_boolean([Z)V fill_byte([B)V fill_long([J)V fill_short([S)V fill_double([D)V fill_char([C)V fill_float([F)V fill_Object([Ljava/lang/Object;)V SourceFileRectangularArrayBuilder.java AX NotAnArrayException A ArrayDimensionExceptionjava/lang/StringBuffer Anot a single dimension array : A   java/lang/ClassNotFoundException I [I WXZ[Z YZB[B [\J[J ]^S[S _`D[D abC[C cdF[F ef[Ljava/lang/Object; gh ABprimitive type : int primitive type : boolean primitive type : byte primitive type : long primitive type : short primitive type : double primitive type : char primitive type : float RectangularArrayBuilderRJavaArrayIteratorRJavaArrayToolsisArray(Ljava/lang/Object;)Zjava/lang/ObjectgetClass()Ljava/lang/Class;(Ljava/lang/Class;)VisSingleDimensionArray()Vappend,(Ljava/lang/String;)Ljava/lang/StringBuffer;,(Ljava/lang/Object;)Ljava/lang/StringBuffer;toString()Ljava/lang/String;(Ljava/lang/String;)VarrayLjava/lang/Object;getObjectTypeName&(Ljava/lang/Object;)Ljava/lang/String;java/lang/ClassgetClassLoader()Ljava/lang/ClassLoader;getClassForSignature<(Ljava/lang/String;Ljava/lang/ClassLoader;)Ljava/lang/Class;java/lang/reflect/Array newInstance'(Ljava/lang/Class;[I)Ljava/lang/Object;java/lang/StringequalshasNext()Znext()Ljava/lang/Object;start increment!?@ABC3*,+Y++!YY  + , *++N:-+::*,-*+-*+-*+-*+ !j-"*+##$S-%*+&&'<-(*+))*%-+*+,,-*+../S`cDz =CK P!S#`$e&o'x()*+,-./0123456'82<EAFC) *+ YO0D > ?EAGC&*1Y23DBEAHC&*1Y43DCEAIC&*1Y53DDEAJC&*1Y63DEEAKC&*1Y73DFEALC&*1Y83DGEAMC&*1Y93DHEANC&*1Y:3DIEAOC&*1Y23DKEAPC&*1Y43DLEAQC&*1Y53DMEARC&*1Y63DNEASC&*1Y73DOEATC&*1Y83DPEAUC&*1Y93DQEAVC&*1Y:3DREWXCm9*;4*<N*==6--+.O*>`=˱D"XYZ[!\([5^8_YZCm9*;4*<N*==6--+3T*>`=˱D"cdef!g(f5i8j[\Cm9*;4*<N*==6--+3T*>`=˱D"nopq!r(q5t8u]^Cm9*;4*< N*==6--+/P*>`=˱D"yz{|!}(|58_`Cm9*;4*<##N*==6--+5V*>`=˱D"!(58abCm9*;4*<&&N*==6--+1R*>`=˱D"!(58cdCm9*;4*<))N*==6--+4U*>`=˱D"!(58efCm9*;4*<,,N*==6--+0Q*>`=˱D"!(58ghCm9*;4*<..N*==6--+2S*>`=˱D"!(58ijrJava/src/java/RJavaArrayTools.java0000644000176200001440000007064012256051760016726 0ustar liggesusers// RJavaTools.java: rJava - low level R to java interface // // :tabSize=2:indentSize=2:noTabs=false:folding=explicit:collapseFolds=1: // // Copyright (C) 2009 - 2010 Simon Urbanek and Romain Francois // // This file is part of rJava. // // rJava is free software: you can redistribute it and/or modify it // under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 2 of the License, or // (at your option) any later version. // // rJava is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with rJava. If not, see . import java.lang.reflect.Array ; import java.util.Map; import java.util.HashMap; import java.util.Vector ; import java.util.Arrays ; import java.util.Iterator; import java.lang.reflect.Method ; import java.lang.reflect.InvocationTargetException ; public class RJavaArrayTools { // TODO: maybe factor this out of this class private static Map primitiveClasses = initPrimitiveClasses() ; private static Map initPrimitiveClasses(){ Map primitives = new HashMap(); primitives.put( "I", Integer.TYPE ); primitives.put( "Z", Boolean.TYPE ); primitives.put( "B", Byte.TYPE ); primitives.put( "J", Long.TYPE ); primitives.put( "S", Short.TYPE ); primitives.put( "D", Double.TYPE ); primitives.put( "C", Character.TYPE ); primitives.put( "F", Float.TYPE ); return primitives; } // {{{ getObjectTypeName /** * Get the object type name of an multi dimensional array. * * @param o object * @throws NotAnArrayException if the object is not an array */ public static String getObjectTypeName(Object o) throws NotAnArrayException { Class o_clazz = o.getClass(); if( !o_clazz.isArray() ) throw new NotAnArrayException( o_clazz ); String cl = o_clazz.getName(); return cl.replaceFirst("\\[+L?", "").replace(";", "") ; } public static int getObjectTypeName(int x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : int ") ; } public static int getObjectTypeName(boolean x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : boolean ") ; } public static int getObjectTypeName(byte x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : byte ") ; } public static int getObjectTypeName(long x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : long ") ; } public static int getObjectTypeName(short x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : short ") ; } public static int getObjectTypeName(double x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : double ") ; } public static int getObjectTypeName(char x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : char ") ; } public static int getObjectTypeName(float x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : float ") ; } // }}} // {{{ makeArraySignature // TODO: test public static String makeArraySignature( String typeName, int depth ){ StringBuffer buffer = new StringBuffer() ; for( int i=0; i 1 ) return false; if( name.equals("I") ) return true ; if( name.equals("Z") ) return true ; if( name.equals("B") ) return true ; if( name.equals("J") ) return true ; if( name.equals("S") ) return true ; if( name.equals("D") ) return true ; if( name.equals("C") ) return true ; if( name.equals("F") ) return true ; return false; } // }}} // {{{ isRectangularArray /** * Indicates if o is a rectangular array * * @param o an array * @throws NotAnArrayException if o is not an array * @deprecated use new ArrayWrapper(o).isRectangular() instead */ public static boolean isRectangularArray(Object o) { if( !isArray(o) ) return false; boolean res = false; try{ if( getDimensionLength( o ) == 1 ) return true ; res = ( new ArrayWrapper(o) ).isRectangular() ; } catch( NotAnArrayException e){ res = false; } return res ; } // thoose below make java < 1.5 happy and me unhappy ;-) public static boolean isRectangularArray(int x) { return false ; } public static boolean isRectangularArray(boolean x) { return false ; } public static boolean isRectangularArray(byte x) { return false ; } public static boolean isRectangularArray(long x) { return false ; } public static boolean isRectangularArray(short x) { return false ; } public static boolean isRectangularArray(double x) { return false ; } public static boolean isRectangularArray(char x) { return false ; } public static boolean isRectangularArray(float x) { return false ; } // }}} // {{{ getDimensionLength /** * Returns the number of dimensions of an array * * @param o an array * @throws NotAnArrayException if this is not an array */ public static int getDimensionLength( Object o) throws NotAnArrayException, NullPointerException { if( o == null ) throw new NullPointerException( "array is null" ) ; Class clazz = o.getClass(); if( !clazz.isArray() ) throw new NotAnArrayException(clazz) ; int n = 0; while( clazz.isArray() ){ n++ ; clazz = clazz.getComponentType() ; } return n ; } // thoose below make java < 1.5 happy and me unhappy ;-) public static int getDimensionLength(int x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : int ") ; } public static int getDimensionLength(boolean x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : boolean ") ; } public static int getDimensionLength(byte x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : byte ") ; } public static int getDimensionLength(long x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : long ") ; } public static int getDimensionLength(short x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : short ") ; } public static int getDimensionLength(double x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : double ") ; } public static int getDimensionLength(char x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : char ") ; } public static int getDimensionLength(float x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : float ") ; } // }}} // {{{ getDimensions /** * Returns the dimensions of an array * * @param o an array * @throws NotAnArrayException if this is not an array * @return the dimensions of the array or null if the object is null */ public static int[] getDimensions( Object o) throws NotAnArrayException, NullPointerException { if( o == null ) throw new NullPointerException( "array is null" ) ; Class clazz = o.getClass(); if( !clazz.isArray() ) throw new NotAnArrayException(clazz) ; Object a = o ; int n = getDimensionLength( o ) ; int[] dims = new int[n] ; int i=0; int current ; while( clazz.isArray() ){ current = Array.getLength( a ) ; dims[i] = current ; i++; if( current == 0 ){ break ; // the while loop } else { a = Array.get( a, 0 ) ; clazz = clazz.getComponentType() ; } } /* in case of premature stop, we fill the rest of the array with 0 */ // this might not be true: // Object[][] = new Object[0][10] will return c(0,0) while( i < dims.length){ dims[i] = 0 ; i++ ; } return dims ; } // thoose below make java < 1.5 happy and me unhappy ;-) public static int[] getDimensions(int x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : int ") ; } public static int[] getDimensions(boolean x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : boolean ") ; } public static int[] getDimensions(byte x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : byte ") ; } public static int[] getDimensions(long x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : long ") ; } public static int[] getDimensions(short x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : short ") ; } public static int[] getDimensions(double x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : double ") ; } public static int[] getDimensions(char x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : char ") ; } public static int[] getDimensions(float x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : float ") ; } // }}} // {{{ getTrueLength /** * Returns the true length of an array (the product of its dimensions) * * @param o an array * @throws NotAnArrayException if this is not an array * @return the number of objects in the array (the product of its dimensions). */ public static int getTrueLength( Object o) throws NotAnArrayException, NullPointerException { if( o == null ) throw new NullPointerException( "array is null" ) ; Class clazz = o.getClass(); if( !clazz.isArray() ) throw new NotAnArrayException(clazz) ; Object a = o ; int len = 1 ; int i = 0; while( clazz.isArray() ){ len = len * Array.getLength( a ) ; if( len == 0 ) return 0 ; /* no need to go further */ i++; a = Array.get( a, 0 ) ; clazz = clazz.getComponentType() ; } return len ; } // thoose below make java < 1.5 happy and me unhappy ;-) public static int getTrueLength(int x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : int ") ; } public static int getTrueLength(boolean x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : boolean ") ; } public static int getTrueLength(byte x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : byte ") ; } public static int getTrueLength(long x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : long ") ; } public static int getTrueLength(short x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : short ") ; } public static int getTrueLength(double x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : double ") ; } public static int getTrueLength(char x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : char ") ; } public static int getTrueLength(float x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : float ") ; } // }}} // {{{ isArray /** * Indicates if a java object is an array * * @param o object * @return true if the object is an array * @deprecated use RJavaArrayTools#isArray */ public static boolean isArray(Object o){ if( o == null) return false ; return o.getClass().isArray() ; } // thoose below make java < 1.5 happy and me unhappy ;-) public static boolean isArray(int x){ return false ; } public static boolean isArray(boolean x){ return false ; } public static boolean isArray(byte x){ return false ; } public static boolean isArray(long x){ return false ; } public static boolean isArray(short x){ return false ; } public static boolean isArray(double x){ return false ; } public static boolean isArray(char x){ return false ; } public static boolean isArray(float x){ return false ; } // }}} // {{{ ArrayDimensionMismatchException public static class ArrayDimensionMismatchException extends Exception { public ArrayDimensionMismatchException( int index_dim, int actual_dim ){ super( "dimension of indexer (" + index_dim + ") too large for array (depth ="+ actual_dim+ ")") ; } } // }}} // {{{ get /** * Gets a single object from a multi dimensional array * * @param array java array * @param position */ public static Object get( Object array, int[] position ) throws NotAnArrayException, ArrayDimensionMismatchException { return Array.get( getArray( array, position ), position[ position.length -1] ); } public static int getInt( Object array, int[] position ) throws NotAnArrayException, ArrayDimensionMismatchException { return Array.getInt( getArray( array, position ), position[ position.length -1] ); } public static boolean getBoolean( Object array, int[] position ) throws NotAnArrayException, ArrayDimensionMismatchException { return Array.getBoolean( getArray( array, position ), position[ position.length -1] ); } public static byte getByte( Object array, int[] position ) throws NotAnArrayException, ArrayDimensionMismatchException { return Array.getByte( getArray( array, position ), position[ position.length -1] ); } public static long getLong( Object array, int[] position ) throws NotAnArrayException, ArrayDimensionMismatchException { return Array.getLong( getArray( array, position ), position[ position.length -1] ); } public static short getShort( Object array, int[] position ) throws NotAnArrayException, ArrayDimensionMismatchException { return Array.getShort( getArray( array, position ), position[ position.length -1] ); } public static double getDouble( Object array, int[] position ) throws NotAnArrayException, ArrayDimensionMismatchException { return Array.getDouble( getArray( array, position ), position[ position.length -1] ); } public static char getChar( Object array, int[] position ) throws NotAnArrayException, ArrayDimensionMismatchException { return Array.getChar( getArray( array, position ), position[ position.length -1] ); } public static float getFloat( Object array, int[] position ) throws NotAnArrayException, ArrayDimensionMismatchException { return Array.getFloat( getArray( array, position ), position[ position.length -1] ); } public static Object get( Object array, int position ) throws NotAnArrayException, ArrayDimensionMismatchException { return get( array, new int[]{position} ) ; } public static int getInt( Object array, int position ) throws NotAnArrayException, ArrayDimensionMismatchException { return getInt( array, new int[]{position} ) ; } public static boolean getBoolean( Object array, int position ) throws NotAnArrayException, ArrayDimensionMismatchException { return getBoolean( array, new int[]{position} ) ; } public static byte getByte( Object array, int position ) throws NotAnArrayException, ArrayDimensionMismatchException { return getByte( array, new int[]{position} ) ; } public static long getLong( Object array, int position ) throws NotAnArrayException, ArrayDimensionMismatchException { return getLong( array, new int[]{position} ) ; } public static short getShort( Object array, int position ) throws NotAnArrayException, ArrayDimensionMismatchException { return getShort( array, new int[]{position} ) ; } public static double getDouble( Object array, int position ) throws NotAnArrayException, ArrayDimensionMismatchException { return getDouble( array, new int[]{position} ) ; } public static char getChar( Object array, int position ) throws NotAnArrayException, ArrayDimensionMismatchException { return getChar( array, new int[]{position} ) ; } public static float getFloat( Object array, int position ) throws NotAnArrayException, ArrayDimensionMismatchException { return getFloat( array, new int[]{position} ) ; } private static void checkDimensions(Object array, int[] position) throws NotAnArrayException, ArrayDimensionMismatchException { int poslength = position.length ; int actuallength = getDimensionLength(array); if( poslength > actuallength ){ throw new ArrayDimensionMismatchException( poslength, actuallength ) ; } } // }}} // {{{ set /** * Replaces a single value of the array * * @param array array * @param position index * @param value the new value * * @throws NotAnArrayException if array is not an array * @throws ArrayDimensionMismatchException if the length of position is too big */ public static void set( Object array, int[] position, Object value ) throws NotAnArrayException, ArrayDimensionMismatchException{ Array.set( getArray( array, position ), position[ position.length - 1], value ) ; } /* primitive versions */ public static void set( Object array, int[] position, int value ) throws NotAnArrayException, ArrayDimensionMismatchException{ Array.setInt( getArray( array, position ), position[ position.length - 1], value ) ; } public static void set( Object array, int[] position, boolean value ) throws NotAnArrayException, ArrayDimensionMismatchException{ Array.setBoolean( getArray( array, position ), position[ position.length - 1], value ) ; } public static void set( Object array, int[] position, byte value ) throws NotAnArrayException, ArrayDimensionMismatchException{ Array.setByte( getArray( array, position ), position[ position.length - 1], value ) ; } public static void set( Object array, int[] position, long value ) throws NotAnArrayException, ArrayDimensionMismatchException{ Array.setLong( getArray( array, position ), position[ position.length - 1], value ) ; } public static void set( Object array, int[] position, short value ) throws NotAnArrayException, ArrayDimensionMismatchException{ Array.setShort( getArray( array, position ), position[ position.length - 1], value ) ; } public static void set( Object array, int[] position, double value ) throws NotAnArrayException, ArrayDimensionMismatchException{ Array.setDouble( getArray( array, position ), position[ position.length - 1], value ) ; } public static void set( Object array, int[] position, char value ) throws NotAnArrayException, ArrayDimensionMismatchException{ Array.setChar( getArray( array, position ), position[ position.length - 1], value ) ; } public static void set( Object array, int[] position, float value ) throws NotAnArrayException, ArrayDimensionMismatchException{ Array.setFloat( getArray( array, position ), position[ position.length - 1], value ) ; } public static void set( Object array, int position, Object value ) throws NotAnArrayException, ArrayDimensionMismatchException{ set( array, new int[]{ position }, value ); } public static void set( Object array, int position, int value ) throws NotAnArrayException, ArrayDimensionMismatchException{ set( array, new int[]{ position }, value ); } public static void set( Object array, int position, boolean value ) throws NotAnArrayException, ArrayDimensionMismatchException{ set( array, new int[]{ position }, value ); } public static void set( Object array, int position, byte value ) throws NotAnArrayException, ArrayDimensionMismatchException{ set( array, new int[]{ position }, value ); } public static void set( Object array, int position, long value ) throws NotAnArrayException, ArrayDimensionMismatchException{ set( array, new int[]{ position }, value ); } public static void set( Object array, int position, short value ) throws NotAnArrayException, ArrayDimensionMismatchException{ set( array, new int[]{ position }, value ); } public static void set( Object array, int position, double value ) throws NotAnArrayException, ArrayDimensionMismatchException{ set( array, new int[]{ position }, value ); } public static void set( Object array, int position, char value ) throws NotAnArrayException, ArrayDimensionMismatchException{ set( array, new int[]{ position }, value ); } public static void set( Object array, int position, float value ) throws NotAnArrayException, ArrayDimensionMismatchException{ set( array, new int[]{ position }, value ); } private static Object getArray( Object array, int[] position ) throws NotAnArrayException, ArrayDimensionMismatchException{ checkDimensions( array, position ) ; int poslength = position.length ; Object o = array ; int i=0 ; if( poslength > 1 ){ while( i< (poslength-1) ){ o = Array.get( o, position[i] ) ; i++ ; } } return o ; } // TODO: also have primitive types in value // }}} // {{{ unique // TODO: cannot use LinkedHashSet because it first was introduced in 1.4 // and code in this area needs to work on 1.2 jvm public static Object[] unique( Object[] array ){ int n = array.length ; boolean[] unique = new boolean[ array.length ]; for( int i=0; i> new ArrayWrapper( int[] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(int[]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(int[]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("I") ){ throw new TestException( "ArrayWrapper(int[]).getObjectTypeName() != 'I'" ) ; } System.out.println( " I : ok" ); System.out.print( " >> flat_int()" ) ; int[] flat; try{ flat = wrapper.flat_int() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(int[]) >> FlatException") ; } for( int i=0; i<5; i++){ if( flat[i] != i ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_int_2 private static void flatten_int_2() throws TestException{ int[][] o = RectangularArrayExamples.getIntDoubleRectangularArrayExample(); ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( int[][] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(int[][]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(int[][]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("I") ){ throw new TestException( "ArrayWrapper(int[][]).getObjectTypeName() != 'I'" ) ; } System.out.println( " I : ok" ); System.out.print( " >> flat_int()" ) ; int[] flat; try{ flat = wrapper.flat_int() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(int[][]) >> FlatException") ; } for( int i=0; i<10; i++){ if( flat[i] != i ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_int_3 private static void flatten_int_3() throws TestException{ int[][][] o = RectangularArrayExamples.getIntTripleRectangularArrayExample(); ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( int[][][] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(int[][][]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(int[][][]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("I") ){ throw new TestException( "ArrayWrapper(int[][][]).getObjectTypeName() != 'I'" ) ; } System.out.println( " I : ok" ); System.out.print( " >> flat_int()" ) ; int[] flat; try{ flat = wrapper.flat_int() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(int[][][]) >> FlatException") ; } for( int i=0; i<30; i++){ if( flat[i] != i ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_boolean_1 private static void flatten_boolean_1() throws TestException{ boolean[] o = new boolean[5] ; boolean current = false; for( int i=0;i<5;i++){ o[i] = current ; current = !current ; } ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( boolean[] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(boolean[]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(boolean[]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("Z") ){ throw new TestException( "ArrayWrapper(boolean[]).getObjectTypeName() != 'Z'" ) ; } System.out.println( " Z : ok" ); System.out.print( " >> flat_boolean()" ) ; boolean[] flat; try{ flat = wrapper.flat_boolean() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(int[]) >> FlatException") ; } current = false ; for( int i=0; i<5; i++){ if( flat[i] != current ) throw new TestException( "flat[" + i + "] = " + flat [i] ); current = !current ; } System.out.println( " ok" ) ; } // }}} // {{{ flatten_boolean_2 private static void flatten_boolean_2() throws TestException{ boolean[][] o = RectangularArrayExamples.getBooleanDoubleRectangularArrayExample(); ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( boolean[][] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(boolean[][]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(boolean[][]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("Z") ){ throw new TestException( "ArrayWrapper(boolean[][]).getObjectTypeName() != 'Z'" ) ; } System.out.println( " Z : ok" ); System.out.print( " >> flat_boolean()" ) ; boolean[] flat; try{ flat = wrapper.flat_boolean() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(boolean[][]) >> FlatException") ; } boolean current = false ; for( int i=0; i<10; i++){ if( flat[i] != current ) throw new TestException( "flat[" + i + "] = " + flat [i] ); current = !current ; } System.out.println( " ok" ) ; } // }}} // {{{ flatten_boolean_3 private static void flatten_boolean_3() throws TestException{ boolean[][][] o = RectangularArrayExamples.getBooleanTripleRectangularArrayExample(); ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( boolean[][][] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(boolean[][][]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(boolean[][][]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("Z") ){ throw new TestException( "ArrayWrapper(int[][][]).getObjectTypeName() != 'Z'" ) ; } System.out.println( " Z : ok" ); System.out.print( " >> flat_boolean()" ) ; boolean[] flat; try{ flat = wrapper.flat_boolean() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(boolean[][][]) >> FlatException") ; } boolean current = false ; for( int i=0; i<30; i++){ if( flat[i] != current ) throw new TestException( "flat[" + i + "] = " + flat [i] ); current = !current ; } System.out.println( " ok" ) ; } // }}} // {{{ flatten_byte_1 private static void flatten_byte_1() throws TestException{ byte[] o = new byte[5] ; for( int i=0;i<5;i++) o[i] = (byte)i ; ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( byte[] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(byte[]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(byte[]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("B") ){ throw new TestException( "ArrayWrapper(byte[]).getObjectTypeName() != 'I'" ) ; } System.out.println( " B : ok" ); System.out.print( " >> flat_byte()" ) ; byte[] flat; try{ flat = wrapper.flat_byte() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(byte[]) >> FlatException") ; } for( int i=0; i<5; i++){ if( flat[i] != (byte)i ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_byte_2 private static void flatten_byte_2() throws TestException{ byte[][] o = RectangularArrayExamples.getByteDoubleRectangularArrayExample(); ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( byte[][] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(byte[][]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(byte[][]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("B") ){ throw new TestException( "ArrayWrapper(byte[][]).getObjectTypeName() != 'B'" ) ; } System.out.println( " B : ok" ); System.out.print( " >> flat_byte()" ) ; byte[] flat; try{ flat = wrapper.flat_byte() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(byte[][]) >> FlatException") ; } for( int i=0; i<10; i++){ if( flat[i] != (byte)i ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_byte_3 private static void flatten_byte_3() throws TestException{ byte[][][] o = RectangularArrayExamples.getByteTripleRectangularArrayExample(); ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( byte[][][] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(byte[][][]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(byte[][][]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("B") ){ throw new TestException( "ArrayWrapper(int[][][]).getObjectTypeName() != 'B'" ) ; } System.out.println( " B : ok" ); System.out.print( " >> flat_byte()" ) ; byte[] flat; try{ flat = wrapper.flat_byte() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(byte[][][]) >> FlatException") ; } for( int i=0; i<30; i++){ if( flat[i] != (byte)i ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_long_1 private static void flatten_long_1() throws TestException{ long[] o = new long[5] ; for( int i=0;i<5;i++) o[i] = (long)i ; ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( long[] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(long[]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(long[]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("J") ){ throw new TestException( "ArrayWrapper(long[]).getObjectTypeName() != 'J'" ) ; } System.out.println( " J : ok" ); System.out.print( " >> flat_long()" ) ; long[] flat; try{ flat = wrapper.flat_long() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(long[]) >> FlatException") ; } for( int i=0; i<5; i++){ if( flat[i] != (long)i ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_long_2 private static void flatten_long_2() throws TestException{ long[][] o = RectangularArrayExamples.getLongDoubleRectangularArrayExample(); ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( long[][] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(long[][]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(long[][]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("J") ){ throw new TestException( "ArrayWrapper(long[][]).getObjectTypeName() != 'J'" ) ; } System.out.println( " J : ok" ); System.out.print( " >> flat_long()" ) ; long[] flat; try{ flat = wrapper.flat_long() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(long[][]) >> FlatException") ; } for( int i=0; i<10; i++){ if( flat[i] != (long)i ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_long_3 private static void flatten_long_3() throws TestException{ long[][][] o = RectangularArrayExamples.getLongTripleRectangularArrayExample(); ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( long[][][] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(long[][][]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(long[][][]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("J") ){ throw new TestException( "ArrayWrapper(long[][][]).getObjectTypeName() != 'J'" ) ; } System.out.println( " J : ok" ); System.out.print( " >> flat_long()" ) ; long[] flat; try{ flat = wrapper.flat_long() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(long[][][]) >> FlatException") ; } for( int i=0; i<30; i++){ if( flat[i] != (long)i ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_short_1 private static void flatten_short_1() throws TestException{ short[] o = new short[5] ; for( int i=0;i<5;i++) o[i] = (short)i ; ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( short[] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(short[]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(short[]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("S") ){ throw new TestException( "ArrayWrapper(long[]).getObjectTypeName() != 'S'" ) ; } System.out.println( " S : ok" ); System.out.print( " >> flat_short()" ) ; short[] flat; try{ flat = wrapper.flat_short() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(short[]) >> FlatException") ; } for( int i=0; i<5; i++){ if( flat[i] != (double)i ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_short_2 private static void flatten_short_2() throws TestException{ short[][] o = RectangularArrayExamples.getShortDoubleRectangularArrayExample(); ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( short[][] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(short[][]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(short[][]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("S") ){ throw new TestException( "ArrayWrapper(short[][]).getObjectTypeName() != 'S'" ) ; } System.out.println( " S : ok" ); System.out.print( " >> flat_short()" ) ; short[] flat; try{ flat = wrapper.flat_short() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(short[][]) >> FlatException") ; } for( int i=0; i<10; i++){ if( flat[i] != (double)i ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_short_3 private static void flatten_short_3() throws TestException{ short[][][] o = RectangularArrayExamples.getShortTripleRectangularArrayExample(); ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( short[][][] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(short[][][]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(short[][][]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("S") ){ throw new TestException( "ArrayWrapper(short[][][]).getObjectTypeName() != 'S'" ) ; } System.out.println( " S : ok" ); System.out.print( " >> flat_short()" ) ; short[] flat; try{ flat = wrapper.flat_short() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(short[][][]) >> FlatException") ; } for( int i=0; i<30; i++){ if( flat[i] != (double)i ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_double_1 private static void flatten_double_1() throws TestException{ double[] o = new double[5] ; for( int i=0;i<5;i++) o[i] = i+0.0 ; ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( double[] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(double[]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(double[]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("D") ){ throw new TestException( "ArrayWrapper(double[]).getObjectTypeName() != 'D'" ) ; } System.out.println( " D : ok" ); System.out.print( " >> flat_double()" ) ; double[] flat; try{ flat = wrapper.flat_double() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(double[]) >> FlatException") ; } for( int i=0; i<5; i++){ if( flat[i] != (i+0.0) ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_double_2 private static void flatten_double_2() throws TestException{ double[][] o = RectangularArrayExamples.getDoubleDoubleRectangularArrayExample(); ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( double[][] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(double[][]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(double[][]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("D") ){ throw new TestException( "ArrayWrapper(double[][]).getObjectTypeName() != 'D'" ) ; } System.out.println( " D : ok" ); System.out.print( " >> flat_double()" ) ; double[] flat; try{ flat = wrapper.flat_double() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(double[][]) >> FlatException") ; } for( int i=0; i<10; i++){ if( flat[i] != (i+0.0) ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_double_3 private static void flatten_double_3() throws TestException{ double[][][] o = RectangularArrayExamples.getDoubleTripleRectangularArrayExample(); ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( double[][][] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(double[][][]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(double[][][]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("D") ){ throw new TestException( "ArrayWrapper(double[][][]).getObjectTypeName() != 'D'" ) ; } System.out.println( " D : ok" ); System.out.print( " >> flat_double()" ) ; double[] flat; try{ flat = wrapper.flat_double() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(double[][][]) >> FlatException") ; } for( int i=0; i<30; i++){ if( flat[i] != (i+0.0) ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_char_1 private static void flatten_char_1() throws TestException{ char[] o = new char[5] ; for( int i=0;i<5;i++) o[i] = (char)i ; ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( char[] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(char[]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(char[]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("C") ){ throw new TestException( "ArrayWrapper(char[]).getObjectTypeName() != 'C'" ) ; } System.out.println( " C : ok" ); System.out.print( " >> flat_char()" ) ; char[] flat; try{ flat = wrapper.flat_char() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(char[]) >> FlatException") ; } for( int i=0; i<5; i++){ if( flat[i] != (char)i ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_char_2 private static void flatten_char_2() throws TestException{ char[][] o = RectangularArrayExamples.getCharDoubleRectangularArrayExample(); ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( char[][] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(char[][]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(char[][]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("C") ){ throw new TestException( "ArrayWrapper(char[][]).getObjectTypeName() != 'C'" ) ; } System.out.println( " C : ok" ); System.out.print( " >> flat_char()" ) ; char[] flat; try{ flat = wrapper.flat_char() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(char[][]) >> FlatException") ; } for( int i=0; i<10; i++){ if( flat[i] != (i+0.0) ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_char_3 private static void flatten_char_3() throws TestException{ char[][][] o = RectangularArrayExamples.getCharTripleRectangularArrayExample(); ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( char[][][] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(char[][][]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(char[][][]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("C") ){ throw new TestException( "ArrayWrapper(char[][][]).getObjectTypeName() != 'C'" ) ; } System.out.println( " C : ok" ); System.out.print( " >> flat_char()" ) ; char[] flat; try{ flat = wrapper.flat_char() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(char[][][]) >> FlatException") ; } for( int i=0; i<30; i++){ if( flat[i] != (char)i ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_float_1 private static void flatten_float_1() throws TestException{ float[] o = new float[5] ; for( int i=0;i<5;i++) o[i] = (float)(i+0.0) ; ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( float[] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(float[]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(float[]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("F") ){ throw new TestException( "ArrayWrapper(float[]).getObjectTypeName() != 'F'" ) ; } System.out.println( " F : ok" ); System.out.print( " >> flat_float()" ) ; float[] flat; try{ flat = wrapper.flat_float() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(float[]) >> FlatException") ; } for( int i=0; i<5; i++){ if( flat[i] != (i+0.0) ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_float_2 private static void flatten_float_2() throws TestException{ float[][] o = RectangularArrayExamples.getFloatDoubleRectangularArrayExample(); ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( float[][] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(float[][]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(float[][]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("F") ){ throw new TestException( "ArrayWrapper(float[][]).getObjectTypeName() != 'F'" ) ; } System.out.println( " F : ok" ); System.out.print( " >> flat_float()" ) ; float[] flat; try{ flat = wrapper.flat_float() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(float[][]) >> FlatException") ; } for( int i=0; i<10; i++){ if( flat[i] != (i+0.0) ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_float_3 private static void flatten_float_3() throws TestException{ float[][][] o = RectangularArrayExamples.getFloatTripleRectangularArrayExample(); ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( float[][][] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(float[][][]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(float[][][]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("F") ){ throw new TestException( "ArrayWrapper(float[][][]).getObjectTypeName() != 'F'" ) ; } System.out.println( " F : ok" ); System.out.print( " >> flat_float()" ) ; float[] flat; try{ flat = wrapper.flat_float() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(float[][][]) >> FlatException") ; } for( int i=0; i<30; i++){ if( flat[i] != (float)(i+0.0) ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // }}} // {{{ flat array of String // {{{ flatten_String_1 private static void flatten_String_1() throws TestException{ String[] o = new String[5] ; for( int i=0;i<5;i++) o[i] = ""+i ; ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( String[] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(String[]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(String[]) is primitive" ) ; } System.out.println( " false : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("java.lang.String") ){ throw new TestException( "ArrayWrapper(float[]).getObjectTypeName() != 'java.lang.String'" ) ; } System.out.println( " java.lang.String : ok" ); System.out.print( " >> flat_String()" ) ; String[] flat; try{ flat = wrapper.flat_String() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(String[]) >> FlatException") ; } for( int i=0; i<5; i++){ if( ! flat[i].equals(""+i) ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_String_2 private static void flatten_String_2() throws TestException{ String[][] o = RectangularArrayExamples.getStringDoubleRectangularArrayExample(); ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( String[][] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(String[][]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(String[][]) is primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("java.lang.String") ){ throw new TestException( "ArrayWrapper(float[][]).getObjectTypeName() != 'java.lang.String'" ) ; } System.out.println( " java.lang.String : ok" ); System.out.print( " >> flat_String()" ) ; String[] flat; try{ flat = wrapper.flat_String() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(String[][]) >> FlatException") ; } for( int i=0; i<10; i++){ if( ! flat[i].equals( ""+i) ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_String_3 private static void flatten_String_3() throws TestException{ String[][][] o = RectangularArrayExamples.getStringTripleRectangularArrayExample(); ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( String[][][] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(String[][][]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(String[][][]) is primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("java.lang.String") ){ throw new TestException( "ArrayWrapper(String[][][]).getObjectTypeName() != 'java.lang.String'" ) ; } System.out.println( " java.lang.String : ok" ); System.out.print( " >> flat_String()" ) ; String[] flat; try{ flat = wrapper.flat_String() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(String[][][]) >> FlatException") ; } for( int i=0; i<30; i++){ if( !flat[i].equals( ""+i) ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // }}} // {{{ flat array of Point // {{{ flatten_Point_1 private static void flatten_Point_1() throws TestException{ DummyPoint[] o = new DummyPoint[5] ; for( int i=0;i<5;i++) o[i] = new DummyPoint(i,i) ; ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( DummyPoint[] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(DummyPoint[]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(DummyPoint[]) is primitive" ) ; } System.out.println( " false : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("DummyPoint") ){ throw new TestException( "ArrayWrapper(DummyPoint[]).getObjectTypeName() != 'DummyPoint'" ) ; } System.out.println( " DummyPoint : ok" ); System.out.print( " >> flat_Object()" ) ; DummyPoint[] flat ; try{ flat = (DummyPoint[])wrapper.flat_Object() ; } catch( ObjectArrayException e){ throw new TestException( "ObjectArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(DummyPoint[]) >> FlatException") ; } DummyPoint p ; for( int i=0; i<5; i++){ p = flat[i] ; if( p.x != i || p.y != i) throw new TestException( "flat[" + i + "].x = " + p.x + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_Point_2 private static void flatten_Point_2() throws TestException{ DummyPoint[][] o = RectangularArrayExamples.getDummyPointDoubleRectangularArrayExample(); ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( DummyPoint[][] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(DummyPoint[][]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(DummyPoint[][]) is primitive" ) ; } System.out.println( " false : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("DummyPoint") ){ throw new TestException( "ArrayWrapper(DummyPoint[][]).getObjectTypeName() != 'DummyPoint'" ) ; } System.out.println( " DummyPoint : ok" ); System.out.print( " >> flat_Object()" ) ; DummyPoint[] flat; try{ flat = (DummyPoint[])wrapper.flat_Object() ; } catch( ObjectArrayException e){ throw new TestException( "ObjectArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(DummyPoint[][]) >> FlatException") ; } DummyPoint p; for( int i=0; i<10; i++){ p = flat[i] ; if( p.x != i || p.y != i) throw new TestException( "flat[" + i + "].x = " + p.x + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_Point_3 private static void flatten_Point_3() throws TestException{ DummyPoint[][][] o = RectangularArrayExamples.getDummyPointTripleRectangularArrayExample(); ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( DummyPoint[][][] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(DummyPoint[][][]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(DummyPoint[][][]) is primitive" ) ; } System.out.println( " false : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("DummyPoint") ){ throw new TestException( "ArrayWrapper(DummyPoint[][][]).getObjectTypeName() != 'DummyPoint'" ) ; } System.out.println( " DummyPoint : ok" ); System.out.print( " >> flat_Object()" ) ; DummyPoint[] flat; try{ flat = (DummyPoint[])wrapper.flat_Object() ; } catch( ObjectArrayException e){ throw new TestException( "ObjectArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(Object[][][]) >> FlatException") ; } DummyPoint p; for( int i=0; i<30; i++){ p = flat[i]; if( p.x != i || p.y != i ) throw new TestException( "flat[" + i + "].x = " + p.x + "!=" + i); } System.out.println( " ok" ) ; } // }}} // }}} } rJava/src/java/RJavaTools.class0000644000176200001440000002103412256051764016110 0ustar liggesusers.. _ ^  ^     ^  ^ ^     _ ^ ^     ^ ^  , ^ ^     ^ ^ 5 _ ^ ^       ()VCodeLineNumberTablegetClass7(Ljava/lang/Class;Ljava/lang/String;Z)Ljava/lang/Class;getStaticClasses%(Ljava/lang/Class;)[Ljava/lang/Class;isStatic(Ljava/lang/Class;)ZgetStaticFields-(Ljava/lang/Class;)[Ljava/lang/reflect/Field;getStaticMethods.(Ljava/lang/Class;)[Ljava/lang/reflect/Method; getFieldNames'(Ljava/lang/Class;Z)[Ljava/lang/String;getMethodNamesgetMemberNames1([Ljava/lang/reflect/Member;Z)[Ljava/lang/String;getCompletionName.(Ljava/lang/reflect/Member;)Ljava/lang/String;(Ljava/lang/reflect/Member;)ZhasField'(Ljava/lang/Object;Ljava/lang/String;)ZhasClass classHasField'(Ljava/lang/Class;Ljava/lang/String;Z)ZclassHasMethod classHasClass hasMethod newInstanceJ(Ljava/lang/Class;[Ljava/lang/Object;[Ljava/lang/Class;)Ljava/lang/Object; Exceptions arg_is_null([Ljava/lang/Object;)[Z invokeMethodn(Ljava/lang/Class;Ljava/lang/Object;Ljava/lang/String;[Ljava/lang/Object;[Ljava/lang/Class;)Ljava/lang/Object;getConstructorF(Ljava/lang/Class;[Ljava/lang/Class;[Z)Ljava/lang/reflect/Constructor; isPrimitive getMethodS(Ljava/lang/Class;Ljava/lang/String;[Ljava/lang/Class;[Z)Ljava/lang/reflect/Method;isMoreSpecific7(Ljava/lang/reflect/Method;Ljava/lang/reflect/Method;)ZA(Ljava/lang/reflect/Constructor;Ljava/lang/reflect/Constructor;)Z'([Ljava/lang/Class;[Ljava/lang/Class;)Z getClasses&(Ljava/lang/Object;)[Ljava/lang/Class; getClassNames'(Ljava/lang/Object;)[Ljava/lang/String;getSimpleClassNames((Ljava/lang/Object;Z)[Ljava/lang/String;getSimpleClassName&(Ljava/lang/Object;)Ljava/lang/String; getSimpleName&(Ljava/lang/String;)Ljava/lang/String;getFieldTypeName7(Ljava/lang/Class;Ljava/lang/String;)Ljava/lang/String; SourceFileRJavaTools.java `a hijava/util/Vector java/lang/Class  hujava/lang/reflect/Field java/lang/reflect/Method qrjava/lang/String st )java/lang/StringBuffer (  d yz |z {z      ~+java/lang/reflect/InvocationTargetException  [Ljava/lang/Class; java/lang/NoSuchMethodException  i i ,No constructor matching the given parameters `  ! " +No suitable method for the given parameters #  Exceptionerror condition $% &' ()intdoublebooleanbytelongfloatshortchar (*[] +, - java/lang/NoSuchFieldException RJavaToolsjava/lang/Objectjava/lang/Throwablejava/lang/SecurityException()[Ljava/lang/Class;getName()Ljava/lang/String;equals(Ljava/lang/Object;)Zaddsize()ItoArray(([Ljava/lang/Object;)[Ljava/lang/Object; getModifiers getFields()[Ljava/lang/reflect/Field; getMethods()[Ljava/lang/reflect/Method;java/lang/reflect/MembergetParameterTypesappend,(Ljava/lang/String;)Ljava/lang/StringBuffer;toString()Ljava/lang/Class;java/lang/reflect/Constructor isAccessible()Z setAccessible(Z)V'([Ljava/lang/Object;)Ljava/lang/Object;getTargetException()Ljava/lang/Throwable;invoke9(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;3([Ljava/lang/Class;)Ljava/lang/reflect/Constructor;getConstructors"()[Ljava/lang/reflect/Constructor;isAssignableFrom(Ljava/lang/String;)Vjava/lang/BooleanTYPELjava/lang/Class;java/lang/Integerjava/lang/Doublejava/lang/Floatjava/lang/Longjava/lang/Shortjava/lang/Character@(Ljava/lang/String;[Ljava/lang/Class;)Ljava/lang/reflect/Method; getSuperclass lastIndexOf(I)IcharAt(I)C substring(II)Ljava/lang/String;(I)Ljava/lang/String;getField-(Ljava/lang/String;)Ljava/lang/reflect/Field;getType!^_ `ab*c$ debg;*N6---2+ -2-2c./0.13/94 fgbV*L+YM+>6+2: , W, , :, Wc:?@ BCDE%F-G4D:JAKCMLNSO hib(* ~cY jkbW*L+YM+>6+2: , W, , :, Wc>cd e ghi j&k.l5i;oBpDrMsTt lmbW*LYM++>6+2: , W, , :, Wc>~  &.5;BDMT nob! *c pob! *c qrbM*>TY:6"*2: W  M, W"M6,*2S,cV $*2=CKPY`chq| stbpH* **3*LY*+c(E hub**~c vwb" * +!c xwb" * +"c yzbd8*N6-*+-2#-2$~c.06 {zbd8*N6-*+-2%-2&~c#$%.&0$6' |zbd8*N6-*+-2 -2c678.9076: }wb" * +'cH ~b c+N6+-+2T*,-(:)6*++:*:-:*:BL,:BTLVTc:STUT%X-[4\:`BeIfLaNcTe`gbU)**L=*+*2T+ckl mn!m'p b D*,-./:061+-2:1:-: 1 #-,#5-75c* z }~#*-/5A bv *N++*34N-*+4N--:N*6:62:7:+b+66 6  <, 3+ 28%6 %+ 2 2+ 29 6  - -:N}- 5Y;<-'+5c#"&(+-/5@GNVY]`jq{~5ibdL*=>?*?>5*@>+*A>!*B>*C> *D>c b *,, *+3E*+,E:::*:62:%+w:,e,6 6 6   <- 3, 28%6 %, 2 2, 29 6   F:k 5YG<(,5c#!&),.17BIUX_gjnq{   5 b0*M+N,-Hc)* + b0*7M+7N,-Hc89 : bN*=>69*2+2(*2+29 +2+29c* KLMNO'P-Q;R>MDT bc/YL* M,+, W,IM+ N+- W-c"]^ _`ac'd-e bf2YL* M,+, W,IM+ N+- W-c"no pqr"t*u0v bl=YN* :*:J=- WI: -J W-K W-L W- :- WcF )+2<@DKRYbi b# * c b*[M<**[M`NL**[M`*;MOKf*N=I PKTD QKHZ RK<B SK0J TK$F UKS VK CWK*$M= *`XK*.M> *`XK*Y*Y:6ZW*c" 28>DJPV\bhntz bJM*+[\MNM,]crJava/src/java/RectangularArrayBuilder_Test.java0000644000176200001440000005766112256051760021467 0ustar liggesusers// :tabSize=2:indentSize=2:noTabs=false:folding=explicit:collapseFolds=1: /** * Test suite for RectangularArrayBuilder */ public class RectangularArrayBuilder_Test { private static int[] dim1d = {10} ; private static int[] dim2d = {5,2} ; private static int[] dim3d = {5,3,2} ; // {{{ main public static void main(String[] args ){ try{ runtests() ; } catch( TestException e){ e.printStackTrace(); System.exit(1); } System.out.println( "\nALL PASSED\n" ) ; System.exit( 0 ); } // }}} // {{{ runtests public static void runtests() throws TestException { // {{{ 1d System.out.println( " >> 1 d" ); System.out.print( "fill int[]" ); fill_int_1(); System.out.println( " : ok" ); System.out.print( "fill boolean[]" ); fill_boolean_1(); System.out.println( " : ok" ); System.out.print( "fill byte[]" ); fill_byte_1(); System.out.println( " : ok" ); System.out.print( "fill long[]" ); fill_long_1(); System.out.println( " : ok" ); System.out.print( "fill short[]" ); fill_short_1(); System.out.println( " : ok" ); System.out.print( "fill double[]" ); fill_double_1(); System.out.println( " : ok" ); System.out.print( "fill char[]" ); fill_char_1(); System.out.println( " : ok" ); System.out.print( "fill float[]" ); fill_float_1(); System.out.println( " : ok" ); System.out.print( "fill String[]" ); fill_String_1(); System.out.println( " : ok" ); System.out.print( "fill Point[]" ); fill_Point_1(); System.out.println( " : ok" ); // }}} // {{{ 2d System.out.println( " >> 2 d" ); System.out.print( "fill int[][]" ); fill_int_2(); System.out.println( " : ok" ); System.out.print( "fill boolean[][]" ); fill_boolean_2(); System.out.println( " : ok" ); System.out.print( "fill byte[][]" ); fill_byte_2(); System.out.println( " : ok" ); System.out.print( "fill long[][]" ); fill_long_2(); System.out.println( " : ok" ); System.out.print( "fill short[][]" ); fill_short_2(); System.out.println( " : ok" ); System.out.print( "fill double[][]" ); fill_double_2(); System.out.println( " : ok" ); System.out.print( "fill char[][]" ); fill_char_2(); System.out.println( " : ok" ); System.out.print( "fill float[][]" ); fill_float_2(); System.out.println( " : ok" ); System.out.print( "fill String[][]" ); fill_String_2(); System.out.println( " : ok" ); System.out.print( "fill Point[][]" ); fill_Point_2(); System.out.println( " : ok" ); // }}} // {{{ 3d System.out.println( " >> 3 d" ); System.out.print( "fill int[][][]" ); fill_int_3(); System.out.println( " : ok" ); System.out.print( "fill boolean[][][]" ); fill_boolean_3(); System.out.println( " : ok" ); System.out.print( "fill byte[][][]" ); fill_byte_3(); System.out.println( " : ok" ); System.out.print( "fill long[][][]" ); fill_long_3(); System.out.println( " : ok" ); System.out.print( "fill short[][][]" ); fill_short_3(); System.out.println( " : ok" ); System.out.print( "fill double[][][]" ); fill_double_3(); System.out.println( " : ok" ); System.out.print( "fill char[][][]" ); fill_char_3(); System.out.println( " : ok" ); System.out.print( "fill float[][][]" ); fill_float_3(); System.out.println( " : ok" ); System.out.print( "fill String[][][]" ); fill_String_3(); System.out.println( " : ok" ); System.out.print( "fill Point[][][]" ); fill_Point_3(); System.out.println( " : ok" ); // }}} } //}}} // {{{ 1d private static void fill_int_1() throws TestException{ RectangularArrayBuilder builder = null; try{ builder = new RectangularArrayBuilder( ints(10), dim1d ); } catch( NotAnArrayException e){ throw new TestException( "not an array int[10]" ) ; } catch( ArrayDimensionException e){ throw new TestException( "array dimensionexception" ) ; } int[] data = (int[])builder.getArray(); int current = 0; for( int i=0; i(Ljava/lang/String;)VCodeLineNumberTable SourceFileTestException.java  TestExceptionjava/lang/Exception!*+ rJava/src/java/RJavaClassLoader$UnixFile.class0000644000176200001440000000127312256051764020717 0ustar liggesusers.'       lastModStampJthis$0LRJavaClassLoader; Synthetic'(LRJavaClassLoader;Ljava/lang/String;)VCodeLineNumberTable hasChanged()Zupdate()V SourceFileRJavaClassLoader.java! "# $  %&RJavaClassLoader$UnixFileUnixFile InnerClasses java/io/FileRJavaClassLoaderu2w&(Ljava/lang/String;)Ljava/lang/String;(Ljava/lang/String;)V lastModified()J     7*,*+* ML NO0*@* UV% ** ]^ rJava/src/java/ArrayWrapper_Test.class0000644000176200001440000006360412256051764017513 0ustar liggesusers. @i ?jk l mn mop qrs ?tuv ?wx ?yz ?{| ?}~ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? q H  H H   H ^i ^ ^ ^   H ^   H      H  ^   !" H#$ %&'()* +,-./01234567 H89 ^: ;<=>?@ ABCDEFGHIJKLM HNO ^P QRSTUV WXYZ[\]^_`abc Hde ^f ghijkl mnopqrstuvwxyz{| H}~   " H " "  ()VCodeLineNumberTablemain([Ljava/lang/String;)Vruntests Exceptions flatten_int_1 flatten_int_2 flatten_int_3flatten_boolean_1flatten_boolean_2flatten_boolean_3flatten_byte_1flatten_byte_2flatten_byte_3flatten_long_1flatten_long_2flatten_long_3flatten_short_1flatten_short_2flatten_short_3flatten_double_1flatten_double_2flatten_double_3flatten_char_1flatten_char_2flatten_char_3flatten_float_1flatten_float_2flatten_float_3flatten_String_1flatten_String_2flatten_String_3flatten_Point_1flatten_Point_2flatten_Point_3 SourceFileArrayWrapper_Test.java AB GB TestException B   ALL PASSED   flatten int[] IBPASSEDflatten int[][] JBflatten int[][][] KBflatten boolean[] LBflatten boolean[][] MBflatten boolean[][][] NBflatten byte[] OBflatten byte[][] PBflatten byte[][][] QBflatten long[] RBflatten long[][] SBflatten long[][][] TBflatten short[] UBflatten short[][] VBflatten short[][][] WBflatten double[] XBflatten double[][] YBflatten double[][][] ZBflatten char[] [Bflatten char[][] \Bflatten char[][][] ]Bflatten float[] ^Bflatten float[][] _Bflatten float[][][] `Bflatten String[] aBflatten String[][] bBflatten String[][][] cBflatten Point[] dBflatten Point[][] eBflatten Point[][][] fB >> new ArrayWrapper( int[] )  ArrayWrapper ANotAnArrayException/new ArrayWrapper(int[]) >> NotAnArrayException Aok >> isPrimitive() !ArrayWrapper(int[]) not primitive true : ok >> getObjectTypeName() I .ArrayWrapper(int[]).getObjectTypeName() != 'I' I : ok >> flat_int() PrimitiveArrayException FlatException(new ArrayWrapper(int[]) >> FlatExceptionjava/lang/StringBufferflat[  ] = !=  ok ! >> new ArrayWrapper( int[][] ) 1new ArrayWrapper(int[][]) >> NotAnArrayException #ArrayWrapper(int[][]) not primitive0ArrayWrapper(int[][]).getObjectTypeName() != 'I'*new ArrayWrapper(int[][]) >> FlatException # >> new ArrayWrapper( int[][][] ) 3new ArrayWrapper(int[][][]) >> NotAnArrayException %ArrayWrapper(int[][][]) not primitive2ArrayWrapper(int[][][]).getObjectTypeName() != 'I',new ArrayWrapper(int[][][]) >> FlatException# >> new ArrayWrapper( boolean[] ) 3new ArrayWrapper(boolean[]) >> NotAnArrayException %ArrayWrapper(boolean[]) not primitiveZ2ArrayWrapper(boolean[]).getObjectTypeName() != 'Z' Z : ok >> flat_boolean()   % >> new ArrayWrapper( boolean[][] ) 5new ArrayWrapper(boolean[][]) >> NotAnArrayException 'ArrayWrapper(boolean[][]) not primitive4ArrayWrapper(boolean[][]).getObjectTypeName() != 'Z'.new ArrayWrapper(boolean[][]) >> FlatException ' >> new ArrayWrapper( boolean[][][] ) 7new ArrayWrapper(boolean[][][]) >> NotAnArrayException )ArrayWrapper(boolean[][][]) not primitive2ArrayWrapper(int[][][]).getObjectTypeName() != 'Z'0new ArrayWrapper(boolean[][][]) >> FlatException >> new ArrayWrapper( byte[] ) 0new ArrayWrapper(byte[]) >> NotAnArrayException "ArrayWrapper(byte[]) not primitiveB/ArrayWrapper(byte[]).getObjectTypeName() != 'I' B : ok >> flat_byte() )new ArrayWrapper(byte[]) >> FlatException " >> new ArrayWrapper( byte[][] ) 2new ArrayWrapper(byte[][]) >> NotAnArrayException $ArrayWrapper(byte[][]) not primitive1ArrayWrapper(byte[][]).getObjectTypeName() != 'B'+new ArrayWrapper(byte[][]) >> FlatException $ >> new ArrayWrapper( byte[][][] ) 4new ArrayWrapper(byte[][][]) >> NotAnArrayException &ArrayWrapper(byte[][][]) not primitive2ArrayWrapper(int[][][]).getObjectTypeName() != 'B'-new ArrayWrapper(byte[][][]) >> FlatException >> new ArrayWrapper( long[] ) 0new ArrayWrapper(long[]) >> NotAnArrayException "ArrayWrapper(long[]) not primitiveJ/ArrayWrapper(long[]).getObjectTypeName() != 'J' J : ok >> flat_long() )new ArrayWrapper(long[]) >> FlatException  " >> new ArrayWrapper( long[][] ) 2new ArrayWrapper(long[][]) >> NotAnArrayException $ArrayWrapper(long[][]) not primitive1ArrayWrapper(long[][]).getObjectTypeName() != 'J'+new ArrayWrapper(long[][]) >> FlatException $ >> new ArrayWrapper( long[][][] ) 4new ArrayWrapper(long[][][]) >> NotAnArrayException &ArrayWrapper(long[][][]) not primitive3ArrayWrapper(long[][][]).getObjectTypeName() != 'J'-new ArrayWrapper(long[][][]) >> FlatException! >> new ArrayWrapper( short[] ) 1new ArrayWrapper(short[]) >> NotAnArrayException #ArrayWrapper(short[]) not primitiveS/ArrayWrapper(long[]).getObjectTypeName() != 'S' S : ok >> flat_short() *new ArrayWrapper(short[]) >> FlatException # >> new ArrayWrapper( short[][] ) 3new ArrayWrapper(short[][]) >> NotAnArrayException %ArrayWrapper(short[][]) not primitive2ArrayWrapper(short[][]).getObjectTypeName() != 'S',new ArrayWrapper(short[][]) >> FlatException % >> new ArrayWrapper( short[][][] ) 5new ArrayWrapper(short[][][]) >> NotAnArrayException 'ArrayWrapper(short[][][]) not primitive4ArrayWrapper(short[][][]).getObjectTypeName() != 'S'.new ArrayWrapper(short[][][]) >> FlatException" >> new ArrayWrapper( double[] ) 2new ArrayWrapper(double[]) >> NotAnArrayException $ArrayWrapper(double[]) not primitiveD1ArrayWrapper(double[]).getObjectTypeName() != 'D' D : ok >> flat_double() +new ArrayWrapper(double[]) >> FlatException  $ >> new ArrayWrapper( double[][] ) 4new ArrayWrapper(double[][]) >> NotAnArrayException &ArrayWrapper(double[][]) not primitive3ArrayWrapper(double[][]).getObjectTypeName() != 'D'-new ArrayWrapper(double[][]) >> FlatException & >> new ArrayWrapper( double[][][] ) 6new ArrayWrapper(double[][][]) >> NotAnArrayException (ArrayWrapper(double[][][]) not primitive5ArrayWrapper(double[][][]).getObjectTypeName() != 'D'/new ArrayWrapper(double[][][]) >> FlatException >> new ArrayWrapper( char[] ) 0new ArrayWrapper(char[]) >> NotAnArrayException "ArrayWrapper(char[]) not primitiveC/ArrayWrapper(char[]).getObjectTypeName() != 'C' C : ok >> flat_char() )new ArrayWrapper(char[]) >> FlatException  " >> new ArrayWrapper( char[][] ) 2new ArrayWrapper(char[][]) >> NotAnArrayException $ArrayWrapper(char[][]) not primitive1ArrayWrapper(char[][]).getObjectTypeName() != 'C'+new ArrayWrapper(char[][]) >> FlatException $ >> new ArrayWrapper( char[][][] ) 4new ArrayWrapper(char[][][]) >> NotAnArrayException &ArrayWrapper(char[][][]) not primitive3ArrayWrapper(char[][][]).getObjectTypeName() != 'C'-new ArrayWrapper(char[][][]) >> FlatException! >> new ArrayWrapper( float[] ) 1new ArrayWrapper(float[]) >> NotAnArrayException #ArrayWrapper(float[]) not primitiveF0ArrayWrapper(float[]).getObjectTypeName() != 'F' F : ok >> flat_float() *new ArrayWrapper(float[]) >> FlatException  # >> new ArrayWrapper( float[][] ) 3new ArrayWrapper(float[][]) >> NotAnArrayException %ArrayWrapper(float[][]) not primitive2ArrayWrapper(float[][]).getObjectTypeName() != 'F',new ArrayWrapper(float[][]) >> FlatException % >> new ArrayWrapper( float[][][] ) 5new ArrayWrapper(float[][][]) >> NotAnArrayException 'ArrayWrapper(float[][][]) not primitive4ArrayWrapper(float[][][]).getObjectTypeName() != 'F'.new ArrayWrapper(float[][][]) >> FlatExceptionjava/lang/String" >> new ArrayWrapper( String[] ) 2new ArrayWrapper(String[]) >> NotAnArrayException #ArrayWrapper(String[]) is primitive false : okjava.lang.String?ArrayWrapper(float[]).getObjectTypeName() != 'java.lang.String' java.lang.String : ok >> flat_String() +new ArrayWrapper(String[]) >> FlatException $ >> new ArrayWrapper( String[][] ) 4new ArrayWrapper(String[][]) >> NotAnArrayException %ArrayWrapper(String[][]) is primitiveAArrayWrapper(float[][]).getObjectTypeName() != 'java.lang.String'-new ArrayWrapper(String[][]) >> FlatException & >> new ArrayWrapper( String[][][] ) 6new ArrayWrapper(String[][][]) >> NotAnArrayException 'ArrayWrapper(String[][][]) is primitiveDArrayWrapper(String[][][]).getObjectTypeName() != 'java.lang.String'/new ArrayWrapper(String[][][]) >> FlatException DummyPoint A& >> new ArrayWrapper( DummyPoint[] ) 6new ArrayWrapper(DummyPoint[]) >> NotAnArrayException 'ArrayWrapper(DummyPoint[]) is primitive>ArrayWrapper(DummyPoint[]).getObjectTypeName() != 'DummyPoint' DummyPoint : ok >> flat_Object()  [LDummyPoint;ObjectArrayException/new ArrayWrapper(DummyPoint[]) >> FlatException  ].x = ( >> new ArrayWrapper( DummyPoint[][] ) 8new ArrayWrapper(DummyPoint[][]) >> NotAnArrayException )ArrayWrapper(DummyPoint[][]) is primitive@ArrayWrapper(DummyPoint[][]).getObjectTypeName() != 'DummyPoint'1new ArrayWrapper(DummyPoint[][]) >> FlatException * >> new ArrayWrapper( DummyPoint[][][] ) :new ArrayWrapper(DummyPoint[][][]) >> NotAnArrayException +ArrayWrapper(DummyPoint[][][]) is primitiveBArrayWrapper(DummyPoint[][][]).getObjectTypeName() != 'DummyPoint'/new ArrayWrapper(Object[][][]) >> FlatExceptionArrayWrapper_Testjava/lang/ObjectprintStackTracejava/lang/Systemexit(I)VoutLjava/io/PrintStream;java/io/PrintStreamprintln(Ljava/lang/String;)Vprint(Ljava/lang/Object;)V isPrimitive()ZgetObjectTypeName()Ljava/lang/String;equals(Ljava/lang/Object;)Zflat_int()[Iappend,(Ljava/lang/String;)Ljava/lang/StringBuffer;(I)Ljava/lang/StringBuffer;toStringRectangularArrayExamples#getIntDoubleRectangularArrayExample()[[I#getIntTripleRectangularArrayExample()[[[I flat_boolean()[Z(Z)Ljava/lang/StringBuffer;'getBooleanDoubleRectangularArrayExample()[[Z'getBooleanTripleRectangularArrayExample()[[[Z flat_byte()[B$getByteDoubleRectangularArrayExample()[[B$getByteTripleRectangularArrayExample()[[[B flat_long()[J(J)Ljava/lang/StringBuffer;$getLongDoubleRectangularArrayExample()[[J$getLongTripleRectangularArrayExample()[[[J flat_short()[S%getShortDoubleRectangularArrayExample()[[S%getShortTripleRectangularArrayExample()[[[S flat_double()[D(D)Ljava/lang/StringBuffer;&getDoubleDoubleRectangularArrayExample()[[D&getDoubleTripleRectangularArrayExample()[[[D flat_char()[C(C)Ljava/lang/StringBuffer;$getCharDoubleRectangularArrayExample()[[C$getCharTripleRectangularArrayExample()[[[C flat_float()[F(F)Ljava/lang/StringBuffer;%getFloatDoubleRectangularArrayExample()[[F%getFloatTripleRectangularArrayExample()[[[F flat_String()[Ljava/lang/String;&getStringDoubleRectangularArrayExample()[[Ljava/lang/String;&getStringTripleRectangularArrayExample()[[[Ljava/lang/String;(II)V flat_Object()[Ljava/lang/Object;xy*getDummyPointDoubleRectangularArrayExample()[[LDummyPoint;*getDummyPointTripleRectangularArrayExample()[[[LDummyPoint;!?@!ABC*D EFCX L+D"    GBC;                ! "# $% &' () *+ ,- ./ 01 23 45 67 89 :; <= >? @A BC DE Dn[  !&#.$1%9)A*D+L-T.W/_1g2j3r7z8}9;<=?@AEFGIJKMNOSTUWXY [\]a%b(c0e8f;gCiKjNkVo^paqisqttu|wxy}~  '/2:H IBC K< *OLFGHY*ILMYKLMNG+O YPLQRG+STU YVLWXG+YMNY[LNY]L>?,.2Y^Y_`abca,.bdabeL²f(+JZ\Dv(+,6>FMW_gs}H JBCgKLhGHY*ILMYiLMNG+O YjLQRG+STU YkLWXG+YMNY[LNYlL> ?,.2Y^Y_`abca,.bdabeLfJ|Z|\Dr%-5<FNVblt|H KBCmKLnGHY*ILMYoLMNG+O YpLQRG+STU YqLWXG+YMNY[LNYrL>?,.2Y^Y_`abca,.bdabeLfJ|Z|\Dr  %-5<FNVbl t"|%*&'(),-,/1H LBC K<=*T<MsGHY*IMNYtLMNG,O YuLQRG,SvU YwLxyG,zN:Y[L:Y]L<6C-3+Y^Y_`abca-3{eL<f+47JZ\D#:;< =><!A#B+D4G7E8FBHJJRKYLcNkPsQRTVY^Z[\]`abcae gH MBC|KL}GHY*ILMY~LMNG+O YLQRG+SvU YLxyG+zMNY[LNYL>6 C,3+Y^Y_`abca,3{eL>fJ|Z|\Dzmoprust%v-x5y<zF|N~Vblt|H NBCKLGHY*ILMYLMNG+O YLQRG+SvU YLxyG+zMNY[LNYL>6C,3+Y^Y_`abca,3{eL>fJ|Z|\Dz%-5<FNVblt|H OBCK<*TLGHY*ILMYLMNG+O YLQRG+SU YLG+MNY[LNYL>@,32Y^Y_`abca,3bdabeLf ),JZ\Dv ),-7?GNX`ht~H PBCKLGHY*ILMYLMNG+O YLQRG+SU YLG+MNY[LNYL> @,32Y^Y_`abca,3bdabeLfJ|Z|\Dr%-5<F N V b lt|!H QBCKLGHY*ILMYLMNG+O YLQRG+SU YLG+MNY[LNYL>@,32Y^Y_`abca,3bdabeLfJ|Z|\Dr')*,/-.%0-253<4F6N8V9b:l<t>|AFBCDEIJILNH RBC K<*PLGHY*ILMYLMNG+O YLQRG+SU YLG+MNY[LNYL>A,/2Y^Y_`abca,/dabeLf ),JZ\DvUVXY [)^,\-]7_?aGbNcXe`ghhti~kmpuqrstwxwz|H SBCKLGHY*ILMYLMNG+O YLQRG+SU YLG+MNY[LNYL> A,/2Y^Y_`abca,/dabeLfJ|Z|\Dr%-5<FNVblt|H TBCKLGHY*ILMYLMNG+O YLQRG+SU YLG+MNY[LNYL>A,/2Y^Y_`abca,/dabeLfJ|Z|\Dr%-5<FNVblt|H UBC K<*VLGHY*ILMYLMNG+O YLQRG+SU YLG+MNY[LNYL>B,52Y^Y_`abca,5bdabeLf ),JZ\Dv ),-7?GNX`ht~H VBCKLGHY*ILMYLMNG+O YLQRG+SU YLG+MNY[LNYL> B,52Y^Y_`abca,5bdabeLfJ|Z|\Dr %-5<FNVb l"t$|',()*+/0/24H WBCKLöGHY*ILMYķLMNG+O YŷLQRG+SU YƷLG+MNY[LNYǷL>B,52Y^Y_`abca,5bdabeLfJ|Z|\Dr:<=?B@A%C-E5F<GFINKVLbMlOtQ|TYUVWX\]\_aH XBCK<*cRLȶGHY*ILMYɷLMNG+O YʷLQRG+S˶U Y̷LͶζG+MNY[LNYзL>C,1c2Y^Y_`abca,1dabeLf"+.JZ\Dvijlm"o+r.p/q9sAuIvPwZyb{j|v}H YBCKLӶGHY*ILMYԷLMNG+O YշLQRG+S˶U YַLͶζG+MNY[LNY׷L> C,1c2Y^Y_`abca,1dabeLfJ|Z|\Dr%-5<FNVblt|H ZBCKLٶGHY*ILMYڷLMNG+O Y۷LQRG+S˶U YܷLͶζG+MNY[LNYݷL>C,1c2Y^Y_`abca,1dabeLfJ|Z|\Dr%-5<FNVblt|H [BCK<*UL޶GHY*ILMY߷LMNG+O YLQRG+SU YLG+MNY[LNYL>@,42Y^Y_`abca,4dabeLf ),JZ\Dv ),-7?GNX`ht~   H \BCKLGHY*ILMYLMNG+O YLQRG+SU YLG+MNY[LNYL> D,4c2Y^Y_`abca,4dabeLfJ|Z|\Dr!"$'%&%(-*5+<,F.N0V1b2l4t6|9>:;<=ABADFH ]BCKLGHY*ILMYLMNG+O YLQRG+SU YLG+MNY[LNYL>@,42Y^Y_`abca,4dabeLfJ|Z|\DrLNOQTRS%U-W5X<YF[N]V^b_latc|fkghijnonqsH ^BCK<*cQLGHY*ILMYLMNG+O YLQRG+SU YLG+MNY[LNYL>D,0c2Y^Y_`abca,0dabeLf#,/JZ\Dv{|~#,/0:BJQ[ckwH _BCKLGHY*ILMYLMNG+OYLQRG+SUYLG+MNY[LNYL> D,0c2Y^Y_`abca,0dabeLfJZ\Dr&.6=HPXdowH `BCKLGHY*ILMYLMNG+OYLQRG+SUYLG+MNY[LNY L>D,0c2Y^Y_`abca,0dabeLfJZ\Dr'/7>IQYepxH aBC* K< *^Y_ abeSL GHY*ILMY LMNG+OYLRG+SUYLG+MNY[LNYL>U,2^Y_ abeU2Y^Y_`abca,2adabeLf4=@JZ\Dv) + 4 =@ ALT\cnw!&"#$%()(!+)-H bBCKLGHY*ILMYLMNG+OYLQRG+SUYLG+MNY[LNYL> U,2^Y_ abeU2Y^Y_`abca,2adabeLfJZ\Dr3568;9:'</>7?>@IBQDYEfFqHzJMRNOPQUVUXZH cBCKLGHY*ILMYLMNG+OYLQRG+SUY LG+MNY[LNY!L>U,2^Y_ abeU2Y^Y_`abca,2adabeLfJZ\Dr`bcehfg'i/k7l>mIoQqYrfsquzwz{|}~H dBC&"K<*"Y#SL$GHY*ILMY%LMNG+OY&LRG+S'UY(L)*G++,,MNY.LNY/L6S,2N-0 -16Y^Y_`ab2a-0bdabeLf)25J-\Dz )256AIQXclt%H eBC 3KL4GHY*ILMY5LMNG+OY6LRG+S'UY7L)*G++,,MNY.LNY8L6 S,2N-0 -16Y^Y_`ab2a-0bdabeLfJ-\Dv'/7>IRZgr{ H fBC 9KL:GHY*ILMY;LMNG+OY<LRG+S'UY=L)*G++,,MNY.LNY>L6S,2N-0 -16Y^Y_`ab2a-0bdabeLfJ-\Dv'/7>IRZgr{    HghrJava/src/java/RJavaTools_Test$DummyNonStaticClass.class0000644000176200001440000000060712256051764023003 0ustar liggesusers.  this$0LRJavaTools_Test; Synthetic(LRJavaTools_Test;)VCodeLineNumberTable SourceFileRJavaTools_Test.java  #RJavaTools_Test$DummyNonStaticClassDummyNonStaticClass InnerClassesjava/lang/Object()VRJavaTools_Test!  " **+    rJava/src/java/RJavaClassLoader$UnixJarFile.class0000644000176200001440000000366312256051764021361 0ustar liggesusers.p 4 5 6 78 9: ; < ; = > ?@ ABC DE F G H IJ KL M HNOPQ RSVzfileLjava/util/zip/ZipFile; urlPrefixLjava/lang/String;this$0LRJavaClassLoader; Synthetic'(LRJavaClassLoader;Ljava/lang/String;)VCodeLineNumberTableupdate()VgetResourceAsStream)(Ljava/lang/String;)Ljava/io/InputStream; getResource"(Ljava/lang/String;)Ljava/net/URL; SourceFileRJavaClassLoader.java () %& !" X-java/util/zip/ZipFile (Yjava/lang/Exception ,- Z[ \] ^_` abc dejava/lang/StringBuffer (-)RJavaClassLoader$UnixJarFile: exception: fg hi jik lm #$jar: no!java/net/MalformedURLExceptionjava/io/IOException java/net/URL (mRJavaClassLoader$UnixJarFile UnixJarFile InnerClassesRJavaClassLoader$UnixFileUnixFileclose(Ljava/io/File;)V hasChanged()ZgetEntry,(Ljava/lang/String;)Ljava/util/zip/ZipEntry;getInputStream/(Ljava/util/zip/ZipEntry;)Ljava/io/InputStream;RJavaClassLoaderverboseZjava/lang/SystemerrLjava/io/PrintStream;append,(Ljava/lang/String;)Ljava/lang/StringBuffer; getMessage()Ljava/lang/String;toStringjava/io/PrintStreamprintln(Ljava/lang/String;)VtoURL()Ljava/net/URL;  !"#$%&'()*, *+,*++sr t,-*W#* **Y*L*+yz|}"./*Y* * * **+ M, *, &M Y,404+* $(145W01*j**+ M*-*Y*NNYY*+MN,?B?FGdg+6 ?BCFGdgh23U?T ?WrJava/src/java/RJavaArrayTools_Test.java0000644000176200001440000012401312256051760017717 0ustar liggesusers// :tabSize=2:indentSize=2:noTabs=false:folding=explicit:collapseFolds=1: public class RJavaArrayTools_Test { // {{{ main public static void main(String[] args){ System.out.println( "Test suite for RJavaArrayTools" ) ; try{ runtests() ; } catch( TestException e){ fails( e ) ; System.exit(1); } System.exit(0); } // }}} // {{{ runtests public static void runtests() throws TestException { System.out.println( "Test suite for RJavaArrayTools" ) ; System.out.println( "Testing RJavaArrayTools.isArray" ) ; isarray(); success() ; System.out.println( "Testing RJavaArrayTools.isRectangularArray" ) ; isrect(); success() ; System.out.println( "Testing RJavaArrayTools.getDimensionLength" ) ; getdimlength(); success() ; System.out.println( "Testing RJavaArrayTools.getDimensions" ) ; getdims(); success() ; System.out.println( "Testing RJavaArrayTools.getTrueLength" ) ; gettruelength(); success() ; System.out.println( "Testing RJavaArrayTools.getObjectTypeName" ) ; gettypename(); success() ; System.out.println( "Testing RJavaArrayTools.isPrimitiveTypeName" ) ; isprim(); success() ; System.out.println( "Testing RJavaTools.rep" ) ; rep(); success() ; } // }}} // {{{ fails private static void fails( TestException e ){ System.err.println( "\n" ) ; e.printStackTrace() ; System.err.println( "FAILED" ) ; } // }}} // {{{ success private static void success(){ System.out.println( "PASSED" ) ; } // }}} // {{{ isarray private static void isarray() throws TestException { // {{{ int System.out.print( " isArray( int )" ) ; if( RJavaArrayTools.isArray( 0 ) ){ throw new TestException( " isArray( int ) " ); } System.out.println( " false : ok" ) ; // }}} // {{{ boolean System.out.print( " isArray( boolean )" ) ; if( RJavaArrayTools.isArray( true ) ){ throw new TestException( " isArray( boolean ) " ); } System.out.println( " false : ok" ) ; // }}} // {{{ byte System.out.print( " isArray( byte )" ) ; if( RJavaArrayTools.isArray( (byte)0 ) ){ throw new TestException( " isArray( byte ) " ); } System.out.println( " false : ok" ) ; // }}} // {{{ long System.out.print( " isArray( long )" ) ; if( RJavaArrayTools.isArray( (long)0 ) ){ throw new TestException( " isArray( long ) " ); } System.out.println( " false : ok" ) ; // }}} // {{{ short System.out.print( " isArray( short )" ) ; if( RJavaArrayTools.isArray( (double)0 ) ){ throw new TestException( " isArray( short ) " ); } System.out.println( " false : ok" ) ; // }}} // {{{ double System.out.print( " isArray( double )" ) ; if( RJavaArrayTools.isArray( 0.0 ) ){ throw new TestException( " isArray( double ) " ); } System.out.println( " false : ok" ) ; // }}} // {{{ char System.out.print( " isArray( char )" ) ; if( RJavaArrayTools.isArray( 'a' ) ){ throw new TestException( " isArray( char ) " ); } System.out.println( " false : ok" ) ; // }}} // {{{ float System.out.print( " isArray( float )" ) ; if( RJavaArrayTools.isArray( 0.0f ) ){ throw new TestException( " isArray( float ) " ) ; } System.out.println( " false : ok" ) ; // }}} // {{{ String System.out.print( " isArray( String )" ) ; if( RJavaArrayTools.isArray( "dd" ) ){ throw new TestException( " isArray( String ) " ) ; } System.out.println( " false : ok" ) ; // }}} // {{{ int[] int[] x = new int[2] ; System.out.print( " isArray( int[] )" ) ; if( ! RJavaArrayTools.isArray( x ) ){ throw new TestException( " !isArray( int[] ) " ) ; } System.out.println( " true : ok" ) ; // }}} // {{{ Object o = new double[2] Object o = new double[2]; System.out.print( " isArray( double[] (but declared as 0bject) )" ) ; if( ! RJavaArrayTools.isArray( o ) ){ throw new TestException( " !isArray( Object o = new double[2]; ) " ) ; } System.out.println( " true : ok" ) ; // }}} // {{{ null System.out.print( " isArray( null )" ) ; if( RJavaArrayTools.isArray( null ) ){ throw new TestException( " isArray( null) " ) ; } System.out.println( " false : ok" ) ; // }}} } // }}} // {{{ getdimlength private static void getdimlength() throws TestException{ System.out.println( " >> actual arrays" ) ; // {{{ int[] o = new int[10] ; int[] o = new int[10] ; System.out.print( " int[] o = new int[10] ;" ) ; try{ if( RJavaArrayTools.getDimensionLength( o ) != 1 ){ throw new TestException( "getDimensionLength( int[10] ) != 1" ); } } catch( NotAnArrayException e){ throw new TestException( "not an array int[10]" ) ; } System.out.println( " 1 : ok " ); // }}} // {{{ int[] o = new int[0] ; o = new int[0] ; System.out.print( " int[] o = new int[0] ;" ) ; try{ if( RJavaArrayTools.getDimensionLength( o ) != 1 ){ throw new TestException( "getDimensionLength( int[0] ) != 1" ); } } catch( NotAnArrayException e){ throw new TestException( "not an array int[0]" ) ; } System.out.println( " 1 : ok " ); // }}} // {{{ Object[][] = new Object[10][10] ; Object[][] ob = new Object[10][10] ; System.out.print( " new Object[10][10]" ) ; try{ if( RJavaArrayTools.getDimensionLength( ob ) != 2 ){ throw new TestException( "getDimensionLength( new Object[10][10] ) != 2" ); } } catch( NotAnArrayException e){ throw new TestException( "not an array Object[10][10]" ) ; } System.out.println( " 2 : ok " ); // }}} // {{{ Object[][] = new Object[10][10][10] ; Object[][][] obj = new Object[10][10][10] ; System.out.print( " new Object[10][10][10]" ) ; try{ if( RJavaArrayTools.getDimensionLength( obj ) != 3 ){ throw new TestException( "getDimensionLength( new Object[10][10][3] ) != 3" ); } } catch( NotAnArrayException e){ throw new TestException( "not an array Object[10][10][3]" ) ; } System.out.println( " 3 : ok " ); // }}} // {{{ Object System.out.println( " >> Object" ) ; System.out.print( " new Double('10.2') " ) ; boolean ok = false; try{ RJavaArrayTools.getDimensionLength( new Double("10.3") ) ; } catch( NotAnArrayException e){ ok = true ; } if( !ok ){ throw new TestException( "getDimensionLength(Double) did not throw exception" ); } System.out.println( " -> NotAnArrayException : ok " ); // }}} // {{{ primitives System.out.println( " >> Testing primitive types" ) ; // {{{ int System.out.print( " getDimensionLength( int )" ) ; ok = false; try{ RJavaArrayTools.getDimensionLength( 0 ) ; } catch( NotAnArrayException e){ ok = true; } if( !ok ) throw new TestException( " getDimensionLength( int ) not throwing exception" ); System.out.println( " ok" ) ; // }}} // {{{ boolean System.out.print( " getDimensionLength( boolean )" ) ; ok = false; try{ RJavaArrayTools.getDimensionLength( true ) ; } catch( NotAnArrayException e){ ok = true; } if( !ok ) throw new TestException( " getDimensionLength( boolean ) not throwing exception" ); System.out.println( " : ok" ) ; // }}} // {{{ byte System.out.print( " getDimensionLength( byte )" ) ; ok = false; try{ RJavaArrayTools.getDimensionLength( (byte)0 ) ; } catch( NotAnArrayException e){ ok = true; } if( !ok ) throw new TestException( " getDimensionLength( byte ) not throwing exception" ); System.out.println( " : ok" ) ; // }}} // {{{ long System.out.print( " getDimensionLength( long )" ) ; ok = false; try{ RJavaArrayTools.getDimensionLength( (long)0 ); } catch( NotAnArrayException e){ ok = true; } if( !ok) throw new TestException( " getDimensionLength( long ) not throwing exception" ); System.out.println( " ok" ) ; // }}} // {{{ short System.out.print( " getDimensionLength( short )" ) ; ok = false; try{ RJavaArrayTools.getDimensionLength( (double)0 ) ; } catch( NotAnArrayException e ){ ok = true; } if( !ok ) throw new TestException( " getDimensionLength( short ) not throwing exception" ); System.out.println( " : ok" ) ; // }}} // {{{ double System.out.print( " getDimensionLength( double )" ) ; ok = false; try{ RJavaArrayTools.getDimensionLength( 0.0 ); } catch( NotAnArrayException e ){ ok = true; } if( !ok ) throw new TestException( " getDimensionLength( double ) not throwing exception" ); System.out.println( " : ok" ) ; // }}} // {{{ char System.out.print( " getDimensionLength( char )" ) ; ok = false; try{ RJavaArrayTools.getDimensionLength( 'a' ) ; } catch( NotAnArrayException e ){ ok = true; } if( !ok ) throw new TestException( " getDimensionLength( char ) not throwing exception " ); System.out.println( " : ok" ) ; // }}} // {{{ float System.out.print( " getDimensionLength( float )" ) ; ok = false; try{ RJavaArrayTools.getDimensionLength( 0.0f ) ; } catch( NotAnArrayException e ){ ok = true; } if( !ok ) throw new TestException( " getDimensionLength( float ) not throwing exception " ) ; System.out.println( " : ok" ) ; // }}} // }}} // {{{ null System.out.print( " getDimensionLength( null )" ) ; ok = false; try{ RJavaArrayTools.getDimensionLength( null ) ; } catch( NullPointerException e ){ ok = true; } catch( NotAnArrayException e ){ throw new TestException("getDimensionLength( null ) throwing wrong kind of exception") ; } if( !ok ) throw new TestException( " getDimensionLength( null ) not throwing exception " ) ; System.out.println( " : ok" ) ; // }}} } // }}} // {{{ getdims private static void getdims() throws TestException{ int[] res = null ; // {{{ actual arrays // {{{ int[] o = new int[10] ; int[] o = new int[10] ; System.out.print( " int[] o = new int[10] ;" ) ; try{ res = RJavaArrayTools.getDimensions( o ); if( res.length != 1 ){ throw new TestException( "getDimensions( int[10]).length != 1" ); } if( res[0] != 10 ){ throw new TestException( "getDimensions( int[10])[0] != 10" ); } } catch( NotAnArrayException e){ throw new TestException( "not an array int[10]" ) ; } System.out.println( " c( 10 ) : ok " ); // }}} // {{{ Object[][] = new Object[10][10] ; Object[][] ob = new Object[10][10] ; System.out.print( " new Object[10][10]" ) ; try{ res = RJavaArrayTools.getDimensions( ob ) ; if( res.length != 2 ){ throw new TestException( "getDimensions( Object[10][10] ).length != 2" ); } if( res[0] != 10 ){ throw new TestException( "getDimensions( Object[10][10] )[0] != 10" ); } if( res[1] != 10 ){ throw new TestException( "getDimensions( Object[10][10] )[1] != 10" ); } } catch( NotAnArrayException e){ throw new TestException( "not an array Object[10][10]" ) ; } System.out.println( " c(10,10) : ok " ); // }}} // {{{ Object[][] = new Object[10][10][10] ; Object[][][] obj = new Object[10][10][10] ; System.out.print( " new Object[10][10][10]" ) ; try{ res = RJavaArrayTools.getDimensions( obj ) ; if( res.length != 3 ){ throw new TestException( "getDimensions( Object[10][10][10] ).length != 3" ); } if( res[0] != 10 ){ throw new TestException( "getDimensions( Object[10][10][10] )[0] != 10" ); } if( res[1] != 10 ){ throw new TestException( "getDimensions( Object[10][10][10] )[1] != 10" ); } if( res[2] != 10 ){ throw new TestException( "getDimensions( Object[10][10][10] )[1] != 10" ); } } catch( NotAnArrayException e){ throw new TestException( "not an array Object[10][10][10]" ) ; } System.out.println( " c(10,10,10) : ok " ); // }}} // }}} // {{{ zeroes System.out.println( " >> zeroes " ) ; // {{{ int[] o = new int[0] ; o = new int[0] ; System.out.print( " int[] o = new int[0] ;" ) ; try{ res = RJavaArrayTools.getDimensions( o ) ; if( res.length != 1 ){ throw new TestException( "getDimensions( int[0]).length != 1" ); } if( res[0] != 0){ throw new TestException( "getDimensions( int[0])[0] != 0" ); } } catch( NotAnArrayException e){ throw new TestException( "not an array int[0]" ) ; } System.out.println( " c(0) : ok " ); // }}} // {{{ Object[][] = new Object[10][10][0] ; obj = new Object[10][10][0] ; System.out.print( " new Object[10][10][0]" ) ; try{ res = RJavaArrayTools.getDimensions( obj ) ; if( res.length != 3 ){ throw new TestException( "getDimensions( Object[10][10][0] ).length != 3" ); } if( res[0] != 10 ){ throw new TestException( "getDimensions( Object[10][10][0] )[0] != 10" ); } if( res[1] != 10 ){ throw new TestException( "getDimensions( Object[10][10][0] )[1] != 10" ); } if( res[2] != 0 ){ throw new TestException( "getDimensions( Object[10][10][0] )[1] != 0" ); } } catch( NotAnArrayException e){ throw new TestException( "not an array Object[10][10][0]" ) ; } System.out.println( " c(10,10,0) : ok " ); // }}} // {{{ Object[][] = new Object[10][0][10] ; obj = new Object[10][0][10] ; System.out.print( " new Object[10][0][10]" ) ; try{ res = RJavaArrayTools.getDimensions( obj ) ; if( res.length != 3 ){ throw new TestException( "getDimensions( Object[10][0][0] ).length != 3" ); } if( res[0] != 10 ){ throw new TestException( "getDimensions( Object[10][0][0] )[0] != 10" ); } if( res[1] != 0 ){ throw new TestException( "getDimensions( Object[10][0][0] )[1] != 0" ); } if( res[2] != 0 ){ throw new TestException( "getDimensions( Object[10][0][0] )[1] != 0" ); } } catch( NotAnArrayException e){ throw new TestException( "not an array Object[10][0][10]" ) ; } System.out.println( " c(10,0,0) : ok " ); // }}} // }}} // {{{ Object System.out.println( " >> Object" ) ; System.out.print( " new Double('10.2') " ) ; boolean ok = false; try{ res = RJavaArrayTools.getDimensions( new Double("10.3") ) ; } catch( NotAnArrayException e){ ok = true ; } if( !ok ){ throw new TestException( "getDimensions(Double) did not throw exception" ); } System.out.println( " -> NotAnArrayException : ok " ); // }}} // {{{ primitives System.out.println( " >> Testing primitive types" ) ; // {{{ int System.out.print( " getDimensions( int )" ) ; ok = false; try{ RJavaArrayTools.getDimensions( 0 ) ; } catch( NotAnArrayException e){ ok = true; } if( !ok ) throw new TestException( " getDimensions( int ) not throwing exception" ); System.out.println( " ok" ) ; // }}} // {{{ boolean System.out.print( " getDimensions( boolean )" ) ; ok = false; try{ RJavaArrayTools.getDimensions( true ) ; } catch( NotAnArrayException e){ ok = true; } if( !ok ) throw new TestException( " getDimensions( boolean ) not throwing exception" ); System.out.println( " : ok" ) ; // }}} // {{{ byte System.out.print( " getDimensions( byte )" ) ; ok = false; try{ RJavaArrayTools.getDimensions( (byte)0 ) ; } catch( NotAnArrayException e){ ok = true; } if( !ok ) throw new TestException( " getDimensions( byte ) not throwing exception" ); System.out.println( " : ok" ) ; // }}} // {{{ long System.out.print( " getDimensions( long )" ) ; ok = false; try{ RJavaArrayTools.getDimensions( (long)0 ); } catch( NotAnArrayException e){ ok = true; } if( !ok) throw new TestException( " getDimensions( long ) not throwing exception" ); System.out.println( " ok" ) ; // }}} // {{{ short System.out.print( " getDimensions( short )" ) ; ok = false; try{ RJavaArrayTools.getDimensions( (double)0 ) ; } catch( NotAnArrayException e ){ ok = true; } if( !ok ) throw new TestException( " getDimensions( short ) not throwing exception" ); System.out.println( " : ok" ) ; // }}} // {{{ double System.out.print( " getDimensions( double )" ) ; ok = false; try{ RJavaArrayTools.getDimensions( 0.0 ); } catch( NotAnArrayException e ){ ok = true; } if( !ok ) throw new TestException( " getDimensions( double ) not throwing exception" ); System.out.println( " : ok" ) ; // }}} // {{{ char System.out.print( " getDimensions( char )" ) ; ok = false; try{ RJavaArrayTools.getDimensions( 'a' ) ; } catch( NotAnArrayException e ){ ok = true; } if( !ok ) throw new TestException( " getDimensions( char ) not throwing exception " ); System.out.println( " : ok" ) ; // }}} // {{{ float System.out.print( " getDimensions( float )" ) ; ok = false; try{ RJavaArrayTools.getDimensions( 0.0f ) ; } catch( NotAnArrayException e ){ ok = true; } if( !ok ) throw new TestException( " getDimensions( float ) not throwing exception " ) ; System.out.println( " : ok" ) ; // }}} // }}} // {{{ null System.out.print( " getDimensions( null )" ) ; ok = false; try{ RJavaArrayTools.getDimensions( null ) ; } catch( NullPointerException e ){ ok = true; } catch( NotAnArrayException e ){ throw new TestException("getDimensions( null ) throwing wrong kind of exception") ; } if( !ok ) throw new TestException( " getDimensions( null ) not throwing exception " ) ; System.out.println( " : ok" ) ; // }}} } // }}} // {{{ gettruelength private static void gettruelength() throws TestException{ int res = 0 ; // {{{ actual arrays // {{{ int[] o = new int[10] ; int[] o = new int[10] ; System.out.print( " int[] o = new int[10] ;" ) ; try{ res = RJavaArrayTools.getTrueLength( o ); if( res != 10 ){ throw new TestException( "getTrueLength( int[10]) != 10" ); } } catch( NotAnArrayException e){ throw new TestException( "not an array int[10]" ) ; } System.out.println( " 10 : ok " ); // }}} // {{{ Object[][] = new Object[10][10] ; Object[][] ob = new Object[10][10] ; System.out.print( " new Object[10][10]" ) ; try{ res = RJavaArrayTools.getTrueLength( ob ) ; if( res != 100 ){ throw new TestException( "getTrueLength( Object[10][10] ) != 100" ); } } catch( NotAnArrayException e){ throw new TestException( "not an array Object[10][10]" ) ; } System.out.println( " 100 : ok " ); // }}} // {{{ Object[][] = new Object[10][10][10] ; Object[][][] obj = new Object[10][10][10] ; System.out.print( " new Object[10][10][10]" ) ; try{ res = RJavaArrayTools.getTrueLength( obj ) ; if( res != 1000 ){ throw new TestException( "getTrueLength( Object[10][10][10] ) != 1000" ); } } catch( NotAnArrayException e){ throw new TestException( "not an array Object[10][10][10]" ) ; } System.out.println( " 1000 : ok " ); // }}} // }}} // {{{ zeroes System.out.println( " >> zeroes " ) ; // {{{ int[] o = new int[0] ; o = new int[0] ; System.out.print( " int[] o = new int[0] ;" ) ; try{ res = RJavaArrayTools.getTrueLength( o ) ; if( res != 0 ){ throw new TestException( "getTrueLength( int[0]) != 0" ); } } catch( NotAnArrayException e){ throw new TestException( "not an array int[0]" ) ; } System.out.println( " c(0) : ok " ); // }}} // {{{ Object[][] = new Object[10][10][0] ; obj = new Object[10][10][0] ; System.out.print( " new Object[10][10][0]" ) ; try{ res = RJavaArrayTools.getTrueLength( obj ) ; if( res != 0 ){ throw new TestException( "getTrueLength( Object[10][10][0] ) != 0" ); } } catch( NotAnArrayException e){ throw new TestException( "not an array Object[10][10][0]" ) ; } System.out.println( " 0 : ok " ); // }}} // {{{ Object[][] = new Object[10][0][10] ; obj = new Object[10][0][10] ; System.out.print( " new Object[10][0][10]" ) ; try{ res = RJavaArrayTools.getTrueLength( obj ) ; if( res != 0){ throw new TestException( "getTrueLength( Object[10][0][0] ) != 0" ); } } catch( NotAnArrayException e){ throw new TestException( "not an array Object[10][0][10]" ) ; } System.out.println( " 0 : ok " ); // }}} // }}} // {{{ Object System.out.println( " >> Object" ) ; System.out.print( " new Double('10.2') " ) ; boolean ok = false; try{ res = RJavaArrayTools.getTrueLength( new Double("10.3") ) ; } catch( NotAnArrayException e){ ok = true ; } if( !ok ){ throw new TestException( "getTrueLength(Double) did not throw exception" ); } System.out.println( " -> NotAnArrayException : ok " ); // }}} // {{{ primitives System.out.println( " >> Testing primitive types" ) ; // {{{ int System.out.print( " getTrueLength( int )" ) ; ok = false; try{ RJavaArrayTools.getTrueLength( 0 ) ; } catch( NotAnArrayException e){ ok = true; } if( !ok ) throw new TestException( " getTrueLength( int ) not throwing exception" ); System.out.println( " ok" ) ; // }}} // {{{ boolean System.out.print( " getTrueLength( boolean )" ) ; ok = false; try{ RJavaArrayTools.getTrueLength( true ) ; } catch( NotAnArrayException e){ ok = true; } if( !ok ) throw new TestException( " getTrueLength( boolean ) not throwing exception" ); System.out.println( " : ok" ) ; // }}} // {{{ byte System.out.print( " getTrueLength( byte )" ) ; ok = false; try{ RJavaArrayTools.getTrueLength( (byte)0 ) ; } catch( NotAnArrayException e){ ok = true; } if( !ok ) throw new TestException( " getTrueLength( byte ) not throwing exception" ); System.out.println( " : ok" ) ; // }}} // {{{ long System.out.print( " getTrueLength( long )" ) ; ok = false; try{ RJavaArrayTools.getTrueLength( (long)0 ); } catch( NotAnArrayException e){ ok = true; } if( !ok) throw new TestException( " getTrueLength( long ) not throwing exception" ); System.out.println( " ok" ) ; // }}} // {{{ short System.out.print( " getTrueLength( short )" ) ; ok = false; try{ RJavaArrayTools.getTrueLength( (double)0 ) ; } catch( NotAnArrayException e ){ ok = true; } if( !ok ) throw new TestException( " getTrueLength( short ) not throwing exception" ); System.out.println( " : ok" ) ; // }}} // {{{ double System.out.print( " getTrueLength( double )" ) ; ok = false; try{ RJavaArrayTools.getTrueLength( 0.0 ); } catch( NotAnArrayException e ){ ok = true; } if( !ok ) throw new TestException( " getTrueLength( double ) not throwing exception" ); System.out.println( " : ok" ) ; // }}} // {{{ char System.out.print( " getTrueLength( char )" ) ; ok = false; try{ RJavaArrayTools.getTrueLength( 'a' ) ; } catch( NotAnArrayException e ){ ok = true; } if( !ok ) throw new TestException( " getTrueLength( char ) not throwing exception " ); System.out.println( " : ok" ) ; // }}} // {{{ float System.out.print( " getTrueLength( float )" ) ; ok = false; try{ RJavaArrayTools.getTrueLength( 0.0f ) ; } catch( NotAnArrayException e ){ ok = true; } if( !ok ) throw new TestException( " getTrueLength( float ) not throwing exception " ) ; System.out.println( " : ok" ) ; // }}} // }}} // {{{ null System.out.print( " getTrueLength( null )" ) ; ok = false; try{ RJavaArrayTools.getTrueLength( null ) ; } catch( NullPointerException e ){ ok = true; } catch( NotAnArrayException e ){ throw new TestException("getTrueLength( null ) throwing wrong kind of exception") ; } if( !ok ) throw new TestException( " getTrueLength( null ) not throwing exception " ) ; System.out.println( " : ok" ) ; // }}} } // }}} // {{{ isRectangular private static void isrect() throws TestException { // {{{ int System.out.print( " isRectangularArray( int )" ) ; if( RJavaArrayTools.isRectangularArray( 0 ) ){ throw new TestException( " isRectangularArray( int ) " ); } System.out.println( " false : ok" ) ; // }}} // {{{ boolean System.out.print( " isRectangularArray( boolean )" ) ; if( RJavaArrayTools.isRectangularArray( true ) ){ throw new TestException( " isRectangularArray( boolean ) " ); } System.out.println( " false : ok" ) ; // }}} // {{{ byte System.out.print( " isRectangularArray( byte )" ) ; if( RJavaArrayTools.isRectangularArray( (byte)0 ) ){ throw new TestException( " isRectangularArray( byte ) " ); } System.out.println( " false : ok" ) ; // }}} // {{{ long System.out.print( " isRectangularArray( long )" ) ; if( RJavaArrayTools.isRectangularArray( (long)0 ) ){ throw new TestException( " isRectangularArray( long ) " ); } System.out.println( " false : ok" ) ; // }}} // {{{ short System.out.print( " isRectangularArray( short )" ) ; if( RJavaArrayTools.isRectangularArray( (double)0 ) ){ throw new TestException( " isRectangularArray( short ) " ); } System.out.println( " false : ok" ) ; // }}} // {{{ double System.out.print( " isRectangularArray( double )" ) ; if( RJavaArrayTools.isRectangularArray( 0.0 ) ){ throw new TestException( " isRectangularArray( double ) " ); } System.out.println( " false : ok" ) ; // }}} // {{{ char System.out.print( " isRectangularArray( char )" ) ; if( RJavaArrayTools.isRectangularArray( 'a' ) ){ throw new TestException( " isRectangularArray( char ) " ); } System.out.println( " false : ok" ) ; // }}} // {{{ float System.out.print( " isRectangularArray( float )" ) ; if( RJavaArrayTools.isRectangularArray( 0.0f ) ){ throw new TestException( " isRectangularArray( float ) " ) ; } System.out.println( " false : ok" ) ; // }}} // {{{ String System.out.print( " isRectangularArray( String )" ) ; if( RJavaArrayTools.isRectangularArray( "dd" ) ){ throw new TestException( " isRectangularArray( String ) " ) ; } System.out.println( " false : ok" ) ; // }}} // {{{ int[] int[] x = new int[2] ; System.out.print( " isRectangularArray( int[] )" ) ; if( ! RJavaArrayTools.isRectangularArray( x ) ){ throw new TestException( " !isRectangularArray( int[] ) " ) ; } System.out.println( " true : ok" ) ; // }}} // {{{ Object o = new double[2] Object o = new double[2]; System.out.print( " isRectangularArray( double[] (but declared as 0bject) )" ) ; if( ! RJavaArrayTools.isRectangularArray( o ) ){ throw new TestException( " !isRectangularArray( Object o = new double[2]; ) " ) ; } System.out.println( " true : ok" ) ; // }}} // {{{ null System.out.print( " isRectangularArray( null )" ) ; if( RJavaArrayTools.isRectangularArray( null ) ){ throw new TestException( " isRectangularArray( null) " ) ; } System.out.println( " false : ok" ) ; // }}} // {{{ 2d rectangular int[][] x2d = new int[3][4]; System.out.print( " isRectangularArray( new int[3][4] )" ) ; if( ! RJavaArrayTools.isRectangularArray( x2d ) ){ throw new TestException( " !isRectangularArray( new int[3][4] ) " ) ; } System.out.println( " true : ok" ) ; // }}} // {{{ 2d not rectangular int[][] x2d_not = new int[2][] ; x2d_not[0] = new int[2] ; x2d_not[1] = new int[3] ; System.out.print( " isRectangularArray( new int[2][2,4] )" ) ; if( RJavaArrayTools.isRectangularArray( x2d_not ) ){ throw new TestException( " !isRectangularArray( new int[2][2,4] ) " ) ; } System.out.println( " false : ok" ) ; // }}} // {{{ 3d not rectangular int[][][] x3d_not = new int[1][][] ; x3d_not[0] = new int[2][]; x3d_not[0][0] = new int[1] ; x3d_not[0][1] = new int[2] ; System.out.print( " isRectangularArray( new int[2][2][10,25] )" ) ; if( RJavaArrayTools.isRectangularArray( x3d_not ) ){ throw new TestException( " !isRectangularArray( new int[2][2][10,25] ) " ) ; } System.out.println( " false : ok" ) ; // }}} } // }}} // {{{ getObjectTypeName private static void gettypename() throws TestException { String res ; // {{{ actual arrays // {{{ int[] o = new int[10] ; System.out.print( " int[] o = new int[10] ;" ) ; try{ res = RJavaArrayTools.getObjectTypeName( new int[1] ); if( !res.equals("I") ){ throw new TestException( "getObjectTypeName(int[]) != 'I' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array int[10]" ) ; } System.out.println( " I : ok " ); // }}} // {{{ boolean[] ; System.out.print( " boolean[]" ) ; try{ res = RJavaArrayTools.getObjectTypeName( new boolean[1] ); if( !res.equals("Z") ){ throw new TestException( "getObjectTypeName(boolean[]) != 'Z' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array boolean[10]" ) ; } System.out.println( " Z : ok " ); // }}} // {{{ byte[] ; System.out.print( " byte[]" ) ; try{ res = RJavaArrayTools.getObjectTypeName( new byte[1] ); if( !res.equals("B") ){ throw new TestException( "getObjectTypeName(byte[]) != 'B' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array byte[10]" ) ; } System.out.println( " B : ok " ); // }}} // {{{ long[] ; System.out.print( " long[]" ) ; try{ res = RJavaArrayTools.getObjectTypeName( new long[1] ); if( !res.equals("J") ){ throw new TestException( "getObjectTypeName(long[]) != 'J' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array long[10]" ) ; } System.out.println( " J : ok " ); // }}} // {{{ short[] ; System.out.print( " short[]" ) ; try{ res = RJavaArrayTools.getObjectTypeName( new short[1] ); if( !res.equals("S") ){ throw new TestException( "getObjectTypeName(short[]) != 'S' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array short[10]" ) ; } System.out.println( " S : ok " ); // }}} // {{{ double[] ; System.out.print( " double[]" ) ; try{ res = RJavaArrayTools.getObjectTypeName( new double[1] ); if( !res.equals("D") ){ throw new TestException( "getObjectTypeName(double[]) != 'D' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array double[10]" ) ; } System.out.println( " D : ok " ); // }}} // {{{ char[] ; System.out.print( " char[]" ) ; try{ res = RJavaArrayTools.getObjectTypeName( new char[1] ); if( !res.equals("C") ){ throw new TestException( "getObjectTypeName(char[]) != 'C' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array char[10]" ) ; } System.out.println( " C : ok " ); // }}} // {{{ float[] ; System.out.print( " float[]" ) ; try{ res = RJavaArrayTools.getObjectTypeName( new float[1] ); if( !res.equals("F") ){ throw new TestException( "getObjectTypeName(float[]) != 'F' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array float[10]" ) ; } System.out.println( " F : ok " ); // }}} System.out.println(" >> multi dim primitive arrays" ) ; // {{{ int[] o = new int[10] ; System.out.print( " int[][] ;" ) ; try{ res = RJavaArrayTools.getObjectTypeName( new int[1][1] ); if( !res.equals("I") ){ throw new TestException( "getObjectTypeName(int[]) != 'I' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array int[10]" ) ; } System.out.println( " I : ok " ); // }}} // {{{ boolean[] ; System.out.print( " boolean[][]" ) ; try{ res = RJavaArrayTools.getObjectTypeName( new boolean[1][1] ); if( !res.equals("Z") ){ throw new TestException( "getObjectTypeName(boolean[]) != 'Z' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array boolean[10]" ) ; } System.out.println( " Z : ok " ); // }}} // {{{ byte[] ; System.out.print( " byte[][]" ) ; try{ res = RJavaArrayTools.getObjectTypeName( new byte[1][1] ); if( !res.equals("B") ){ throw new TestException( "getObjectTypeName(byte[]) != 'B' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array byte[10]" ) ; } System.out.println( " B : ok " ); // }}} // {{{ long[] ; System.out.print( " long[][]" ) ; try{ res = RJavaArrayTools.getObjectTypeName( new long[1][1] ); if( !res.equals("J") ){ throw new TestException( "getObjectTypeName(long[]) != 'J' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array long[10]" ) ; } System.out.println( " J : ok " ); // }}} // {{{ short[] ; System.out.print( " short[][]" ) ; try{ res = RJavaArrayTools.getObjectTypeName( new short[1][1] ); if( !res.equals("S") ){ throw new TestException( "getObjectTypeName(short[]) != 'S' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array short[10]" ) ; } System.out.println( " S : ok " ); // }}} // {{{ double[] ; System.out.print( " double[][]" ) ; try{ res = RJavaArrayTools.getObjectTypeName( new double[1][1] ); if( !res.equals("D") ){ throw new TestException( "getObjectTypeName(double[]) != 'D' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array double[10]" ) ; } System.out.println( " D : ok " ); // }}} // {{{ char[] ; System.out.print( " char[][]" ) ; try{ res = RJavaArrayTools.getObjectTypeName( new char[1][1] ); if( !res.equals("C") ){ throw new TestException( "getObjectTypeName(char[]) != 'C' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array char[10]" ) ; } System.out.println( " C : ok " ); // }}} // {{{ float[] ; System.out.print( " float[][]" ) ; try{ res = RJavaArrayTools.getObjectTypeName( new float[1][1] ); if( !res.equals("F") ){ throw new TestException( "getObjectTypeName(float[]) != 'F' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array float[10]" ) ; } System.out.println( " F : ok " ); // }}} // {{{ Object[][] = new Object[10][10] ; Object[][] ob = new Object[10][10] ; System.out.print( " new Object[10][10]" ) ; try{ res = RJavaArrayTools.getObjectTypeName( ob ) ; if( !res.equals("java.lang.Object") ){ throw new TestException( "getObjectTypeName(Object[][]) != 'java.lang.Object' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array Object[10][10]" ) ; } System.out.println( " : ok " ); // }}} // {{{ Object[][] = new Object[10][10][10] ; Object[][][] obj = new Object[10][10][10] ; System.out.print( " new Object[10][10][10]" ) ; try{ res = RJavaArrayTools.getObjectTypeName( obj ) ; if( !res.equals("java.lang.Object") ){ throw new TestException( "getObjectTypeName( Object[10][10][10] ) != 'java.lang.Object' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array Object[10][10][10]" ) ; } System.out.println( " 1000 : ok " ); // }}} // }}} // {{{ zeroes System.out.println( " >> zeroes " ) ; // {{{ int[] o = new int[0] ; int[] o = new int[0] ; System.out.print( " int[] o = new int[0] ;" ) ; try{ res = RJavaArrayTools.getObjectTypeName( o ) ; if( !res.equals("I") ){ throw new TestException( "getObjectTypeName(int[0]) != 'I' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array int[0]" ) ; } System.out.println( " : ok " ); // }}} // {{{ Object[][] = new Object[10][10][0] ; obj = new Object[10][10][0] ; System.out.print( " new Object[10][10][0]" ) ; try{ res = RJavaArrayTools.getObjectTypeName( obj ) ; if( !res.equals("java.lang.Object") ){ throw new TestException( "getObjectTypeName( Object[10][10][0] ) != 'java.lang.Object' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array Object[10][10][0]" ) ; } System.out.println( " : ok " ); // }}} // {{{ Object[][] = new Object[10][0][10] ; obj = new Object[10][0][10] ; System.out.print( " new Object[10][0][10]" ) ; try{ res = RJavaArrayTools.getObjectTypeName( obj ) ; if( !res.equals("java.lang.Object") ){ throw new TestException( "getObjectTypeName( Object[10][0][0] ) != 'java.lang.Object' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array Object[10][0][10]" ) ; } System.out.println( " 0 : ok " ); // }}} // }}} // {{{ Object System.out.println( " >> Object" ) ; System.out.print( " new Double('10.2') " ) ; boolean ok = false; try{ res = RJavaArrayTools.getObjectTypeName( new Double("10.3") ) ; } catch( NotAnArrayException e){ ok = true ; } if( !ok ){ throw new TestException( "getObjectTypeName(Double) did not throw exception" ); } System.out.println( " -> NotAnArrayException : ok " ); // }}} // {{{ primitives System.out.println( " >> Testing primitive types" ) ; // {{{ int System.out.print( " getObjectTypeName( int )" ) ; ok = false; try{ RJavaArrayTools.getObjectTypeName( 0 ) ; } catch( NotAnArrayException e){ ok = true; } if( !ok ) throw new TestException( " getObjectTypeName( int ) not throwing exception" ); System.out.println( " ok" ) ; // }}} // {{{ boolean System.out.print( " getObjectTypeName( boolean )" ) ; ok = false; try{ RJavaArrayTools.getObjectTypeName( true ) ; } catch( NotAnArrayException e){ ok = true; } if( !ok ) throw new TestException( " getObjectTypeName( boolean ) not throwing exception" ); System.out.println( " : ok" ) ; // }}} // {{{ byte System.out.print( " getObjectTypeName( byte )" ) ; ok = false; try{ RJavaArrayTools.getObjectTypeName( (byte)0 ) ; } catch( NotAnArrayException e){ ok = true; } if( !ok ) throw new TestException( " getObjectTypeName( byte ) not throwing exception" ); System.out.println( " : ok" ) ; // }}} // {{{ long System.out.print( " getObjectTypeName( long )" ) ; ok = false; try{ RJavaArrayTools.getObjectTypeName( (long)0 ); } catch( NotAnArrayException e){ ok = true; } if( !ok) throw new TestException( " getObjectTypeName( long ) not throwing exception" ); System.out.println( " ok" ) ; // }}} // {{{ short System.out.print( " getObjectTypeName( short )" ) ; ok = false; try{ RJavaArrayTools.getObjectTypeName( (double)0 ) ; } catch( NotAnArrayException e ){ ok = true; } if( !ok ) throw new TestException( " getObjectTypeName( short ) not throwing exception" ); System.out.println( " : ok" ) ; // }}} // {{{ double System.out.print( " getObjectTypeName( double )" ) ; ok = false; try{ RJavaArrayTools.getObjectTypeName( 0.0 ); } catch( NotAnArrayException e ){ ok = true; } if( !ok ) throw new TestException( " getObjectTypeName( double ) not throwing exception" ); System.out.println( " : ok" ) ; // }}} // {{{ char System.out.print( " getObjectTypeName( char )" ) ; ok = false; try{ RJavaArrayTools.getObjectTypeName( 'a' ) ; } catch( NotAnArrayException e ){ ok = true; } if( !ok ) throw new TestException( " getObjectTypeName( char ) not throwing exception " ); System.out.println( " : ok" ) ; // }}} // {{{ float System.out.print( " getObjectTypeName( float )" ) ; ok = false; try{ RJavaArrayTools.getObjectTypeName( 0.0f ) ; } catch( NotAnArrayException e ){ ok = true; } if( !ok ) throw new TestException( " getObjectTypeName( float ) not throwing exception " ) ; System.out.println( " : ok" ) ; // }}} // }}} // {{{ null System.out.print( " getObjectTypeName( null )" ) ; ok = false; try{ RJavaArrayTools.getObjectTypeName( null ) ; } catch( NullPointerException e ){ ok = true; } catch( NotAnArrayException e ){ throw new TestException("getObjectTypeName( null ) throwing wrong kind of exception") ; } if( !ok ) throw new TestException( " getObjectTypeName( null ) not throwing exception " ) ; System.out.println( " : ok" ) ; // }}} } // }}} // {{{ isPrimitiveTypeName private static void isprim() throws TestException{ System.out.print( " isPrimitiveTypeName( 'I' ) " ) ; if( !RJavaArrayTools.isPrimitiveTypeName("I") ) throw new TestException("I not primitive") ; System.out.println( " true : ok " ); System.out.print( " isPrimitiveTypeName( 'Z' ) " ) ; if( !RJavaArrayTools.isPrimitiveTypeName("Z") ) throw new TestException("Z not primitive") ; System.out.println( " true : ok " ); System.out.print( " isPrimitiveTypeName( 'B' ) " ) ; if( !RJavaArrayTools.isPrimitiveTypeName("B") ) throw new TestException("B not primitive") ; System.out.println( " true : ok " ); System.out.print( " isPrimitiveTypeName( 'J' ) " ) ; if( !RJavaArrayTools.isPrimitiveTypeName("J") ) throw new TestException("J not primitive") ; System.out.println( " true : ok " ); System.out.print( " isPrimitiveTypeName( 'S' ) " ) ; if( !RJavaArrayTools.isPrimitiveTypeName("S") ) throw new TestException("S not primitive") ; System.out.println( " true : ok " ); System.out.print( " isPrimitiveTypeName( 'D' ) " ) ; if( !RJavaArrayTools.isPrimitiveTypeName("D") ) throw new TestException("D not primitive") ; System.out.println( " true : ok " ); System.out.print( " isPrimitiveTypeName( 'C' ) " ) ; if( !RJavaArrayTools.isPrimitiveTypeName("C") ) throw new TestException("C not primitive") ; System.out.println( " true : ok " ); System.out.print( " isPrimitiveTypeName( 'F' ) " ) ; if( !RJavaArrayTools.isPrimitiveTypeName("F") ) throw new TestException("F not primitive") ; System.out.println( " true : ok " ); System.out.print( " isPrimitiveTypeName( 'java.lang.Object' ) " ) ; if( RJavaArrayTools.isPrimitiveTypeName("java.lang.Object") ) throw new TestException("Object primitive") ; System.out.println( " false : ok " ); } // }}} // {{{ rep private static void rep() throws TestException{ DummyPoint p = new DummyPoint(10, 10) ; DummyPoint[] res = null; System.out.print( " rep( DummyPoint, 10)" ); try{ res = (DummyPoint[])RJavaArrayTools.rep( p, 10 ); } catch( Throwable e){ throw new TestException( "rep(DummyPoint, 10) failed" ) ; } if( res.length != 10 ){ throw new TestException( "rep(DummyPoint, 10).length != 10" ) ; } if( res[5].getX() != 10.0 ){ throw new TestException( "rep(DummyPoint, 10)[5].getX() != 10" ) ; } System.out.println( ": ok " ); } /// }}} } rJava/src/java/RJavaArrayTools$ArrayDimensionMismatchException.class0000644000176200001440000000121512256051764025364 0ustar liggesusers.(     (II)VCodeLineNumberTable SourceFileRJavaArrayTools.javajava/lang/StringBuffer dimension of indexer ( !" !#) too large for array (depth =) $% &'/RJavaArrayTools$ArrayDimensionMismatchExceptionArrayDimensionMismatchException InnerClassesjava/lang/Exception()Vappend,(Ljava/lang/String;)Ljava/lang/StringBuffer;(I)Ljava/lang/StringBuffer;toString()Ljava/lang/String;(Ljava/lang/String;)VRJavaArrayTools!  B&*Y  *%+   rJava/src/java/RJavaClassLoader$RJavaObjectInputStream.class0000644000176200001440000000160712256051764023523 0ustar liggesusers..     !this$0LRJavaClassLoader; Synthetic*(LRJavaClassLoader;Ljava/io/InputStream;)VCodeLineNumberTable Exceptions" resolveClass.(Ljava/io/ObjectStreamClass;)Ljava/lang/Class;# SourceFileRJavaClassLoader.java $  % &'( )*+ ,-'RJavaClassLoader$RJavaObjectInputStreamRJavaObjectInputStream InnerClassesjava/io/ObjectInputStreamjava/io/IOException java/lang/ClassNotFoundException(Ljava/io/InputStream;)Vjava/io/ObjectStreamClassgetName()Ljava/lang/String;RJavaClassLoadergetPrimaryLoader()LRJavaClassLoader;java/lang/ClassforName=(Ljava/lang/String;ZLjava/lang/ClassLoader;)Ljava/lang/Class;     + *,*+gf h $ +j rJava/src/java/PrimitiveArrayException.class0000644000176200001440000000074212256051764020715 0ustar liggesusers.    (Ljava/lang/String;)VCodeLineNumberTable SourceFilePrimitiveArrayException.javajava/lang/StringBuffer :cannot convert to single dimension array of primitive type   PrimitiveArrayExceptionjava/lang/Exception()Vappend,(Ljava/lang/String;)Ljava/lang/StringBuffer;toString()Ljava/lang/String;!  4*Y+  rJava/src/java/ArrayDimensionException.java0000644000176200001440000000020412256051760020473 0ustar liggesuserspublic class ArrayDimensionException extends Exception{ public ArrayDimensionException(String message){ super( message ) ; } } rJava/src/java/NotComparableException.class0000644000176200001440000000165412256051764020477 0ustar liggesusers.4     !" # $ %&'()'(Ljava/lang/Object;Ljava/lang/Object;)VCodeLineNumberTable(Ljava/lang/Object;)V(Ljava/lang/Class;)V(Ljava/lang/String;)V SourceFileNotComparableException.javajava/lang/StringBuffer *objects of class +,- ./0 12 and  are not comparable 32  class ( does not implement java.util.ComparableNotComparableExceptionjava/lang/Exception()Vappend,(Ljava/lang/String;)Ljava/lang/StringBuffer;java/lang/ObjectgetClass()Ljava/lang/Class;java/lang/ClassgetName()Ljava/lang/String;toString!N2*Y+,   1 ( *+   % *+  9*Y +   rJava/src/java/NotComparableException.java0000644000176200001440000000132512256051760020302 0ustar liggesusers/** * Exception generated when two objects cannot be compared * * Such cases happen when an object does not implement the Comparable * interface or when the comparison produces a ClassCastException */ public class NotComparableException extends Exception{ public NotComparableException(Object a, Object b){ super( "objects of class " + a.getClass().getName() + " and " + b.getClass().getName() + " are not comparable" ) ; } public NotComparableException( Object o){ this( o.getClass().getName() ) ; } public NotComparableException( Class cl){ this( cl.getName() ) ; } public NotComparableException( String type ){ super( "class " + type + " does not implement java.util.Comparable" ) ; } } rJava/src/java/RJavaArrayTools.class0000644000176200001440000003705112256051764017115 0ustar liggesusers.- 6:;< = > ?@ ? A BCD AE FA GAH IA AJ KAL MA N 6OP Q 6RST UVW UXY Z[\]^_`ab -? -c -d e -f g Bh Bij 6k l Um Un Uo pq =r =stu @> 6v wx wy z w{ w| w} w~ w w w w          X w w w w w w w w w           m? o m m w m   6 yQ      m     6  6 R  6            ArrayDimensionMismatchException InnerClassesprimitiveClassesLjava/util/Map; NA_INTEGERI ConstantValueNA_REALDNA_bitsJclass$java$lang$ComparableLjava/lang/Class; Synthetic()VCodeLineNumberTableinitPrimitiveClasses()Ljava/util/Map;getObjectTypeName&(Ljava/lang/Object;)Ljava/lang/String; Exceptions(I)I(Z)I(B)I(J)I(S)I(D)I(C)I(F)ImakeArraySignature'(Ljava/lang/String;I)Ljava/lang/String;getClassForSignature<(Ljava/lang/String;Ljava/lang/ClassLoader;)Ljava/lang/Class;isSingleDimensionArray(Ljava/lang/Object;)ZisPrimitiveTypeName(Ljava/lang/String;)ZisRectangularArray Deprecated(I)Z(Z)Z(B)Z(J)Z(S)Z(D)Z(C)Z(F)ZgetDimensionLength(Ljava/lang/Object;)I getDimensions(Ljava/lang/Object;)[I(I)[I(Z)[I(B)[I(J)[I(S)[I(D)[I(C)[I(F)[I getTrueLengthisArrayget((Ljava/lang/Object;[I)Ljava/lang/Object;getInt(Ljava/lang/Object;[I)I getBoolean(Ljava/lang/Object;[I)ZgetByte(Ljava/lang/Object;[I)BgetLong(Ljava/lang/Object;[I)JgetShort(Ljava/lang/Object;[I)S getDouble(Ljava/lang/Object;[I)DgetChar(Ljava/lang/Object;[I)CgetFloat(Ljava/lang/Object;[I)F'(Ljava/lang/Object;I)Ljava/lang/Object;(Ljava/lang/Object;I)I(Ljava/lang/Object;I)Z(Ljava/lang/Object;I)B(Ljava/lang/Object;I)J(Ljava/lang/Object;I)S(Ljava/lang/Object;I)D(Ljava/lang/Object;I)C(Ljava/lang/Object;I)FcheckDimensions(Ljava/lang/Object;[I)Vset)(Ljava/lang/Object;[ILjava/lang/Object;)V(Ljava/lang/Object;[II)V(Ljava/lang/Object;[IZ)V(Ljava/lang/Object;[IB)V(Ljava/lang/Object;[IJ)V(Ljava/lang/Object;[IS)V(Ljava/lang/Object;[ID)V(Ljava/lang/Object;[IC)V(Ljava/lang/Object;[IF)V((Ljava/lang/Object;ILjava/lang/Object;)V(Ljava/lang/Object;II)V(Ljava/lang/Object;IZ)V(Ljava/lang/Object;IB)V(Ljava/lang/Object;IJ)V(Ljava/lang/Object;IS)V(Ljava/lang/Object;ID)V(Ljava/lang/Object;IC)V(Ljava/lang/Object;IF)VgetArrayunique(([Ljava/lang/Object;)[Ljava/lang/Object; duplicated([Ljava/lang/Object;)[Z anyDuplicated([Ljava/lang/Object;)Isort)([Ljava/lang/Object;Z)[Ljava/lang/Object;revcopygetIterableContent)(Ljava/lang/Iterable;)[Ljava/lang/Object;rep((Ljava/lang/Object;I)[Ljava/lang/Object;getCloneMethod-(Ljava/lang/Class;)Ljava/lang/reflect/Method; cloneObject&(Ljava/lang/Object;)Ljava/lang/Object; unboxDoubles([Ljava/lang/Double;)[D unboxIntegers([Ljava/lang/Integer;)[I unboxBooleans([Ljava/lang/Boolean;)[IisNA boxDoubles([D)[Ljava/lang/Double; boxIntegers([I)[Ljava/lang/Integer; boxBooleans([I)[Ljava/lang/Boolean;class$%(Ljava/lang/String;)Ljava/lang/Class; SourceFileRJavaArrayTools.java 6 java/lang/ClassNotFoundExceptionjava/lang/NoClassDefFoundError   java/util/HashMap  ZBSCF  NotAnArrayException  \[+L? ; primitive type : int primitive type : boolean primitive type : byte primitive type : long primitive type : short primitive type : double primitive type : char primitive type : float java/lang/StringBuffer     'java/lang/Class      ArrayWrapper  java/lang/NullPointerException array is null    /RJavaArrayTools$ArrayDimensionMismatchException                    java/util/Vector   [Ljava/lang/Object;  java.lang.Comparable 56   NotComparableException       java/lang/Cloneable $%    ' java/lang/IllegalAccessException+java/lang/reflect/InvocationTargetException  clone  ! " #$ % & '( java/lang/Double . )java/lang/Integer *java/lang/Boolean  +,RJavaArrayToolsjava/lang/Objectjava/lang/ThrowableforName getMessage()Ljava/lang/String;(Ljava/lang/String;)VTYPE java/util/Mapput8(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;java/lang/Bytejava/lang/Longjava/lang/Shortjava/lang/Characterjava/lang/FloatgetClass()Ljava/lang/Class;()Z(Ljava/lang/Class;)VgetNamejava/lang/String replaceFirst8(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;replaceD(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String;append(C)Ljava/lang/StringBuffer;,(Ljava/lang/String;)Ljava/lang/StringBuffer;toString containsKey=(Ljava/lang/String;ZLjava/lang/ClassLoader;)Ljava/lang/Class; lastIndexOflength()Iequals(Ljava/lang/Object;)V isRectangulargetComponentTypejava/lang/reflect/Array getLength(II)VsetInt setBooleansetBytesetLongsetShort setDoublesetCharsetFloataddsize newInstance&(Ljava/lang/Class;I)Ljava/lang/Object;toArrayisAssignableFrom(Ljava/lang/Class;)Zjava/util/Arrays([Ljava/lang/Object;)Vjava/lang/Iterableiterator()Ljava/util/Iterator;java/util/IteratorhasNextnext()Ljava/lang/Object;()[Ljava/lang/Object;java/lang/reflect/Method isAccessible setAccessible(Z)Vinvoke9(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;castgetCause()Ljava/lang/Throwable;getDeclaredMethods()[Ljava/lang/reflect/Method;getParameterTypes()[Ljava/lang/Class; getSuperclass doubleValue()DintValue booleanValuedoubleToRawLongBits(D)J(D)V(I)VlongBitsToDouble(J)D! u!*  ( jYK* W* W* W* W* W* W* W* W** %&' (,)8*D+P,\-h. N**L+ Y++M, !" #9:<= " Y$%? " Y&%@ " Y'%A " Y(%B " Y)%C " Y*%D " Y+%E " Y,%F i5-Y.M>,[/W,*0W*1 ,;/W,2"LMNMP"Q)R0T @ 3*43*56*+7Z [] L(*8Y**L+[9cef&g d*:* ;* ;*;*;*;*;*;*;* m no p+q6rAsLtWubv m)*8<*<=Y*>?<M< $!$" !$%'         m9* @YAB*L+ Y+=++CL"#%,/7@ " Y$% " Y&% " Y'% " Y(% " Y)% " Y*% " Y+% " Y,% v* @YAB*L+ Y+*M*<> :6+),D6O,EM+CLON#%*/29?FINQW_gms@ " Y$% " Y&% " Y'% " Y(% " Y)% " Y*% " Y+% " Y,% Q* @YAB*L+ Y+*M>6+!,Dh>,EM+CL6 #%'*18>AGO@ " Y$% " Y&% " Y'% " Y(%  " Y)%  " Y*%  " Y+%  " Y,%  ***      ! " # $ '*+F++d.E7X '*+F++d.G;X '*+F++d.H>X '*+F++d.IAX '*+F++d.JDX '*+F++d.KGX '*+F++d.LJX '*+F++d.MMX '*+F++d.NPX $ * YOOUX $ * YOPXX $ * YOQ[X $ * YOR^X $ * YOSaX $ * YOTdX $ * YOUgX $ * YOVjX $ * YOWmX @+=*<> XYYqrs tvX ,*+F++d.,Z X ,*+F++d.[ X ,*+F++d.\ X ,*+F++d.] X ,*+F++d. ^ X ,*+F++d._ X ,*+F++d.(` X  ,*+F++d.a X  ,*+F++d.$b X  ) * YO,c  X  ) * YOd  X  ) * YOe  X ) * YOf  X ) * YO g  X ) * YOh  X ) * YO(i  X ) * YOj  X ) * YO$k  X c+*+l+=*N6d-+.EN-&   #)X  *<*M>* ,TmYnN6^,3N*2:6`69*2:,3&o,T-pW6,TDŽ*C-qrss:-tW^"+5;>JPafkruz d*<*M>* ,T>D,35*2:`6%*2:,3o,Tۄ,>!*/:@Q V\b u9*<=0*2N`6*2:-o*  (+17! |*CMuvwYuu,x yY,z*>*{:|l66)2:dd2SddS>01$2-40566;8?9B<I=S>Z?h@s=yCy Z.*<*CrssM>,dd*2S,OPQR&Q,T V**<*CrssM>,*2S,Z[\]"\(_  S+mYnL*}M,~+,pW+efgh&j !"p*rssM*,*N-6-6!*-*s:,Sߧ:-:-,+RU+R`Jvwx{ |&}+4FLRUW]`bhn# $%y=M*8*L>+#+2M,; ,,*K*  +-3; &'A*L+=+N*+*sN:+:+-%(%26  %(*/249?# ()[3*<*=N<-*2 *2R- 1 *+Z2*<*= N<-*2 *2O- 0 ,-b:*<*= N<%-*2*2O- 8 .1& /0]5*<*=N<*1-Y*1S- 3 12\4*<*=N<*.-Y*.S- 2 34d<*<*=N<&*.-Y*.S- :562*LY+17<3#89 X rJava/src/java/DummyPoint.class0000644000176200001440000000075112256051764016174 0ustar liggesusers.    xIy()VCodeLineNumberTable(II)VgetX()Dmove SourceFileDummyPoint.java    DummyPointjava/lang/Objectjava/lang/Cloneable!    #*   3***   *  5*Y`*Y` rJava/src/java/ObjectArrayException.class0000644000176200001440000000067712256051764020162 0ustar liggesusers.    (Ljava/lang/String;)VCodeLineNumberTable SourceFileObjectArrayException.javajava/lang/StringBuffer array is of primitive type :   ObjectArrayExceptionjava/lang/Exception()Vappend,(Ljava/lang/String;)Ljava/lang/StringBuffer;toString()Ljava/lang/String;!  4*Y+  rJava/src/java/DummyPoint.java0000644000176200001440000000046512256051760016006 0ustar liggesusers public class DummyPoint implements Cloneable { public int x; public int y ; public DummyPoint(){ this( 0, 0 ) ; } public DummyPoint( int x, int y){ this.x = x ; this.y = y ; } public double getX(){ return (double)x ; } public void move(int x, int y){ this.x += x ; this.y += y ; } } rJava/src/java/RectangularArrayExamples.java0000644000176200001440000001275012256051760020646 0ustar liggesusers// :tabSize=2:indentSize=2:noTabs=false:folding=explicit:collapseFolds=1: /** * Utility class that makes example rectangular java arrays of 2 and 3 dimensions * for all primitive types, String and Point (as an example of array of non primitive object) */ public class RectangularArrayExamples { // {{{ Example 2d rect arrays public static int[][] getIntDoubleRectangularArrayExample(){ int[][] x = new int[5][2]; int k= 0; for( int j=0; j<2; j++){ for( int i=0; i<5; i++, k++){ x[i][j] = k ; } } return x; } public static boolean[][] getBooleanDoubleRectangularArrayExample(){ boolean[][] x = new boolean[5][2]; boolean current = false; for( int j=0; j<2; j++){ for( int i=0; i<5; i++, current = !current){ x[i][j] = current ; } } return x ; } public static byte[][] getByteDoubleRectangularArrayExample(){ byte[][] x = new byte[5][2]; int k= 0; for( int j=0; j<2; j++){ for( int i=0; i<5; i++, k++){ x[i][j] = (byte)k ; } } return x; } public static long[][] getLongDoubleRectangularArrayExample(){ long[][] x = new long[5][2]; int k= 0; for( int j=0; j<2; j++){ for( int i=0; i<5; i++, k++){ x[i][j] = (long)k ; } } return x; } public static short[][] getShortDoubleRectangularArrayExample(){ short[][] x = new short[5][2]; int k= 0; for( int j=0; j<2; j++){ for( int i=0; i<5; i++, k++){ x[i][j] = (short)k ; } } return x; } public static double[][] getDoubleDoubleRectangularArrayExample(){ double[][] x = new double[5][2]; int k= 0; for( int j=0; j<2; j++){ for( int i=0; i<5; i++, k++){ x[i][j] = k + 0.0 ; } } return x; } public static char[][] getCharDoubleRectangularArrayExample(){ char[][] x = new char[5][2]; int k= 0; for( int j=0; j<2; j++){ for( int i=0; i<5; i++, k++){ x[i][j] = (char)k ; } } return x; } public static float[][] getFloatDoubleRectangularArrayExample(){ float[][] x = new float[5][2]; int k= 0; for( int j=0; j<2; j++){ for( int i=0; i<5; i++, k++){ x[i][j] = k + 0.0f ; } } return x; } public static String[][] getStringDoubleRectangularArrayExample(){ String[][] x = new String[5][2]; int k= 0; for( int j=0; j<2; j++){ for( int i=0; i<5; i++, k++){ x[i][j] = "" + k ; } } return x; } public static DummyPoint[][] getDummyPointDoubleRectangularArrayExample(){ DummyPoint[][] x = new DummyPoint[5][2]; int k= 0; for( int j=0; j<2; j++){ for( int i=0; i<5; i++, k++){ x[i][j] = new DummyPoint(k,k) ; } } return x; } // }}} // {{{ Example 3d rect arrays public static int[][][] getIntTripleRectangularArrayExample(){ int[][][] x = new int[5][3][2]; int current = 0 ; for( int k=0; k<2; k++){ for( int j=0; j<3; j++){ for( int i=0; i<5; i++, current++){ x[i][j][k] = current ; } } } return x; } public static boolean[][][] getBooleanTripleRectangularArrayExample(){ boolean[][][] x = new boolean[5][3][2]; boolean current = false ; for( int k=0; k<2; k++){ for( int j=0; j<3; j++){ for( int i=0; i<5; i++, current= !current){ x[i][j][k] = current ; } } } return x; } public static byte[][][] getByteTripleRectangularArrayExample(){ byte[][][] x = new byte[5][3][2]; int current = 0 ; for( int k=0; k<2; k++){ for( int j=0; j<3; j++){ for( int i=0; i<5; i++, current++){ x[i][j][k] = (byte)current ; } } } return x; } public static long[][][] getLongTripleRectangularArrayExample(){ long[][][] x = new long[5][3][2]; int current = 0 ; for( int k=0; k<2; k++){ for( int j=0; j<3; j++){ for( int i=0; i<5; i++, current++){ x[i][j][k] = (long)current ; } } } return x; } public static short[][][] getShortTripleRectangularArrayExample(){ short[][][] x = new short[5][3][2]; int current = 0 ; for( int k=0; k<2; k++){ for( int j=0; j<3; j++){ for( int i=0; i<5; i++, current++){ x[i][j][k] = (short)current ; } } } return x; } public static double[][][] getDoubleTripleRectangularArrayExample(){ double[][][] x = new double[5][3][2]; int current = 0 ; for( int k=0; k<2; k++){ for( int j=0; j<3; j++){ for( int i=0; i<5; i++, current++){ x[i][j][k] = 0.0 + current ; } } } return x; } public static char[][][] getCharTripleRectangularArrayExample(){ char[][][] x = new char[5][3][2]; int current = 0 ; for( int k=0; k<2; k++){ for( int j=0; j<3; j++){ for( int i=0; i<5; i++, current++){ x[i][j][k] = (char)current ; } } } return x; } public static float[][][] getFloatTripleRectangularArrayExample(){ float[][][] x = new float[5][3][2]; int current = 0 ; for( int k=0; k<2; k++){ for( int j=0; j<3; j++){ for( int i=0; i<5; i++, current++){ x[i][j][k] = 0.0f + current ; } } } return x; } public static String[][][] getStringTripleRectangularArrayExample(){ String[][][] x = new String[5][3][2]; int current = 0 ; for( int k=0; k<2; k++){ for( int j=0; j<3; j++){ for( int i=0; i<5; i++, current++){ x[i][j][k] = ""+current ; } } } return x; } public static DummyPoint[][][] getDummyPointTripleRectangularArrayExample(){ DummyPoint[][][] x = new DummyPoint[5][3][2]; int current = 0 ; for( int k=0; k<2; k++){ for( int j=0; j<3; j++){ for( int i=0; i<5; i++, current++){ x[i][j][k] = new DummyPoint( current, current ) ; } } } return x; } // }}} } rJava/src/java/RJavaComparator.class0000644000176200001440000000171112256051764017117 0ustar liggesusers.6      !"# $ %& '()()VCodeLineNumberTablecompare'(Ljava/lang/Object;Ljava/lang/Object;)I Exceptions SourceFileRJavaComparator.java  *+java/lang/Number ,-java/lang/Double ./ 0 12java/lang/ComparableNotComparableException 3 14java/lang/ClassCastException 5RJavaComparatorjava/lang/Objectequals(Ljava/lang/Object;)ZgetClass()Ljava/lang/Class; doubleValue()D(D)V compareTo(Ljava/lang/Double;)I(Ljava/lang/Object;)V(Ljava/lang/Object;)I'(Ljava/lang/Object;Ljava/lang/Object;)V!* *+*;+4*+)Y*NY+:-* Y* + Y+ * + =N+ * t=: Y*+itw x > #2 B!I$Y%i(t/w)x+.,-0 rJava/src/java/RJavaClassLoader.java0000644000176200001440000004461512256051760017026 0ustar liggesusers// :tabSize=4:indentSize=4:noTabs=false:folding=explicit:collapseFolds=1: // {{{ imports import java.io.*; import java.io.File; import java.net.URL; import java.net.URLClassLoader; import java.util.HashMap; import java.util.Vector; import java.util.Enumeration; import java.util.Iterator; import java.util.StringTokenizer; import java.util.zip.*; // }}} /** * Class loader used internally by rJava * * The class manages the class paths and the native libraries (jri, ...) */ public class RJavaClassLoader extends URLClassLoader { // {{{ fields /** * path of RJava */ String rJavaPath ; /** * lib sub directory of rJava */ String rJavaLibPath; /** * map of libraries */ HashMap/**/ libMap; /** * The class path vector */ Vector/**/ classPath; /** * singleton */ public static RJavaClassLoader primaryLoader = null; /** * Print debug messages if is set to true */ public static boolean verbose = false; /** * Should the system class loader be used to resolve classes * as well as this class loader */ public boolean useSystem = true; // }}} // {{{ UnixFile class /** * Light extension of File that handles file separators and updates */ class UnixFile extends File { /** * cached "last time modified" stamp */ long lastModStamp; /** * Constructor. Modifies the path so that * the proper path separator is used (most useful on windows) */ public UnixFile(String fn) { super( u2w(fn) ) ; lastModStamp=0; } /** * @return whether the file modified since last time the update method was called */ public boolean hasChanged() { long curMod = lastModified(); return (curMod != lastModStamp); } /** * Cache the result of the lastModified stamp */ public void update() { lastModStamp = lastModified(); } } // }}} // {{{ UnixJarFile /** * Specialization of UnixFile that deals with jar files */ class UnixJarFile extends UnixFile { /** * The cached jar file */ private ZipFile zfile ; /** * common prefix for all URLs within this jar file */ private String urlPrefix ; public UnixJarFile( String filename ){ super( filename ); } /* @Override */ public void update(){ try { if (zfile != null){ zfile.close(); } zfile = new ZipFile( this ) ; } catch (Exception tryCloseX) {} /* time stamp */ super.update( ) ; } /** * Get an input stream for a resource contained in the jar file * * @param name file name of the resource within the jar file * @return an input stream representing the resouce if it exists or null */ public InputStream getResourceAsStream( String name ){ if (zfile==null || hasChanged()) { update(); } try { if (zfile == null) return null; ZipEntry e = zfile.getEntry(name); if (e != null) return zfile.getInputStream(e); } catch(Exception e) { if (verbose) System.err.println("RJavaClassLoader$UnixJarFile: exception: "+e.getMessage()); } return null; } public URL getResource(String name ){ if( zfile == null || zfile.getEntry( name ) == null ){ return null ; } URL u = null ; if( urlPrefix == null ){ try{ urlPrefix = "jar:" + toURL().toString() + "!" ; } catch( java.net.MalformedURLException ex){ } catch( java.io.IOException ex){ } } try{ u = new URL( urlPrefix + name ) ; } catch( java.net.MalformedURLException ex ){ /* not to worry */ } return u ; } } // }}} // {{{ UnixDirectory class /** * Specialization of UnixFile representing a directory */ /* it is not really a specialization but makes possible to dispatch on instanceof*/ class UnixDirectory extends UnixFile { public UnixDirectory( String dirname ){ super( dirname ) ; } } // }}} // {{{ getPrimaryLoader /** * Returns the singleton instance of RJavaClassLoader */ public static RJavaClassLoader getPrimaryLoader() { return primaryLoader; } // }}} // {{{ constructor /** * Constructor. The first time an RJavaClassLoader is created, it is * cached as the primary loader. * * @param path path of the rJava package * @param libpath lib sub directory of the rJava package */ public RJavaClassLoader(String path, String libpath) { super(new URL[] {}); // respect rJava.debug level String rjd = System.getProperty("rJava.debug"); if (rjd != null && rjd.length() > 0 && !rjd.equals("0")) verbose = true; if (verbose) System.out.println("RJavaClassLoader(\""+path+"\",\""+libpath+"\")"); if (primaryLoader==null) { primaryLoader = this; if (verbose) System.out.println(" - primary loader"); } else { if (verbose) System.out.println(" - NOT primrary (this="+this+", primary="+primaryLoader+")"); } libMap = new HashMap/**/(); classPath = new Vector/**/(); classPath.add(new UnixDirectory(path+"/java")); rJavaPath = path; rJavaLibPath = libpath; /* load the rJava library */ UnixFile so = new UnixFile(rJavaLibPath+"/rJava.so"); if (!so.exists()) so = new UnixFile(rJavaLibPath+"/rJava.dll"); if (so.exists()) libMap.put("rJava", so); /* load the jri library */ UnixFile jri = new UnixFile(path+"/jri/libjri.so"); String rarch = System.getProperty("r.arch"); if (rarch != null && rarch.length()>0) { UnixFile af = new UnixFile(path+"/jri"+rarch+"/libjri.so"); if (af.exists()) jri = af; else { af = new UnixFile(path+"/jri"+rarch+"/jri.dll"); if (af.exists()) jri = af; } } if (!jri.exists()) jri = new UnixFile(path+"/jri/libjri.jnilib"); if (!jri.exists()) jri = new UnixFile(path+"/jri/jri.dll"); if (jri.exists()) { libMap.put("jri", jri); if (verbose) System.out.println(" - registered JRI: "+jri); } /* if we are the primary loader, make us the context loader so projects that rely on the context loader pick us */ if (primaryLoader == this) Thread.currentThread().setContextClassLoader(this); if (verbose) { System.out.println("RJavaClassLoader initialized.\n\nRegistered libraries:"); for(Iterator entries = libMap.keySet().iterator(); entries.hasNext(); ) { Object key = entries.next(); System.out.println(" " + key + ": '" + libMap.get(key) + "'"); } System.out.println("\nRegistered class paths:"); for (Enumeration e = classPath.elements() ; e.hasMoreElements() ;) System.out.println(" '"+e.nextElement()+"'"); System.out.println("\n-- end of class loader report --"); } } // }}} // {{{ classNameToFile /** * convert . to / */ String classNameToFile(String cls) { return cls.replace('.','/'); } // }}} // {{{ findClass protected Class findClass(String name) throws ClassNotFoundException { Class cl = null; if (verbose) System.out.println(""+this+".findClass("+name+")"); if ("RJavaClassLoader".equals(name)) return getClass(); // {{{ use the usual method of URLClassLoader if (useSystem) { try { cl = super.findClass(name); if (cl != null) { if (verbose) System.out.println("RJavaClassLoader: found class "+name+" using URL loader"); return cl; } } catch (Exception fnf) { if (verbose) System.out.println(" - URL loader did not find it: " + fnf); } } if (verbose) System.out.println("RJavaClassLoader.findClass(\""+name+"\")"); // }}} // {{{ iterate through the elements of the class path InputStream ins = null; Exception defineException = null; Enumeration/**/ e = classPath.elements() ; while( e.hasMoreElements() ){ UnixFile cp = (UnixFile) e.nextElement(); if (verbose) System.out.println(" - trying class path \""+cp+"\""); try { ins = null; /* a file - assume it is a jar file */ if (cp instanceof UnixJarFile){ ins = ((UnixJarFile)cp).getResourceAsStream( classNameToFile(name) + ".class" ) ; if (verbose) System.out.println(" JAR file, can get '" + classNameToFile(name) + "'? " + ((ins == null) ? "NO" : "YES")); } else if ( cp instanceof UnixDirectory ){ UnixFile class_f = new UnixFile(cp.getPath()+"/"+classNameToFile(name)+".class"); if (class_f.isFile() ) { ins = new FileInputStream(class_f); } if (verbose) System.out.println(" Directory, can get '" + class_f + "'? " + ((ins == null) ? "NO" : "YES")); } /* some comments on the following : we could call ZipEntry.getSize in case of a jar file to find out the size of the byte[] directly also ByteBuffer seems more efficient, but the ByteBuffer class is java >= 1.4 and the defineClass method that uses the class is java >= 1.5 */ if (ins != null) { int al = 128*1024; byte fc[] = new byte[al]; int n = ins.read(fc); int rp = n; if( verbose ) System.out.println(" loading class file, initial n = "+n); while (n > 0) { if (rp == al) { int nexa = al*2; if (nexa<512*1024) nexa=512*1024; byte la[] = new byte[nexa]; System.arraycopy(fc, 0, la, 0, al); fc = la; al = nexa; } n = ins.read(fc, rp, fc.length-rp); if( verbose ) System.out.println(" next n = "+n+" (rp="+rp+", al="+al+")"); if (n>0) rp += n; } ins.close(); n = rp; if (verbose) System.out.println("RJavaClassLoader: loaded class "+name+", "+n+" bytes"); try { cl = defineClass(name, fc, 0, n); } catch (Exception dce) { // we want to save this one so we can pass it on defineException = dce; break; } if (verbose) System.out.println(" defineClass('" + name +"') returned " + cl); // System.out.println(" - class = "+cl); return cl; } } catch (Exception ex) { // System.out.println(" * won't work: "+ex.getMessage()); } } // }}} if (defineException != null) // we bailed out on class interpretation, re-throw it throw (new ClassNotFoundException("Class not found - candidate class binary found but could not be loaded", defineException)); // giving up if( verbose ) System.out.println(" >> ClassNotFoundException "); if (cl == null) { throw (new ClassNotFoundException()); } return cl; } // }}} // {{{ findResource public URL findResource(String name) { if (verbose) System.out.println("RJavaClassLoader: findResource('"+name+"')"); // {{{ use the standard way if (useSystem) { try { URL u = super.findResource(name); if (u != null) { if (verbose) System.out.println("RJavaClassLoader: found resource in "+u+" using URL loader."); return u; } } catch (Exception fre) { } } // }}} // {{{ iterate through the classpath if (verbose) System.out.println(" - resource not found with URL loader, trying alternative"); Enumeration/**/ e = classPath.elements() ; while( e.hasMoreElements()) { UnixFile cp = (UnixFile) e.nextElement(); try { /* is a file - assume it is a jar file */ if (cp instanceof UnixJarFile ) { URL u = ( (UnixJarFile)cp ).getResource( name ) ; if (u != null) { if (verbose) System.out.println(" - found in a JAR file, URL "+u); return u; } } else if(cp instanceof UnixDirectory ) { UnixFile res_f = new UnixFile(cp.getPath()+"/"+name); if (res_f.isFile()) { if (verbose) System.out.println(" - find as a file: "+res_f); return res_f.toURL(); } } } catch (Exception iox) { } } // }}} return null; } // }}} // {{{ addRLibrary /** add a library to path mapping for a native library */ public void addRLibrary(String name, String path) { libMap.put(name, new UnixFile(path)); } // }}} // {{{ addClassPath /** * adds an entry to the class path */ public void addClassPath(String cp) { UnixFile f = new UnixFile(cp); // use the URLClassLoader if (useSystem) { try { addURL(f.toURL()); if (verbose) System.out.println("RJavaClassLoader: added '" + cp + "' to the URL class path loader"); //return; // we need to add it anyway so it appears in .jclassPath() } catch (Exception ufe) { } } UnixFile g = null ; if( f.isFile() && (f.getName().endsWith(".jar") || f.getName().endsWith(".JAR"))) { g = new UnixJarFile(cp) ; if (verbose) System.out.println("RJavaClassLoader: adding Java archive file '"+cp+"' to the internal class path"); } else if( f.isDirectory() ){ g = new UnixDirectory(cp) ; if (verbose) System.out.println("RJavaClassLoader: adding class directory '"+cp+"' to the internal class path"); } else if (verbose) System.err.println(f.exists() ? ("WARNING: the path '"+cp+"' is neither a directory nor a .jar file, it will NOT be added to the internal class path!") : ("WARNING: the path '"+cp+"' does NOT exist, it will NOT be added to the internal class path!")); if (g != null && !classPath.contains(g)) { // this is the real meat - add it to our internal list classPath.add(g); // this is just cosmetics - it doesn't really have any meaning System.setProperty("java.class.path", System.getProperty("java.class.path")+File.pathSeparator+g.getPath()); } } /** * adds several entries to the class path */ public void addClassPath(String[] cp) { int i = 0; while (i < cp.length) addClassPath(cp[i++]); } // }}} // {{{ getClassPath /** * @return the array of class paths used by this class loader */ public String[] getClassPath() { int j = classPath.size(); String[] s = new String[j]; int i = 0; while (i < j) { s[i] = ((UnixFile) classPath.elementAt(i)).getPath(); i++; } return s; } // }}} // {{{ findLibrary protected String findLibrary(String name) { if (verbose) System.out.println("RJavaClassLoader.findLibrary(\""+name+"\")"); //if (name.equals("rJava")) // return rJavaLibPath+"/"+name+".so"; UnixFile u = (UnixFile) libMap.get(name); String s = null; if (u!=null && u.exists()) s=u.getPath(); if (verbose) System.out.println(" - mapping to "+((s==null)?"":s)); return s; } // }}} // {{{ bootClass /** * Boots the specified method of the specified class * * @param cName class to boot * @param mName method to boot (typically main). The method must take a String[] as parameter * @param args arguments to pass to the method */ public void bootClass(String cName, String mName, String[] args) throws java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException, java.lang.NoSuchMethodException, java.lang.ClassNotFoundException { Class c = findClass(cName); resolveClass(c); java.lang.reflect.Method m = c.getMethod(mName, new Class[] { String[].class }); m.invoke(null, new Object[] { args }); } // }}} // {{{ setDebug /** * Set the debug level. At the moment, there is only verbose (level>0) * or quiet * * @param level debug level. verbose (>0), quiet otherwise */ public static void setDebug(int level) { verbose=(level>0); } // }}} // {{{ u2w /** * Utility to convert paths for windows. Converts / to the path separator in use * * @param fn file name */ public static String u2w(String fn) { return (File.separatorChar != '/') ? fn.replace('/', File.separatorChar) : fn ; } // }}} // {{{ main /** * main method * *

This uses the system properties: *

    *
  • rjava.path : path of the rJava package
  • *
  • rjava.lib : lib sub directory of the rJava package
  • *
  • main.class : main class to "boot", assumes Main if not specified
  • *
  • rjava.class.path : set of paths to populate the initiate the class path
  • *
*

* *

and boots the "main" method of the specified main.class, * passing the args down to the booted class

* *

This makes sure R and rJava are known by the class loader

*/ public static void main(String[] args) { String rJavaPath = System.getProperty("rjava.path"); if (rJavaPath == null) { System.err.println("ERROR: rjava.path is not set"); System.exit(2); } String rJavaLib = System.getProperty("rjava.lib"); if (rJavaLib == null) { // it is not really used so far, just for rJava.so, so we can guess rJavaLib = rJavaPath + File.separator + "libs"; } RJavaClassLoader cl = new RJavaClassLoader(u2w(rJavaPath), u2w(rJavaLib)); String mainClass = System.getProperty("main.class"); if (mainClass == null || mainClass.length()<1) { System.err.println("WARNING: main.class not specified, assuming 'Main'"); mainClass = "Main"; } String classPath = System.getProperty("rjava.class.path"); if (classPath != null) { StringTokenizer st = new StringTokenizer(classPath, File.pathSeparator); while (st.hasMoreTokens()) { String dirname = u2w(st.nextToken()); cl.addClassPath(dirname); } } try { cl.bootClass(mainClass, "main", args); } catch (Exception ex) { System.err.println("ERROR: while running main method: "+ex); ex.printStackTrace(); } } // }}} //----- tools ----- // {{{ RJavaObjectInputStream class class RJavaObjectInputStream extends ObjectInputStream { public RJavaObjectInputStream(InputStream in) throws IOException { super(in); } protected Class resolveClass(ObjectStreamClass desc) throws ClassNotFoundException { return Class.forName(desc.getName(), false, RJavaClassLoader.getPrimaryLoader()); } } // }}} // {{{ toByte /** * Serialize an object to a byte array. (code by CB) * * @param object object to serialize * @return byte array that represents the object * @throws Exception */ public static byte[] toByte(Object object) throws Exception { ByteArrayOutputStream os = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream((OutputStream) os); oos.writeObject(object); oos.close(); return os.toByteArray(); } // }}} // {{{ toObject /** * Deserialize an object from a byte array. (code by CB) * * @param byteArray * @return the object that is represented by the byte array * @throws Exception */ public Object toObject(byte[] byteArray) throws Exception { InputStream is = new ByteArrayInputStream(byteArray); RJavaObjectInputStream ois = new RJavaObjectInputStream(is); Object o = (Object) ois.readObject(); ois.close(); return o; } // }}} // {{{ toObjectPL /** * converts the byte array into an Object using the primary RJavaClassLoader */ public static Object toObjectPL(byte[] byteArray) throws Exception{ return RJavaClassLoader.getPrimaryLoader().toObject(byteArray); } // }}} } rJava/src/java/RectangularArrayExamples.class0000644000176200001440000001034112256051765021031 0ustar liggesusers.r NOPQRSTUVWX NY Z [ \]^ _`abcdefghijk()VCodeLineNumberTable#getIntDoubleRectangularArrayExample()[[I'getBooleanDoubleRectangularArrayExample()[[Z$getByteDoubleRectangularArrayExample()[[B$getLongDoubleRectangularArrayExample()[[J%getShortDoubleRectangularArrayExample()[[S&getDoubleDoubleRectangularArrayExample()[[D$getCharDoubleRectangularArrayExample()[[C%getFloatDoubleRectangularArrayExample()[[F&getStringDoubleRectangularArrayExample()[[Ljava/lang/String;*getDummyPointDoubleRectangularArrayExample()[[LDummyPoint;#getIntTripleRectangularArrayExample()[[[I'getBooleanTripleRectangularArrayExample()[[[Z$getByteTripleRectangularArrayExample()[[[B$getLongTripleRectangularArrayExample()[[[J%getShortTripleRectangularArrayExample()[[[S&getDoubleTripleRectangularArrayExample()[[[D$getCharTripleRectangularArrayExample()[[[C%getFloatTripleRectangularArrayExample()[[[F&getStringTripleRectangularArrayExample()[[[Ljava/lang/String;*getDummyPointTripleRectangularArrayExample()[[[LDummyPoint; SourceFileRectangularArrayExamples.java ![[I[[Z[[B[[J[[S[[D[[C[[F[[Ljava/lang/String;java/lang/StringBuffer lm ln op[[LDummyPoint; DummyPoint q[[[I[[[Z[[[B[[[J[[[S[[[D[[[C[[[F[[[Ljava/lang/String;[[[LDummyPoint;RectangularArrayExamplesjava/lang/Objectappend,(Ljava/lang/String;)Ljava/lang/StringBuffer;(I)Ljava/lang/StringBuffer;toString()Ljava/lang/String;(II)V! !"*# $%"b.K<=>*2O*#"  & , &'"i5K<=&>*2T<*#" -3 ()"c/K<= >*2T*#"!" #$%$'#-( *+"c/K<= >*2P*#",- ./0/'.-3 ,-"c/K<= >*2V*#"78 9:;:'9-> ./"e1K<=">*2cR*#"BC DEF E)D/I 01"c/K<= >*2U*#"MN OPQP'O-T 23"e1 K<=">*2 bQ*#"XY Z[\ [)Z/_ 45"t@ K<=1>$*2 Y  S݄*#"cd efg/f8e>j 67"j6K<='>*2YS*#"no pqr%q.p4u 89"}AK<=1>$6*22O݄*#* {| }~!*3~9}? :;"HK<=8>+6*22T<ք*#*  !*:@F <="~BK<=2>%6*22T܄*#*  !+4:@ >?"~BK<=2>%6*22P܄*#*  !+4:@ @A"~BK<=2>%6*22V܄*#*  !+4:@ BC"DK<=4>'6*22cRڄ*#*  !-6<B DE"~BK<=2>%6*22U܄*#*  !+4:@ FG"DK<=4>'6*22 bQڄ*#*  !-6<B HI"SK<=C>66'*22 Y  Sل˄*#*  !<EKQ JK"IK<=9>,6*22YSՄ*#*  !2;AGLMrJava/src/java/RJavaImport.class0000644000176200001440000000612612256051764016267 0ustar liggesusers. 3Q 1RS Q 1TU Q 1V 1W 1X YZ[ Q\ ]^_` ab c de fg fhi ajk fl mn op qrst u 1vw x y 1z f{ |m |}~ |  1DEBUGZimportedPackagesLjava/util/Vector;cacheLjava/util/Map;loaderLjava/lang/ClassLoader;(Ljava/lang/ClassLoader;)VCodeLineNumberTablelookup%(Ljava/lang/String;)Ljava/lang/Class;lookup_exists(Ljava/lang/String;)Zexists_ importPackage(Ljava/lang/String;)V([Ljava/lang/String;)VgetKnownClasses()[Ljava/lang/String;4(Ljava/lang/String;Ljava/util/Set;)Ljava/lang/Class;()V SourceFileRJavaImport.java =N ;<java/util/Vector 78java/util/HashMap 9: CB 56 java/lang/StringBuffer [J] lookup( ' ' ) =  '  H java/lang/String Bjava/lang/Exception  [J]  packages . [J] trying class :  [JE] FE [J] exists( ' GH  ! [J] getKnownClasses().length =   RJavaImport ABjava/lang/Objectjava/io/Serializablejava/lang/SystemoutLjava/io/PrintStream;append,(Ljava/lang/String;)Ljava/lang/StringBuffer;java/lang/ClassgetName()Ljava/lang/String;toStringjava/io/PrintStreamprintln java/util/Map containsKey(Ljava/lang/Object;)Zget&(Ljava/lang/Object;)Ljava/lang/Object;forNameput8(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;size()I(I)Ljava/lang/StringBuffer;(I)Ljava/lang/Object; getMessage(Z)Ljava/lang/StringBuffer;addkeySet()Ljava/util/Set; java/util/SettoArray(([Ljava/lang/Object;)[Ljava/lang/Object;iterator()Ljava/util/Iterator;java/util/IteratorhasNext()Znext()Ljava/lang/Object;!134 56789:;< =>?H **+*Y*Y@23 456AB?sS*+ M H Y +, Y ,,@@AQBCB?M*+*+N-:N+MN,*++W,*> ! Y 6* : Y !+:  Y "M(: Y #$,*+,W,l%&',/{@nFHJK#L&M'T,U0V4W@XB[J\n]r^{`abcfdeghi^ mDE?P0*+%= % Y &+'@tu.vFE?9*+*+ @ z|GH?& *+(W@  GI?:=+*+2)@JK?l@**L++=N+-,W  Y ---@ > AL?]-+.N-/-01:*2M,,@"(+MN? @OPrJava/src/java/RectangularArraySummary.class0000644000176200001440000000707212256051765020717 0ustar liggesusers. KLMN O P 'Q &R ST &U SV &W XY KZ S[ &\ &] &^ &_` &a &b &c &d &e &f &gh i Kj kl &mn o &pq &r KstulengthItypeNameLjava/lang/String; isprimitiveZ componentTypeLjava/lang/Class;class$java$lang$Comparable Synthetic(Ljava/lang/Object;[I)VCodeLineNumberTable Exceptionsv(Ljava/lang/Object;I)Vmin(Z)Ljava/lang/Object;maxrange(Z)[Ljava/lang/Object;(([Ljava/lang/Object;Z)Ljava/lang/Object;)([Ljava/lang/Object;Z)[Ljava/lang/Object;checkComparableObjects()VcontainsComparableObjects()Zsmaller'(Ljava/lang/Object;Ljava/lang/Object;)Zbiggerclass$%(Ljava/lang/String;)Ljava/lang/Class; SourceFileRectangularArraySummary.javaw xH java/lang/ClassNotFoundExceptionjava/lang/NoClassDefFoundError yz 2{ 2| }~ *+ ,- ./ @A 23 [Ljava/lang/Object; 9> C DE ;> FE <?java/lang/Comparable  BCNotComparableException 2{ 0/java.lang.Comparable GH RectangularArraySummaryRJavaArrayIteratorNotAnArrayExceptionjava/lang/ClassforName getMessage()Ljava/lang/String;(Ljava/lang/String;)V([I)VarrayLjava/lang/Object;RJavaArrayToolsgetObjectTypeName&(Ljava/lang/Object;)Ljava/lang/String;isPrimitiveTypeName(Ljava/lang/String;)Zjava/lang/ObjectgetClass()Ljava/lang/Class;getClassLoader()Ljava/lang/ClassLoader;getClassForSignature<(Ljava/lang/String;Ljava/lang/ClassLoader;)Ljava/lang/Class; dimensions[IhasNextnext()Ljava/lang/Object; compareTo(Ljava/lang/Object;)IgetComponentTypejava/lang/reflect/Array newInstance&(Ljava/lang/Class;I)Ljava/lang/Object;isAssignableFrom(Ljava/lang/Class;)Z!&'()*+,-./0/1 234t8*,*+*+ ** ** + N*/25" /3 7!67 284) *+ YO5 $ %67 9:4b* M6***6*N-  -M6-,-M,5B,- / 134&8-9<:@;F=K>M?S@[A`E;:4b* M6***6*N-  -M6-,-M,5BOP S UWX&\-]<^@_FaKbMcSd[e`i<=4|* **M6*P*N-  -M6-2,2 ,-2S-2,2,-2S,5Jst wx!{#}&-<@FKMS_eqz 9>4I*=N669*2: $ N6-N-5:"'*0>AG ;>4I*=N669*2: $ N6-N-5:"'*0>AG <?4y*=* N66Y*2: D-S-S6--2-S-2-S-5F!',27<AGW\lqw@A40* Y* !5 6 BC45"#$Y""*%5 DE4+*+5 FE4+*+5GH42*LY+51IJrJava/src/java/RectangularArrayBuilder.java0000644000176200001440000001462512256051760020461 0ustar liggesusers// :tabSize=2:indentSize=2:noTabs=false:folding=explicit:collapseFolds=1: import java.lang.reflect.Array ; /** * Builds rectangular java arrays */ public class RectangularArrayBuilder extends RJavaArrayIterator { // {{{ constructors /** * constructor * * @param payload one dimensional array * @param dimensions target dimensions * @throws NotAnArrayException if payload is not an array */ public RectangularArrayBuilder( Object payload, int[] dimensions) throws NotAnArrayException, ArrayDimensionException { super( dimensions ) ; if( !RJavaArrayTools.isArray(payload) ){ throw new NotAnArrayException( payload.getClass() ) ; } if( !RJavaArrayTools.isSingleDimensionArray(payload)){ throw new ArrayDimensionException( "not a single dimension array : " + payload.getClass() ) ; } if( dimensions.length == 1 ){ array = payload ; } else{ String typeName = RJavaArrayTools.getObjectTypeName( payload ); Class clazz = null ; try{ clazz = RJavaArrayTools.getClassForSignature( typeName, payload.getClass().getClassLoader() ); } catch( ClassNotFoundException e){/* should not happen */} array = Array.newInstance( clazz , dimensions ) ; if( typeName.equals( "I" ) ){ fill_int( (int[])payload ) ; } else if( typeName.equals( "Z" ) ){ fill_boolean( (boolean[])payload ) ; } else if( typeName.equals( "B" ) ){ fill_byte( (byte[])payload ) ; } else if( typeName.equals( "J" ) ){ fill_long( (long[])payload ) ; } else if( typeName.equals( "S" ) ){ fill_short( (short[])payload ) ; } else if( typeName.equals( "D" ) ){ fill_double( (double[])payload ) ; } else if( typeName.equals( "C" ) ){ fill_char( (char[])payload ) ; } else if( typeName.equals( "F" ) ){ fill_float( (float[])payload ) ; } else{ fill_Object( (Object[])payload ) ; } } } public RectangularArrayBuilder( Object payload, int length ) throws NotAnArrayException, ArrayDimensionException{ this( payload, new int[]{ length } ) ; } // java < 1.5 kept happy public RectangularArrayBuilder(int x , int[] dim ) throws NotAnArrayException { throw new NotAnArrayException("primitive type : int ") ; } public RectangularArrayBuilder(boolean x, int[] dim ) throws NotAnArrayException { throw new NotAnArrayException("primitive type : boolean ") ; } public RectangularArrayBuilder(byte x , int[] dim ) throws NotAnArrayException { throw new NotAnArrayException("primitive type : byte ") ; } public RectangularArrayBuilder(long x , int[] dim ) throws NotAnArrayException { throw new NotAnArrayException("primitive type : long ") ; } public RectangularArrayBuilder(short x , int[] dim ) throws NotAnArrayException { throw new NotAnArrayException("primitive type : short ") ; } public RectangularArrayBuilder(double x , int[] dim ) throws NotAnArrayException { throw new NotAnArrayException("primitive type : double ") ; } public RectangularArrayBuilder(char x , int[] dim ) throws NotAnArrayException { throw new NotAnArrayException("primitive type : char ") ; } public RectangularArrayBuilder(float x , int[] dim ) throws NotAnArrayException { throw new NotAnArrayException("primitive type : float ") ; } public RectangularArrayBuilder(int x , int length ) throws NotAnArrayException { throw new NotAnArrayException("primitive type : int ") ; } public RectangularArrayBuilder(boolean x, int length ) throws NotAnArrayException { throw new NotAnArrayException("primitive type : boolean ") ; } public RectangularArrayBuilder(byte x , int length ) throws NotAnArrayException { throw new NotAnArrayException("primitive type : byte ") ; } public RectangularArrayBuilder(long x , int length ) throws NotAnArrayException { throw new NotAnArrayException("primitive type : long ") ; } public RectangularArrayBuilder(short x , int length ) throws NotAnArrayException { throw new NotAnArrayException("primitive type : short ") ; } public RectangularArrayBuilder(double x , int length ) throws NotAnArrayException { throw new NotAnArrayException("primitive type : double ") ; } public RectangularArrayBuilder(char x , int length ) throws NotAnArrayException { throw new NotAnArrayException("primitive type : char ") ; } public RectangularArrayBuilder(float x , int length ) throws NotAnArrayException { throw new NotAnArrayException("primitive type : float ") ; } // }}} // {{{ fill_** private void fill_int( int[] payload ){ int k; while( hasNext() ){ int[] current = (int[])next() ; k = start ; for( int j=0; j?@ T AB AC DEF GHIJ KLMNODummyNonStaticClass InnerClasses TestException ExampleClassbogusI staticbogusxstatic_xclass$DummyPointLjava/lang/Class; Syntheticclass$RJavaTools_Testclass$java$lang$Objectclass$java$lang$Integer#class$RJavaTools_Test$TestException)class$RJavaTools_Test$DummyNonStaticClassclass$java$lang$String"class$RJavaTools_Test$ExampleClass()VCodeLineNumberTablegetBogus()IgetStaticBogusgetX getStaticXsetX(Ljava/lang/Integer;)Vmain([Ljava/lang/String;)Vruntests Exceptionsfails"(LRJavaTools_Test$TestException;)Vsuccess getfieldnamesgetmethodnamesgetcompletionnameisstatic constructorsmethodshasfield hasmethodhasclassgetclass classhasfield classhasclassclasshasmethodgetstaticfieldsgetstaticmethodsgetstaticclasses invokemethodgetfieldtypenameclass$%(Ljava/lang/String;)Ljava/lang/Class; SourceFileRJavaTools_Test.java PK java/lang/ClassNotFoundExceptionjava/lang/NoClassDefFoundError QR &S &'    T U+ 3'RJavaTools_Test$TestException 56V WX YZ!Testing RJavaTools.getConstructor[ \S <' 7' Testing RJavaTools.classHasField B'!Testing RJavaTools.classHasMethod D' Testing RJavaTools.classHasClass C'Testing RJavaTools.hasField >'Testing RJavaTools.hasClass @'Testing RJavaTools.getClass A'Testing RJavaTools.hasMethod ?'Testing RJavaTools.isStatic ;'$Testing RJavaTools.getCompletionName :' Testing RJavaTools.getFieldNames 8'!Testing RJavaTools.getMethodNames 9'"Testing RJavaTools.getStaticFields E'#Testing RJavaTools.getStaticMethods F'#Testing RJavaTools.getStaticClasses G'Testing RJavaTools.invokeMethod H'#Testing RJavaTools.getFieldTypeName I'Testing RJavaTools.getMethodNOT YET AVAILABLETesting RJavaTools.newInstance ]Z ^'FAILEDPASSED& * getFieldNames(DummyPoint, false) _S  DummyPoint JK` ab,getFieldNames(DummyPoint, false).length != 2 &S cdy6getFieldNames(DummyPoint, false).length != c('x','y')  : ok & * getFieldNames(DummyPoint, true )0getFieldNames(DummyPoint, true ) != character(0)+ * getFieldNames(RJavaTools_Test, true ) RJavaTools_Test1getFieldNames(RJavaTools_Test, true ).length != 17getFieldNames(RJavaTools_Test, true )[0] != 'static_x' , * getFieldNames(RJavaTools_Test, false )2getFieldNames(RJavaTools_Test, false ).length != 2=getFieldNames(RJavaTools_Test, false ) != c('x', 'static_x') + * getMethodNames(RJavaTools_Test, true) ebjava/lang/StringBuffer3getMethodNames(RJavaTools_Test, true).length != 3 ( fg fh) iRjava/lang/String getStaticX()main( runtests()PgetMethodNames(RJavaTools_Test, true) != {'getStaticX()','main(', 'runtests()' }" * getMethodNames(Object, true)  java.lang.Object*getMethodNames(Object, true).length != 0 (, * getMethodNames(RJavaTools_Test, false)getX()setX(HgetMethodNames(RJavaTools_Test, false) did not contain expected methods * * getCompletionName(RJavaTools_Test.x) jk lm,getCompletionName(RJavaTools_Test.x) != 'x'  == 'x' : ok java/lang/NoSuchFieldException1 * getCompletionName(RJavaTools_Test.static_x):getCompletionName(RJavaTools_Test.static_x) != 'static_x'  == 'static_x' : ok 0 * getCompletionName(RJavaTools_Test.getX() )[Ljava/lang/Class; no8getCompletionName(RJavaTools_Test.getX() ) != ''getX()'  == 'getX()' : ok java/lang/NoSuchMethodException9 * getCompletionName(RJavaTools_Test.setX( Integer ) )java/lang/Class !java.lang.Integer=getCompletionName(RJavaTools_Test.setX(Integer) ) != 'setX('  == 'setX(' : ok ! * isStatic(RJavaTools_Test.x) pq#isStatic(RJavaTools_Test.x) == true = false : ok ' * isStatic(RJavaTools_Test.getX() )*isStatic(RJavaTools_Test.getX() ) == false( * isStatic(RJavaTools_Test.static_x)+isStatic(RJavaTools_Test.static_x) == false = true : ok - * isStatic(RJavaTools_Test.getStaticX() )0isStatic(RJavaTools_Test.getStaticX() ) == false. * isStatic(RJavaTools_Test.TestException ) " pr0isStatic(RJavaTools_Test.TestException) == false4 * isStatic(RJavaTools_Test.DummyNonStaticClass ) ##RJavaTools_Test$DummyNonStaticClass5isStatic(RJavaTools_Test.DummyNonStaticClass) == true$ * getConstructor( String, null ) $java.lang.String[Z stjava/lang/ExceptiongetConstructor( String, null )1 * getConstructor( Integer, { String.class } )+getConstructor( Integer, { String.class } )% * getConstructor( Integer, null )6getConstructor( Integer, null ) did not generate error -> exception : ok RJavaTools_Test$ExampleClass &uM * getConstructor( ExampleClass, {Object.class, Object.class, boolean}) : %v wQgetConstructor( ExampleClass, {Object.class, Object.class, boolean}) : exception  ok) java> DummyPoint p = new DummyPoint() * hasField( p, 'x' ) xy% hasField( DummyPoint, 'x' ) == false true : ok% * hasField( p, 'iiiiiiiiiiiii' )  iiiiiiiiiiiii0 hasField( DummyPoint, 'iiiiiiiiiiiii' ) == true false : ok * testing a private field ( hasField returned true on private field * hasMethod( p, 'move' ) move zy( hasField( DummyPoint, 'move' ) == false& * hasMethod( p, 'iiiiiiiiiiiii' ) , hasMethod( Point, 'iiiiiiiiiiiii' ) == true * testing a private method * hasMethod returned true on private method3 * hasClass( RJavaTools_Test, 'TestException' ) {y6 hasClass( RJavaTools_Test, 'TestException' ) == false true : ok9 * hasClass( RJavaTools_Test, 'DummyNonStaticClass' ) < hasClass( RJavaTools_Test, 'DummyNonStaticClass' ) == false9 * getClass( RJavaTools_Test, 'TestException', true ) |}D getClass( RJavaTools_Test, 'TestException', true ) != TestException : ok? * getClass( RJavaTools_Test, 'DummyNonStaticClass', true ) A getClass( RJavaTools_Test, 'DummyNonStaticClass', true ) != null@ * getClass( RJavaTools_Test, 'DummyNonStaticClass', false ) > * classHasClass( RJavaTools_Test, 'TestException', true ) ~A classHasClass( RJavaTools_Test, 'TestException', true ) == falseD * classHasClass( RJavaTools_Test, 'DummyNonStaticClass', true ) F classHasClass( RJavaTools_Test, 'DummyNonStaticClass', true ) == trueE * classHasClass( RJavaTools_Test, 'DummyNonStaticClass', false ) H classHasClass( RJavaTools_Test, 'DummyNonStaticClass', false ) == false7 * classHasMethod( RJavaTools_Test, 'getX', false ) : classHasMethod( RJavaTools_Test, 'getX', false ) == false= * classHasMethod( RJavaTools_Test, 'getStaticX', false ) @ classHasMethod( RJavaTools_Test, 'getStaticX', false ) == false6 * classHasMethod( RJavaTools_Test, 'getX', true ) L classHasMethod( RJavaTools_Test, 'getX', true ) == true (non static method)< * classHasMethod( RJavaTools_Test, 'getStaticX', true ) H classHasMethod( RJavaTools_Test, 'getStaticX', true ) == false (static); * classHasMethod( RJavaTools_Test, 'getBogus', false ) N classHasMethod( RJavaTools_Test, 'getBogus', false ) == true (private method)@ * classHasMethod( RJavaTools_Test, 'getStaticBogus', true ) M classHasMethod( RJavaTools_Test, 'getBogus', true ) == true (private method)) * getStaticFields( RJavaTools_Test ) / getStaticFields( RJavaTools_Test ).length != 1 R4 getStaticFields( RJavaTools_Test )[0] != 'static_x' * getStaticFields( Object ) " getStaticFields( Object ) != null* * getStaticMethods( RJavaTools_Test ) 0 getStaticMethods( RJavaTools_Test ).length != 2M getStaticMethods( RJavaTools_Test ) != c('main', 'getStaticX', 'runtests' ) ! * getStaticMethods( Object ) # getStaticMethods( Object ) != null! * getStaticClasses( Object ) # getStaticClasses( Object ) != null* * getStaticClasses( RJavaTools_Test ) 0 getStaticClasses( RJavaTools_Test ).length != 1E getStaticClasses( RJavaTools_Test ) != RJavaTools_Test.TestException. * testing enforcing accessibility (bug# 128)java/util/HashMap   |iterator[Ljava/lang/Object; java/lang/Throwable!not able to enforce accessibility% * getFieldTypeName( DummyPoint, x ) int(getFieldTypeName( DummyPoint, x ) != int: okjava/lang/ObjectforName getMessage()Ljava/lang/String;(Ljava/lang/String;)Vjava/lang/IntegerintValuejava/lang/Systemexit(I)VoutLjava/io/PrintStream;java/io/PrintStreamprintlnerrprintStackTraceprint RJavaTools getFieldNames'(Ljava/lang/Class;Z)[Ljava/lang/String;equals(Ljava/lang/Object;)ZgetMethodNamesappend,(Ljava/lang/String;)Ljava/lang/StringBuffer;(I)Ljava/lang/StringBuffer;toStringgetField-(Ljava/lang/String;)Ljava/lang/reflect/Field;getCompletionName.(Ljava/lang/reflect/Member;)Ljava/lang/String; getMethod@(Ljava/lang/String;[Ljava/lang/Class;)Ljava/lang/reflect/Method;isStatic(Ljava/lang/reflect/Member;)Z(Ljava/lang/Class;)ZgetConstructorF(Ljava/lang/Class;[Ljava/lang/Class;[Z)Ljava/lang/reflect/Constructor;((Ljava/lang/Object;Ljava/lang/String;Z)Vjava/lang/BooleanTYPEhasField'(Ljava/lang/Object;Ljava/lang/String;)Z hasMethodhasClassgetClass7(Ljava/lang/Class;Ljava/lang/String;Z)Ljava/lang/Class; classHasClass'(Ljava/lang/Class;Ljava/lang/String;Z)ZclassHasMethodgetStaticFields-(Ljava/lang/Class;)[Ljava/lang/reflect/Field;java/lang/reflect/FieldgetNamegetStaticMethods.(Ljava/lang/Class;)[Ljava/lang/reflect/Method;java/lang/reflect/MethodgetStaticClasses%(Ljava/lang/Class;)[Ljava/lang/Class; java/util/Mapput8(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;entrySet()Ljava/util/Set;()Ljava/lang/Class; invokeMethodn(Ljava/lang/Class;Ljava/lang/Object;Ljava/lang/String;[Ljava/lang/Object;[Ljava/lang/Class;)Ljava/lang/Object;getFieldTypeName7(Ljava/lang/Class;Ljava/lang/String;)Ljava/lang/String;!    !"#$%&'(3***)  *+(*) ,+( )-+(*) .+( )/0(! *+ ) 12(D L+ )!%"# $& 3'( !"#$%&'()*+,-./012345676)8)* +-./1$2'3*5265789@:C;F=N>Q?TA\B_CbEjFmGpIxJ{K~MNOQRSUVWYZ[]^_abcefgijkmnpqs4 56(989*:8;)yz {| 7'(% <)  8'(W=>?@AY??BK* YCD<)E*2FG*2F YHDزIJ>?@AY??BK* YKDIL>MNAYMMBK* YODP*2F YQDIR>MNAYMMBK* YSD<)E*2FP*2F YTDزI)~"(29OY_go!(>HNV4 9'(:=U>MNAYMMVK*$ YWYXYZ*[\Z]D^Y_SY`SYaSL=>*,6+*2+2F  + YWYXbZ[]DIc>deAYddVK*$ YWYXfZ*[\Z]DIg>MNAYMMVK=^YhSY_SYiSY`SL>*,6+*2+2F  + YjDI)% $*K_ais -/HPZgjmsy4 :'(9yk>MNAYMMElKE*mF YnDoN Y-qDr>MNAYMMPlKP*mF YsDtN Y-qDu>MNAYMMvwxLh+mF8+m YyDzN Y-|D}>MNAYMM~YAYSxLi+mF8+m YDN Y-|DADpQp{hk{)##/9A DE QYt "%#$* +@,L-V.`0h3k1l2x64 ;'(>MNAYMMElK* YDM Y,qD>MNAYMMvwxL+ YDM Y,|D>MNAYMMPlK* YDM Y,qD>MNAYMMwxL+ YDM Y,|D>AYM, YD>AYM, YD<?pL{p(+{)+@A#B*C4E<H?F@GLMTNsOzPRUSTZ[\]_b`aghij l(o+m,n8u@vVw]xgzo~w4 <'(B>AYwKM YDI>AYYAYSYTKM YDI<>AYwKM< YDMNY,-^:<>AYYdeAYddSYdeAYddSYSYTYTYTK :< YD),G_b)#),-7?G_bdfkoy4 ='()4 >'(YK>*E YD>* YDYL>+ YD)B!+3;DNV^foy4 ?'(YK>* YD¶>* Y÷DYLĶ>+Ÿ YƷD)B !+3;DNV^foy!#4 @'(OYKǶ>*ȸɚ YʷD˶̶>*͸ɚ YηD˶)* )+,-#/+132<3F5N74 A'(-ٲ϶>MNAYMMK*AY YѷDҶӶ>MNAYMMK* YԷDҶն>MNAYMMK*AY YԷDҶ)B>?$@=AGCOEWFsGwHJLMNOQS4 B'()Y4 C'(ֶ>MNAYMMך YطD˶ٶ>MNAYMMי YڷD۶>MNAYMMך YܷD˶)6 ^_&`0b8d@e^fhhpjxklnp4 D'(Qݶ>MNAYMMvޚ Y߷D˶>MNAYMMޚ YD˶>MNAYMMvޙ YD>MNAYMMޚ YD˶>MNAYMMޙ YD>MNAYMMޙ YD)fvw&x0z8|@}^~hpx >HP4 E'(>MNAYMMK* YDP*2F YDҶ>deAYddK* YDҶ)6 !'1?IQYrv4 F'(8̲>MNAYMMK^YSYSYSL=*+ YD>*/6+*2+2F  + YDҶ>deAYddK* YDҶ)Z!57>HPZjmpv|4 G'(>deAYddK* YDҶ>MNAYMMK* YD*2AY YDҶ)6 !%/7?X^h4 H'(O>YK*EEW*L++w MM Y DI#7: )*  #7:;FN4 I'(oC >?@AY??E K*F YD)  $ .9B4 JK(2*LY+)L'( )MN   rJava/src/java/PrimitiveArrayException.java0000644000176200001440000000044512256051760020525 0ustar liggesusers/** * Generated when one tries to convert an arrays into * a primitive array of the wrong type */ public class PrimitiveArrayException extends Exception{ public PrimitiveArrayException(String type){ super( "cannot convert to single dimension array of primitive type" + type ) ; } } rJava/src/java/NotAnArrayException.class0000644000176200001440000000104212256051764017756 0ustar liggesusers."     (Ljava/lang/Class;)VCodeLineNumberTable(Ljava/lang/String;)V SourceFileNotAnArrayException.javajava/lang/StringBuffer not an array :   ! NotAnArrayExceptionjava/lang/Exception()Vappend,(Ljava/lang/String;)Ljava/lang/StringBuffer;java/lang/ClassgetName()Ljava/lang/String;toString!   7*Y+   "*+   rJava/src/java/ArrayWrapper.class0000644000176200001440000001314312256051764016505 0ustar liggesusers.    H G G G G G G G H  O F   G G G GJ G 9  G G  isRectZtypeNameLjava/lang/String; primitivelengthIclass$java$lang$ObjectLjava/lang/Class; Synthetic(Ljava/lang/Object;)VCodeLineNumberTable Exceptions(I)V(Z)V(B)V(J)V(S)V(D)V(C)V(F)V isRectangular()ZisRectangular_(Ljava/lang/Object;I)ZgetObjectTypeName()Ljava/lang/String; isPrimitiveflat_int()[I flat_boolean()[Z flat_byte()[B flat_long()[J flat_short()[S flat_double()[D flat_char()[C flat_float()[F flat_Object()[Ljava/lang/Object; flat_String()[Ljava/lang/String;class$%(Ljava/lang/String;)Ljava/lang/Class; SourceFileArrayWrapper.java | java/lang/ClassNotFoundExceptionjava/lang/NoClassDefFoundError e S S d KL MJ IJ bc NO SNotAnArrayExceptionprimitive type S PrimitiveArrayExceptionint FlatException[I a O Oboolean[ZBbyte[BJlong[JSshort[SDdouble[DCchar[CFfloat[F faObjectArrayException[Ljava/lang/Object; PQjava.lang.Object {| java.lang.String[Ljava/lang/String;java/lang/String ArrayWrapperRJavaArrayIteratorjava/lang/ClassforName getMessage(Ljava/lang/String;)VRJavaArrayTools getDimensions(Ljava/lang/Object;)[I([I)VarrayLjava/lang/Object;&(Ljava/lang/Object;)Ljava/lang/String;isPrimitiveTypeName(Ljava/lang/String;)Z dimensions()Vjava/lang/reflect/Array getLength(Ljava/lang/Object;)Iget'(Ljava/lang/Object;I)Ljava/lang/Object;equals(Ljava/lang/Object;)ZhasNextnext()Ljava/lang/Object;start incrementjava/lang/ObjectgetClass()Ljava/lang/Class;getClassLoader()Ljava/lang/ClassLoader;=(Ljava/lang/String;ZLjava/lang/ClassLoader;)Ljava/lang/Class; newInstance&(Ljava/lang/Class;I)Ljava/lang/Object;cast&(Ljava/lang/Object;)Ljava/lang/Object;!GHIJKLMJNOPQRSTUu*+*+*+ ** *  * **+** *(*=* *Y* .hV>"# $% &)'1);,B-G.O0T1_2n1t5WSXU&*YV8WSYU&*YV9WSZU&*YV:WS[U&*YV;WS\U&*YV<WS]U&*YV=WS^U&*YV>WS_U&*YV?W`aU*VFbcUs?* +>* .6*+`V"M NOP%Q5R7P=UdeU* V\faU* VcghUz*  Y* Y* ** L*4* N*!=6-+-.O*"`=+V6 no%p.q9s@vGwRxWyazhyu|x}WijUz#*  Y$* Y* *%%*L*4* %%N*!=6-+-3T*"`=+V6 %.9@GRWahuxWklUz&*  Y'* Y* *((*L*4* ((N*!=6-+-3T*"`=+V6 %.9@GRWahuxWmnUz)*  Y** Y* *++* L*4* ++N*!=6-+-/P*"`=+V6 %.9@GRWahuxWopUz,*  Y-* Y* *..* L*4* ..N*!=6-+-5V*"`=+V6 %.9@GRWahuxWqrUz/*  Y0* Y* *11*L*4* 11N*!=6-+-1R*"`=+V6 %.9@GRWahuxWstUz2*  Y3* Y* *44*L*4* 44N*!=6-+-4U*"`=+V6 %.9@GRWahuxWuvUz5*  Y6* Y* *77*L*4* 77N*!=6-+-0Q*"`=+V6 *+%,.-9/@1G2R3W4a5h4u7x8WwxU"*89Y* :* Y* *;;*<=L>?@Y>>M* *<=AMN,*B;;N*?* ;;:*!66-,2CS*"`6ߧ-WjmVF@A"B+C6EAFWHjInK}MNOPQPSTW9yzU{D*  YD* Y* *EE*FL*4* EEN*!=6-+-2S*"`=+V6 bc%d.e9gAiHjSkXlbmilvoypW{|U2*LY+VFR}~rJava/src/otables.c0000644000176200001440000001312212256051771013706 0ustar liggesusers#include "rJava.h" #define RJAVA_LOOKUP 23 /* This uses the mechanism of the RObjectTables package see: http://www.omegahat.org/RObjectTables/ */ /** * Returns the R_UnboundValue */ HIDE SEXP R_getUnboundValue() { return(R_UnboundValue); } /** * @param name name of a java class * @param canCache Can R cache this object * @param tb * @return TRUE if the a class called name exists in on of the packages */ /* not actually used by R */ HIDE Rboolean rJavaLookupTable_exists(const char * const name, Rboolean *canCache, R_ObjectTable *tb){ #ifdef LOOKUP_DEBUG Rprintf( " >> rJavaLookupTable_exists\n" ); #endif if(tb->active == FALSE) return(FALSE); tb->active = FALSE; Rboolean val = classNameLookupExists( tb, name ); tb->active = TRUE; return( val ); } /** * Returns a new jclassName object if the class exists or the * unbound value if it does not * * @param name class name * @param canCache ?? * @param tb lookup table */ SEXP rJavaLookupTable_get(const char * const name, Rboolean *canCache, R_ObjectTable *tb){ #ifdef LOOKUP_DEBUG Rprintf( " >> rJavaLookupTable_get\n" ); #endif SEXP val; if(tb->active == FALSE) return(R_UnboundValue); tb->active = FALSE; val = PROTECT( classNameLookup( tb, name ) ); tb->active = TRUE; UNPROTECT(1); /* val */ return(val); } /** * Does nothing. Not applicable to java packages */ int rJavaLookupTable_remove(const char * const name, R_ObjectTable *tb){ #ifdef LOOKUP_DEBUG Rprintf( " >> rJavaLookupTable_remove( %s) \n", name ); #endif error( "cannot remove from java package" ) ; return 0; } /** * Indicates if R can cahe the variable name. * Currently allways return FALSE * * @param name name of the class * @param tb lookup table * @return allways FALSE (for now) */ HIDE Rboolean rJavaLookupTable_canCache(const char * const name, R_ObjectTable *tb){ #ifdef LOOKUP_DEBUG Rprintf( " >> rJavaLookupTable_canCache\n" ); #endif return( FALSE ); } /** * Generates an error. assign is not possible on our lookup table */ HIDE SEXP rJavaLookupTable_assign(const char * const name, SEXP value, R_ObjectTable *tb){ #ifdef LOOKUP_DEBUG Rprintf( " >> rJavaLookupTable_assign( %s ) \n", name ); #endif error("can't assign to java package lookup"); return R_NilValue; } /** * Returns the list of classes known to be included in the * packages. Currently returns NULL * * @param tb lookup table */ HIDE SEXP rJavaLookupTable_objects(R_ObjectTable *tb) { #ifdef LOOKUP_DEBUG Rprintf( " >> rJavaLookupTable_objects\n" ); #endif tb->active = FALSE; SEXP res = PROTECT( getKnownClasses( tb ) ) ; tb->active = TRUE; UNPROTECT(1); /* res */ return( res ); } REPC SEXP newRJavaLookupTable(SEXP importer){ #ifdef LOOKUP_DEBUG Rprintf( "\n" ); #endif R_ObjectTable *tb; SEXP val, klass; tb = (R_ObjectTable *) malloc(sizeof(R_ObjectTable)); if(!tb) error( "cannot allocate space for an internal R object table" ); tb->type = RJAVA_LOOKUP ; /* FIXME: not sure what this should be */ tb->cachedNames = NULL; R_PreserveObject(importer); tb->privateData = importer; tb->exists = rJavaLookupTable_exists; tb->get = rJavaLookupTable_get; tb->remove = rJavaLookupTable_remove; tb->assign = rJavaLookupTable_assign; tb->objects = rJavaLookupTable_objects; tb->canCache = rJavaLookupTable_canCache; tb->onAttach = NULL; tb->onDetach = NULL; PROTECT(val = R_MakeExternalPtr(tb, install("UserDefinedDatabase"), R_NilValue)); PROTECT(klass = NEW_CHARACTER(1)); SET_STRING_ELT(klass, 0, COPY_TO_USER_STRING("UserDefinedDatabase")); SET_CLASS(val, klass); UNPROTECT(2); #ifdef LOOKUP_DEBUG Rprintf( "\n" ); #endif return(val); } HIDE jobject getImporterReference(R_ObjectTable *tb ){ jobject res = (jobject)EXTPTR_PTR( GET_SLOT( (SEXP)(tb->privateData), install( "jobj" ) ) ); #ifdef LOOKUP_DEBUG Rprintf( " >> getImporterReference : [%d]\n", res ); #endif return res ; } HIDE SEXP getKnownClasses( R_ObjectTable *tb ){ #ifdef LOOKUP_DEBUG Rprintf( " >> getKnownClasses\n" ); #endif jobject importer = getImporterReference(tb); JNIEnv *env=getJNIEnv(); jarray a = (jarray) (*env)->CallObjectMethod(env, importer, mid_RJavaImport_getKnownClasses ) ; SEXP res = PROTECT( getStringArrayCont( a ) ) ; #ifdef LOOKUP_DEBUG Rprintf( " %d known classes\n", LENGTH(res) ); #endif UNPROTECT(1); return res ; } HIDE SEXP classNameLookup( R_ObjectTable *tb, const char * const name ){ #ifdef LOOKUP_DEBUG Rprintf( " >> classNameLookup\n" ); #endif JNIEnv *env=getJNIEnv(); jobject importer = getImporterReference(tb); jobject clazz = newString(env, name ) ; jstring s ; /* Class */ s = (jstring) (*env)->CallObjectMethod(env, importer, mid_RJavaImport_lookup, clazz ) ; SEXP res ; int np ; if( !s ){ res = R_getUnboundValue() ; np = 0; } else{ PROTECT( res = new_jclassName( env, s ) ); np = 1; } releaseObject(env, clazz); releaseObject(env, s); if( np ) UNPROTECT(1); #ifdef LOOKUP_DEBUG Rprintf( "\n" ); #endif return res ; } HIDE Rboolean classNameLookupExists(R_ObjectTable *tb, const char * const name ){ #ifdef LOOKUP_DEBUG Rprintf( " classNameLookupExists\n" ); #endif JNIEnv *env=getJNIEnv(); jobject importer = getImporterReference(tb); jobject clazz = newString(env, name ) ; jboolean s ; /* Class */ s = (jboolean) (*env)->CallBooleanMethod(env, importer, mid_RJavaImport_exists , clazz ) ; Rboolean res = (s) ? TRUE : FALSE; #ifdef LOOKUP_DEBUG Rprintf( " exists( %s ) = %d \n", name, res ); #endif releaseObject(env, clazz); return res ; } rJava/src/Makevars.in0000644000176200001440000000073712256051760014220 0ustar liggesusers# we need to add JNI specific stuff here PKG_CPPFLAGS=-I. @JAVA_CPPFLAGS@ PKG_LIBS=@JAVA_LIBS@ JAVA_HOME=@JAVA_HOME@ # make SHLIB believe that we know better what the objects are #OBJECTS=Rglue.o callJNI.o initJNI.o rJava.o jri.o jri_glue.o all: $(SHLIB) @WANT_JRI_TRUE@ jri .PHONY: all # this is a hack to force SHLIB to run our sub-make jri: (cd ../jri && $(MAKE)) -@mkdir -p ../inst/jri @(cp -r ../jri/src/JRI.jar ../jri/*jri.* ../jri/run ../jri/examples ../inst/jri/) rJava/src/tools.c0000644000176200001440000001037312256051771013422 0ustar liggesusers/* misc. utility functions, mostly callable from R * * rJava R/Java interface (C)Copyright 2003-2007 Simon Urbanek * (see rJava project root for licensing details) */ #include "rJava.h" /** jobjRefInt object : string */ REPE SEXP RgetStringValue(SEXP par) { SEXP p,e,r; jstring s; const char *c; JNIEnv *env=getJNIEnv(); profStart(); p=CDR(par); e=CAR(p); p=CDR(p); if (e==R_NilValue) return R_NilValue; if (TYPEOF(e)==EXTPTRSXP) { jverify(e); s = (jstring)EXTPTR_PTR(e); } else { error("invalid object parameter"); s = 0; } if (!s) return R_NilValue; c=(*env)->GetStringUTFChars(env, s, 0); if (!c) error("cannot retrieve string content"); r = mkString(c); (*env)->ReleaseStringUTFChars(env, s, c); _prof(profReport("RgetStringValue:")); return r; } /** calls .toString() of the object and returns the corresponding string java object */ HIDE jstring callToString(JNIEnv *env, jobject o) { jclass cls; jmethodID mid; jstring s; if (!o) { _dbg(rjprintf("callToString: invoked on a NULL object\n")); return 0; } cls=objectClass(env,o); if (!cls) { _dbg(rjprintf("callToString: can't determine class of the object\n")); releaseObject(env, cls); checkExceptionsX(env, 1); return 0; } mid=(*env)->GetMethodID(env, cls, "toString", "()Ljava/lang/String;"); if (!mid) { _dbg(rjprintf("callToString: toString not found for the object\n")); releaseObject(env, cls); checkExceptionsX(env, 1); return 0; } BEGIN_RJAVA_CALL; s = (jstring)(*env)->CallObjectMethod(env, o, mid); END_RJAVA_CALL; _mp(MEM_PROF_OUT(" %08x LNEW object method toString result\n", (int) s)) releaseObject(env, cls); return s; } /** calls .toString() on the passed object (int/extptr) and returns the string value or NULL if there is no toString method */ REPE SEXP RtoString(SEXP par) { SEXP p,e,r; jstring s; jobject o; const char *c; JNIEnv *env=getJNIEnv(); p=CDR(par); e=CAR(p); p=CDR(p); if (e==R_NilValue) return R_NilValue; if (TYPEOF(e)==EXTPTRSXP) { jverify(e); o=(jobject)EXTPTR_PTR(e); } else error_return("RtoString: invalid object parameter"); if (!o) return R_NilValue; s=callToString(env, o); if (!s) { return R_NilValue; } c=(*env)->GetStringUTFChars(env, s, 0); PROTECT(r=allocVector(STRSXP,1)); SET_STRING_ELT(r, 0, mkCharUTF8(c)); UNPROTECT(1); (*env)->ReleaseStringUTFChars(env, s, c); releaseObject(env, s); return r; } /* compares two references */ REPC SEXP RidenticalRef(SEXP ref1, SEXP ref2) { SEXP r; if (TYPEOF(ref1)!=EXTPTRSXP || TYPEOF(ref2)!=EXTPTRSXP) return R_NilValue; jverify(ref1); jverify(ref2); r=allocVector(LGLSXP,1); LOGICAL(r)[0]=(R_ExternalPtrAddr(ref1)==R_ExternalPtrAddr(ref2)); return r; } /** create a NULL external reference */ REPC SEXP RgetNullReference() { return R_MakeExternalPtr(0, R_NilValue, R_NilValue); } /** TRUE if cl1 x; cl2 y = (cl2) x ... is valid */ REPC SEXP RisAssignableFrom(SEXP cl1, SEXP cl2) { SEXP r; JNIEnv *env=getJNIEnv(); if (TYPEOF(cl1)!=EXTPTRSXP || TYPEOF(cl2)!=EXTPTRSXP) error("invalid type"); if (!env) error("VM not initialized"); jverify(cl1); jverify(cl2); r=allocVector(LGLSXP,1); LOGICAL(r)[0]=((*env)->IsAssignableFrom(env, (jclass)EXTPTR_PTR(cl1), (jclass)EXTPTR_PTR(cl2))); return r; } REPC SEXP RJava_checkJVM() { SEXP r = allocVector(LGLSXP, 1); LOGICAL(r)[0] = 0; if (!jvm || !getJNIEnv()) return r; LOGICAL(r)[0] = 1; return r; } extern int rJava_initialized; /* in callJNI.c */ REPC SEXP RJava_needs_init() { SEXP r = allocVector(LGLSXP, 1); LOGICAL(r)[0] = rJava_initialized?0:1; return r; } REPC SEXP RJava_set_memprof(SEXP fn) { #ifdef MEMPROF const char *cFn = CHAR(STRING_ELT(fn, 0)); int env = 0; /* we're just faking it so we can call MEM_PROF_OUT */ if (memprof_f) fclose(memprof_f); if (cFn && !cFn[0]) { memprof_f = 0; return R_NilValue; } if (!cFn || (cFn[0]=='-' && !cFn[1])) memprof_f = stdout; else memprof_f = fopen(cFn, "a"); if (!memprof_f) error("Cannot create memory profile file."); MEM_PROF_OUT(" 00000000 REST -- profiling file set --\n"); return R_NilValue; #else error("Memory profiling support was not enabled in rJava."); #endif return R_NilValue; } rJava/src/callback.c0000644000176200001440000000327012256051771014014 0ustar liggesusers#include "rJava.h" #ifdef ENABLE_JRICB #include #include #include "callback.h" int RJava_has_control = 0; /* ipcin -> receives requests on R thread ipcout <- write to place requests to main R thread resout <- written by main thread to respond resin -> read to get info from main thread */ static int ipcin, ipcout, resin, resout; static struct rJavaInfoBlock_s { int ipcin, ipcout, resin, resout; int *has_control; } rJavaInfoBlock; struct rJavaInfoBlock_s *RJava_get_info_block() { return &rJavaInfoBlock; } typedef void(callbackfn)(void*); static void RJava_ProcessEvents(void *data) { long buf[4]; int n = read(ipcin, buf, sizeof(long)); if (buf[0] == IPCC_LOCK_REQUEST) { RJava_has_control = 1; buf[0] = IPCC_LOCK_GRANTED; write(resout, buf, sizeof(long)); n = read(ipcin, buf, sizeof(long)); } if (buf[0] == IPCC_CLEAR_LOCK) { RJava_has_control = 0; } if (buf[0] == IPCC_CONTROL_ADDR) { buf[1] = (long) (void*) &RJava_has_control; write(resout, buf, sizeof(long)*2); } if (buf[0] == IPCC_CALL_REQUEST) { callbackfn *fn; read(ipcin, buf+1, sizeof(long)*2); fn = (callbackfn*) buf[1]; RJava_has_control = 1; fn((void*) buf[2]); RJava_has_control = 0; } } int RJava_init_loop() { int pfd[2]; pipe(pfd); ipcin = pfd[0]; ipcout = pfd[1]; pipe(pfd); resin = pfd[0]; resout = pfd[1]; rJavaInfoBlock.ipcin = ipcin; rJavaInfoBlock.ipcout = ipcout; rJavaInfoBlock.resin = resin; rJavaInfoBlock.resout = resout; rJavaInfoBlock.has_control = &RJava_has_control; addInputHandler(R_InputHandlers, ipcin, RJava_ProcessEvents, RJavaActivity); return 0; } #endif rJava/src/callJNI.c0000644000176200001440000002414212256051771013535 0ustar liggesusers#include #include #include "rJava.h" #include #include #ifdef MEMPROF FILE *memprof_f = 0; #endif /* local to JRI */ static void releaseLocal(JNIEnv *env, jobject o); REPC SEXP RJavaCheckExceptions(SEXP silent) { int result = 0; JNIEnv *env = getJNIEnv(); if (env) result = checkExceptionsX(env, asInteger(silent)); return ScalarInteger(result); } HIDE void* errJNI(const char *err, ...) { char msg[512]; va_list ap; #ifndef RJ_DEBUG /* non-debug version goes straight to ckx - it should never return */ ckx(NULL); #endif va_start(ap, err); msg[511]=0; vsnprintf(msg, 511, err, ap); #ifdef RJ_DEBUG Rf_warning(msg); #else Rf_error(msg); /* this never returns and is just a fallback in case ckx doesn't return */ #endif va_end(ap); checkExceptionsX(getJNIEnv(), 0); return 0; } HIDE jclass findClass(JNIEnv *env, const char *cName) { if (clClassLoader) { char cn[128], *c=cn; jobject cns; jclass cl; strcpy(cn, cName); while (*c) { if (*c=='/') *c='.'; c++; }; cns = newString(env, cn); if (!cns) error("unable to create Java string from '%s'", cn); #ifdef DEBUG_CL printf("findClass(\"%s\") [with rJava loader]\n", cn); #endif cl = (jclass) (*env)->CallStaticObjectMethod(env, javaClassClass, mid_forName, cns, (jboolean) 1, oClassLoader); #if RJAVA_LEGACY clx(env); #endif _mp(MEM_PROF_OUT(" %08x LNEW class\n", (int) cl)) releaseObject(env, cns); #ifdef DEBUG_CL printf(" - got %x\n", (unsigned int) cl); #endif #if RJAVA_LEGACY if (cl) #endif return cl; } #ifdef DEBUG_CL printf("findClass(\"%s\") (no loader)\n", cName); #endif { jclass cl = (*env)->FindClass(env, cName); _mp(MEM_PROF_OUT(" %08x LNEW class\n", (int) cl)) #ifdef DEBUG_CL printf(" - got %x\n", (unsigned int) cl); #endif return cl; } } HIDE jobject createObject(JNIEnv *env, const char *class, const char *sig, jvalue *par, int silent) { /* va_list ap; */ jmethodID mid; jclass cls; jobject o; cls=findClass(env, class); if (!cls) return silent?0:errJNI("createObject.FindClass %s failed",class); mid=(*env)->GetMethodID(env, cls, "", sig); if (!mid) { releaseLocal(env, cls); return silent?0:errJNI("createObject.GetMethodID(\"%s\",\"%s\") failed",class,sig); } /* va_start(ap, sig); */ o=(*env)->NewObjectA(env, cls, mid, par); _mp(MEM_PROF_OUT(" %08x LNEW object\n", (int) o)) /* va_end(ap); */ releaseLocal(env, cls); return (o||silent)?o:errJNI("NewObject(\"%s\",\"%s\",...) failed",class,sig); } HIDE void printObject(JNIEnv *env, jobject o) { jmethodID mid; jclass cls; jobject s; const char *c; cls=(*env)->GetObjectClass(env,o); _mp(MEM_PROF_OUT(" %08x LNEW class from object %08x (JRI-local)\n", (int)cls, (int)o)) if (!cls) { releaseLocal(env, cls); errJNI("printObject.GetObjectClass failed"); return ; } mid=(*env)->GetMethodID(env, cls, "toString", "()Ljava/lang/String;"); if (!mid) { releaseLocal(env, cls); errJNI("printObject.GetMethodID for toString() failed"); return; } s=(*env)->CallObjectMethod(env, o, mid); _mp(MEM_PROF_OUT(" %08x LNEW object method toString result (JRI-local)\n", (int)s)) if (!s) { releaseLocal(env, cls); errJNI("printObject o.toString() call failed"); return; } c=(*env)->GetStringUTFChars(env, (jstring)s, 0); (*env)->ReleaseStringUTFChars(env, (jstring)s, c); releaseLocal(env, cls); releaseLocal(env, s); } HIDE jdoubleArray newDoubleArray(JNIEnv *env, double *cont, int len) { jdoubleArray da=(*env)->NewDoubleArray(env,len); jdouble *dae; _mp(MEM_PROF_OUT(" %08x LNEW double[%d]\n", (int) da, len)) if (!da) return errJNI("newDoubleArray.new(%d) failed",len); dae=(*env)->GetDoubleArrayElements(env, da, 0); if (!dae) { releaseLocal(env, da); return errJNI("newDoubleArray.GetDoubleArrayElements failed"); } memcpy(dae,cont,sizeof(jdouble)*len); (*env)->ReleaseDoubleArrayElements(env, da, dae, 0); return da; } HIDE jintArray newIntArray(JNIEnv *env, int *cont, int len) { jintArray da=(*env)->NewIntArray(env,len); jint *dae; _mp(MEM_PROF_OUT(" %08x LNEW int[%d]\n", (int) da, len)) if (!da) return errJNI("newIntArray.new(%d) failed",len); dae=(*env)->GetIntArrayElements(env, da, 0); if (!dae) { releaseLocal(env,da); return errJNI("newIntArray.GetIntArrayElements failed"); } memcpy(dae,cont,sizeof(jint)*len); (*env)->ReleaseIntArrayElements(env, da, dae, 0); return da; } HIDE jbyteArray newByteArray(JNIEnv *env, void *cont, int len) { jbyteArray da=(*env)->NewByteArray(env,len); jbyte *dae; _mp(MEM_PROF_OUT(" %08x LNEW byte[%d]\n", (int) da, len)) if (!da) return errJNI("newByteArray.new(%d) failed",len); dae=(*env)->GetByteArrayElements(env, da, 0); if (!dae) { releaseLocal(env,da); return errJNI("newByteArray.GetByteArrayElements failed"); } memcpy(dae,cont,len); (*env)->ReleaseByteArrayElements(env, da, dae, 0); return da; } HIDE jbyteArray newByteArrayI(JNIEnv *env, int *cont, int len) { jbyteArray da=(*env)->NewByteArray(env,len); jbyte* dae; int i=0; _mp(MEM_PROF_OUT(" %08x LNEW byte[%d]\n", (int) da, len)) if (!da) return errJNI("newByteArray.new(%d) failed",len); dae=(*env)->GetByteArrayElements(env, da, 0); if (!dae) { releaseLocal(env,da); return errJNI("newByteArray.GetByteArrayElements failed"); } while (iReleaseByteArrayElements(env, da, dae, 0); return da; } HIDE jbooleanArray newBooleanArrayI(JNIEnv *env, int *cont, int len) { jbooleanArray da=(*env)->NewBooleanArray(env,len); jboolean *dae; int i=0; _mp(MEM_PROF_OUT(" %08x LNEW bool[%d]\n", (int) da, len)) if (!da) return errJNI("newBooleanArrayI.new(%d) failed",len); dae=(*env)->GetBooleanArrayElements(env, da, 0); if (!dae) { releaseLocal(env,da); return errJNI("newBooleanArrayI.GetBooleanArrayElements failed"); } /* we cannot just memcpy since JNI uses unsigned char and R uses int */ while (iReleaseBooleanArrayElements(env, da, dae, 0); return da; } HIDE jcharArray newCharArrayI(JNIEnv *env, int *cont, int len) { jcharArray da=(*env)->NewCharArray(env,len); jchar *dae; int i=0; _mp(MEM_PROF_OUT(" %08x LNEW char[%d]\n", (int) da, len)) if (!da) return errJNI("newCharArrayI.new(%d) failed",len); dae=(*env)->GetCharArrayElements(env, da, 0); if (!dae) { releaseLocal(env,da); return errJNI("newCharArrayI.GetCharArrayElements failed"); } while (iReleaseCharArrayElements(env, da, dae, 0); return da; } HIDE jshortArray newShortArrayI(JNIEnv *env, int *cont, int len) { jshortArray da=(*env)->NewShortArray(env,len); jshort *dae; int i=0; _mp(MEM_PROF_OUT(" %08x LNEW short[%d]\n", (int) da, len)) if (!da) return errJNI("newShortArrayI.new(%d) failed",len); dae=(*env)->GetShortArrayElements(env, da, 0); if (!dae) { releaseLocal(env,da); return errJNI("newShortArrayI.GetShortArrayElements failed"); } while (iReleaseShortArrayElements(env, da, dae, 0); return da; } HIDE jfloatArray newFloatArrayD(JNIEnv *env, double *cont, int len) { jfloatArray da=(*env)->NewFloatArray(env,len); jfloat *dae; int i=0; _mp(MEM_PROF_OUT(" %08x LNEW float[%d]\n", (int) da, len)) if (!da) return errJNI("newFloatArrayD.new(%d) failed",len); dae=(*env)->GetFloatArrayElements(env, da, 0); if (!dae) { releaseLocal(env,da); return errJNI("newFloatArrayD.GetFloatArrayElements failed"); } /* we cannot just memcpy since JNI uses float and R uses double */ while (iReleaseFloatArrayElements(env, da, dae, 0); return da; } HIDE jlongArray newLongArrayD(JNIEnv *env, double *cont, int len) { jlongArray da=(*env)->NewLongArray(env,len); jlong *dae; int i=0; _mp(MEM_PROF_OUT(" %08x LNEW long[%d]\n", (int) da, len)) if (!da) return errJNI("newLongArrayD.new(%d) failed",len); dae=(*env)->GetLongArrayElements(env, da, 0); if (!dae) { releaseLocal(env, da); return errJNI("newLongArrayD.GetFloatArrayElements failed"); } /* we cannot just memcpy since JNI uses long and R uses double */ while (iReleaseLongArrayElements(env, da, dae, 0); return da; } HIDE jstring newString(JNIEnv *env, const char *cont) { jstring s=(*env)->NewStringUTF(env, cont); _mp(MEM_PROF_OUT(" %08x LNEW string \"%s\"\n", (int) s, cont)) return s?s:errJNI("newString(\"%s\") failed",cont); } HIDE void releaseObject(JNIEnv *env, jobject o) { /* Rprintf("releaseObject: %lx\n", (long)o); printObject(env, o); */ _mp(MEM_PROF_OUT(" %08x LREL\n", (int)o)) (*env)->DeleteLocalRef(env, o); } HIDE jclass objectClass(JNIEnv *env, jobject o) { jclass cls=(*env)->GetObjectClass(env,o); _mp(MEM_PROF_OUT(" %08x LNEW class from object %08x\n", (int) cls, (int) o)) return cls; } static void releaseLocal(JNIEnv *env, jobject o) { _mp(MEM_PROF_OUT(" %08x LREL (JRI-local)\n", (int)o)) (*env)->DeleteLocalRef(env, o); } HIDE jobject makeGlobal(JNIEnv *env, jobject o) { jobject g=(*env)->NewGlobalRef(env,o); _mp(MEM_PROF_OUT("G %08x GNEW %08x\n", (int) g, (int) o)) return g?g:errJNI("makeGlobal: failed to make global reference"); } HIDE void releaseGlobal(JNIEnv *env, jobject o) { /* Rprintf("releaseGlobal: %lx\n", (long)o); printObject(env, o); */ _mp(MEM_PROF_OUT("G %08x GREL\n", (int) o)) (*env)->DeleteGlobalRef(env,o); } static jobject nullEx = 0; HIDE int checkExceptionsX(JNIEnv *env, int silent) { jthrowable t=(*env)->ExceptionOccurred(env); if (t == nullEx) t = 0; else { if ((*env)->IsSameObject(env, t, 0)) { nullEx = t; t = 0; } else { _mp(MEM_PROF_OUT(" %08x LNEW exception\n", (int) t)) } } if (t) { if (!silent) ckx(env); (*env)->ExceptionClear(env); releaseLocal(env, t); return 1; } return 0; } rJava/src/Makevars.win0000644000176200001440000000177612256051760014413 0ustar liggesusers# To compile the Windows version, you need to: # - set JAVA_HOME to the JDK root (used for includes only) # in addition if the pre-compiled stuff is not present, then also: # - generate libjvm.dll.a from JDK's jvm.dll # (run `make' in `jvm-w32') # - copy WinRegistry.dll into inst/libs # You can modify the following line as the unlima ratio fallback. # Shouldn't be necessary, because JAVA_HOME and autodetection # have higher precedence. DEFAULT_JAVA_HOME=C:\\jdk1.4.2_04 # this file is generated by configure.win and honors JAVA_HOME env.var -include Makevars.java ifeq ($(JAVA_HOME),) JAVA_HOME:=$(DEFAULT_JAVA_HOME) endif $(warning JAVA_HOME is $(JAVA_HOME)) # normally you don't have to touch this unless you want to add # debugging flags like -DRJ_DEBUG or -DRJ_PROFILE to PKG_CFLAGS JAVA_INCLUDES=$(JAVA_HOME)/include $(JAVA_HOME)/include/win32 PKG_CPPFLAGS = -D_R_ -DWin32 -Ijvm-w32 -I$(RHOME)/src/include $(JAVA_INCLUDES:%=-I%) PKG_LIBS = -Ljvm-w32 -ljvm.dll $(warning PKG_CPPFLAGS are $(PKG_CPPFLAGS)) rJava/src/init.c0000644000176200001440000003160012256051771013221 0ustar liggesusers#include "rJava.h" #include #include #include /* global variables */ JavaVM *jvm; /* this will be set when Java tries to exit() but we carry on */ int java_is_dead = 0; /* cached, global objects */ jclass javaStringClass; jclass javaObjectClass; jclass javaClassClass; jclass javaFieldClass; /* cached, global method IDs */ jmethodID mid_forName; jmethodID mid_getName; jmethodID mid_getSuperclass; jmethodID mid_getType; jmethodID mid_getField; /* internal classes and methods */ jclass rj_RJavaTools_Class = (jclass)0; jmethodID mid_rj_getSimpleClassNames = (jmethodID)0 ; jmethodID mid_RJavaTools_getFieldTypeName = (jmethodID)0 ; jclass rj_RJavaImport_Class = (jclass)0; jmethodID mid_RJavaImport_getKnownClasses = (jmethodID)0 ; jmethodID mid_RJavaImport_lookup = (jmethodID)0 ; jmethodID mid_RJavaImport_exists = (jmethodID)0 ; int rJava_initialized = 0; static int jvm_opts=0; static char **jvm_optv=0; #ifdef JNI_VERSION_1_2 static JavaVMOption *vm_options; static JavaVMInitArgs vm_args; #else #error "Java/JNI 1.2 or higher is required!" #endif #define H_OUT 1 #define H_EXIT 2 #ifdef Win32 /* the hooks are reportedly causing problems on Windows, so disable them by default */ static int default_hooks = 0; #else static int default_hooks = H_OUT|H_EXIT; #endif static int JNICALL vfprintf_hook(FILE *f, const char *fmt, va_list ap) { #ifdef Win32 /* on Windows f doesn't refer to neither stderr nor stdout, so we have no way of finding out the target, so we assume stderr */ REvprintf(fmt, ap); return 0; #else if (f==stderr) { REvprintf(fmt, ap); return 0; } else if (f==stdout) { Rvprintf(fmt, ap); return 0; } return vfprintf(f, fmt, ap); #endif } static void JNICALL exit_hook(int status) { /* REprintf("\nJava requested System.exit(%d), trying to raise R error - this may crash if Java is in a bad state.\n", status); */ java_is_dead = 1; Rf_error("Java called System.exit(%d) requesting R to quit - trying to recover", status); /* FIXME: we could do something smart here such as running a call-back into R ... jump into R event loop ... at any rate we cannot return, but we don't want to kill R ... */ exit(status); } /* in reality WIN64 implies WIN32 but to make sure ... */ #if defined(_WIN64) || defined(_WIN32) #include #include #endif static int initJVM(const char *user_classpath, int opts, char **optv, int hooks) { int total_num_properties, propNum = 0; jint res; char *classpath; if(!user_classpath) /* use the CLASSPATH environment variable as default */ user_classpath = getenv("CLASSPATH"); if(!user_classpath) user_classpath = ""; vm_args.version = JNI_VERSION_1_2; if(JNI_GetDefaultJavaVMInitArgs(&vm_args) != JNI_OK) { error("JNI 1.2 or higher is required"); return -1; } /* leave room for class.path, and optional jni args */ total_num_properties = 6 + opts; vm_options = (JavaVMOption *) calloc(total_num_properties, sizeof(JavaVMOption)); vm_args.version = JNI_VERSION_1_2; /* should we do that or keep the default? */ vm_args.options = vm_options; vm_args.ignoreUnrecognized = JNI_TRUE; classpath = (char*) calloc(24 + strlen(user_classpath), sizeof(char)); sprintf(classpath, "-Djava.class.path=%s", user_classpath); vm_options[propNum++].optionString = classpath; /* print JNI-related messages */ /* vm_options[propNum++].optionString = "-verbose:class,jni"; */ if (optv) { int i=0; while (i #ifdef XXDARWIN #include #include #include #endif pthread_t initJVMpt; pthread_mutex_t initMutex = PTHREAD_MUTEX_INITIALIZER; int thInitResult = 0; int initAWT = 0; static void *initJVMthread(void *classpath) { int ws; jclass c; JNIEnv *lenv; thInitResult=initJVM((char*)classpath, jvm_opts, jvm_optv, default_hooks); if (thInitResult) return 0; init_rJava(); lenv = eenv; /* we make a local copy before unlocking just in case someone messes with it before we can use it */ _dbg(rjprintf("initJVMthread: unlocking\n")); pthread_mutex_unlock(&initMutex); if (initAWT) { _dbg(rjprintf("initJVMthread: get AWT class\n")); /* we are still on the same thread, so we can safely use eenv */ c = (*lenv)->FindClass(lenv, "java/awt/Frame"); } _dbg(rjprintf("initJVMthread: returning from the init thread.\n")); return 0; } #endif /* initialize internal structures/variables of rJava. The JVM initialization was performed before (but may have failed) */ HIDE void init_rJava(void) { jclass c; JNIEnv *env = getJNIEnv(); if (!env) return; /* initJVMfailed, so we cannot proceed */ /* get global classes. we make the references explicitely global (although unloading of String/Object is more than unlikely) */ c=(*env)->FindClass(env, "java/lang/String"); if (!c) error("unable to find the basic String class"); javaStringClass=(*env)->NewGlobalRef(env, c); if (!javaStringClass) error("unable to create a global reference to the basic String class"); (*env)->DeleteLocalRef(env, c); c=(*env)->FindClass(env, "java/lang/Object"); if (!c) error("unable to find the basic Object class"); javaObjectClass=(*env)->NewGlobalRef(env, c); if (!javaObjectClass) error("unable to create a global reference to the basic Object class"); (*env)->DeleteLocalRef(env, c); c = (*env)->FindClass(env, "java/lang/Class"); if (!c) error("unable to find the basic Class class"); javaClassClass=(*env)->NewGlobalRef(env, c); if (!javaClassClass) error("unable to create a global reference to the basic Class class"); (*env)->DeleteLocalRef(env, c); c = (*env)->FindClass(env, "java/lang/reflect/Field"); if (!c) error("unable to find the basic Field class"); javaFieldClass=(*env)->NewGlobalRef(env, c); if (!javaFieldClass) error("unable to create a global reference to the basic Class class"); (*env)->DeleteLocalRef(env, c); mid_forName = (*env)->GetStaticMethodID(env, javaClassClass, "forName", "(Ljava/lang/String;ZLjava/lang/ClassLoader;)Ljava/lang/Class;"); if (!mid_forName) error("cannot obtain Class.forName method ID"); mid_getName = (*env)->GetMethodID(env, javaClassClass, "getName", "()Ljava/lang/String;"); if (!mid_getName) error("cannot obtain Class.getName method ID"); mid_getSuperclass =(*env)->GetMethodID(env, javaClassClass, "getSuperclass", "()Ljava/lang/Class;"); if (!mid_getSuperclass) error("cannot obtain Class.getSuperclass method ID"); mid_getField = (*env)->GetMethodID(env, javaClassClass, "getField", "(Ljava/lang/String;)Ljava/lang/reflect/Field;"); if (!mid_getField) error("cannot obtain Class.getField method ID"); mid_getType = (*env)->GetMethodID(env, javaFieldClass, "getType", "()Ljava/lang/Class;"); if (!mid_getType) error("cannot obtain Field.getType method ID"); rJava_initialized = 1; } /** RinitJVM(classpath) initializes JVM with the specified class path */ REP SEXP RinitJVM(SEXP par) { const char *c=0; SEXP e=CADR(par); int r=0; JavaVM *jvms[32]; jsize vms=0; jvm_opts=0; jvm_optv=0; if (TYPEOF(e)==STRSXP && LENGTH(e)>0) c=CHAR(STRING_ELT(e,0)); e = CADDR(par); if (TYPEOF(e)==STRSXP && LENGTH(e)>0) { int len = LENGTH(e), add_xrs = 1, joi = 0; jvm_optv = (char**)malloc(sizeof(char*) * (len + 3)); if (!jvm_optv) Rf_error("Cannot allocate options buffer - out of memory"); #ifdef USE_HEADLESS_INIT /* prepend headless so the user can still override it */ jvm_optv[jvm_opts++] = "-Djava.awt.headless=true"; #endif while (joi < len) { jvm_optv[jvm_opts] = strdup(CHAR(STRING_ELT(e, joi++))); #ifdef HAVE_XRS /* check if Xrs is already used */ if (!strcmp(jvm_optv[jvm_opts], "-Xrs")) add_xrs = 0; #endif jvm_opts++; } #ifdef HAVE_XRS if (add_xrs) jvm_optv[jvm_opts++] = "-Xrs"; #endif } else { #ifdef USE_HEADLESS_INIT jvm_optv = (char**)malloc(sizeof(char*) * 3); if (!jvm_optv) Rf_error("Cannot allocate options buffer - out of memory"); jvm_optv[jvm_opts++] = "-Djava.awt.headless=true"; #endif #ifdef HAVE_XRS if (!jvm_optv) jvm_optv = (char**)malloc(sizeof(char*) * 2); if (!jvm_optv) Rf_error("Cannot allocate options buffer - out of memory"); jvm_optv[jvm_opts++] = "-Xrs"; #endif } if (jvm_opts) jvm_optv[jvm_opts] = 0; r=JNI_GetCreatedJavaVMs(jvms, 32, &vms); if (r) { Rf_error("JNI_GetCreatedJavaVMs returned %d\n", r); } else { if (vms>0) { int i=0; _dbg(rjprintf("RinitJVM: Total %d JVMs found. Trying to attach the current thread.\n", (int)vms)); while (iAttachCurrentThread(jvms[i], (void**)&eenv, NULL)) { _dbg(rjprintf("RinitJVM: Attached to existing JVM #%d.\n", i+1)); break; } } i++; } if (i==vms) Rf_error("Failed to attach to any existing JVM."); else { jvm = jvms[i]; init_rJava(); } PROTECT(e=allocVector(INTSXP,1)); INTEGER(e)[0]=(i==vms)?-2:1; UNPROTECT(1); return e; } } #ifdef THREADS if (getenv("R_GUI_APP_VERSION") || getenv("RJAVA_INIT_AWT")) initAWT=1; _dbg(rjprintf("RinitJVM(threads): launching thread\n")); pthread_mutex_lock(&initMutex); pthread_create(&initJVMpt, 0, initJVMthread, c); _dbg(rjprintf("RinitJVM(threads): waiting for mutex\n")); pthread_mutex_lock(&initMutex); pthread_mutex_unlock(&initMutex); /* pthread_join(initJVMpt, 0); */ _dbg(rjprintf("RinitJVM(threads): attach\n")); /* since JVM was initialized by another thread, we need to attach ourselves */ (*jvm)->AttachCurrentThread(jvm, (void**)&eenv, NULL); _dbg(rjprintf("RinitJVM(threads): done.\n")); r = thInitResult; #else profStart(); r=initJVM(c, jvm_opts, jvm_optv, default_hooks); init_rJava(); _prof(profReport("init_rJava:")); _dbg(rjprintf("RinitJVM(non-threaded): initJVM returned %d\n", r)); #endif if (jvm_optv) free(jvm_optv); jvm_opts=0; PROTECT(e=allocVector(INTSXP,1)); INTEGER(e)[0]=r; UNPROTECT(1); return e; } REP void doneJVM() { (*jvm)->DestroyJavaVM(jvm); jvm = 0; eenv = 0; } /** * Initializes the cached values of classes and methods used internally * These classes and methods are the ones that are in rJava (RJavaTools, ...) * not java standard classes (Object, Class) */ REPC SEXP initRJavaTools(){ JNIEnv *env=getJNIEnv(); jclass c; /* classes */ /* RJavaTools class */ c= findClass( env, "RJavaTools" ) ; if (!c) error("unable to find the RJavaTools class"); rj_RJavaTools_Class=(*env)->NewGlobalRef(env, c); if (!rj_RJavaTools_Class) error("unable to create a global reference to the RJavaTools class"); (*env)->DeleteLocalRef(env, c); /* RJavaImport */ c= findClass( env, "RJavaImport" ) ; if (!c) error("unable to find the RJavaImport class"); rj_RJavaImport_Class=(*env)->NewGlobalRef(env, c); if (!rj_RJavaImport_Class) error("unable to create a global reference to the RJavaImport class"); (*env)->DeleteLocalRef(env, c); /* methods */ mid_RJavaTools_getFieldTypeName = (*env)->GetStaticMethodID(env, rj_RJavaTools_Class, "getFieldTypeName", "(Ljava/lang/Class;Ljava/lang/String;)Ljava/lang/String;"); if (!mid_RJavaTools_getFieldTypeName) error("cannot obtain RJavaTools.getFieldTypeName method ID"); mid_rj_getSimpleClassNames = (*env)->GetStaticMethodID(env, rj_RJavaTools_Class, "getSimpleClassNames", "(Ljava/lang/Object;Z)[Ljava/lang/String;"); if (!mid_rj_getSimpleClassNames) error("cannot obtain RJavaTools.getDimpleClassNames method ID"); mid_RJavaImport_getKnownClasses = (*env)->GetMethodID(env, rj_RJavaImport_Class, "getKnownClasses", "()[Ljava/lang/String;"); if (!mid_RJavaImport_getKnownClasses) error("cannot obtain RJavaImport.getKnownClasses method ID"); mid_RJavaImport_lookup = (*env)->GetMethodID(env, rj_RJavaImport_Class, "lookup", "(Ljava/lang/String;)Ljava/lang/Class;"); if( !mid_RJavaImport_lookup) error("cannot obtain RJavaImport.lookup method ID"); mid_RJavaImport_exists = (*env)->GetMethodID(env, rj_RJavaImport_Class, "exists", "(Ljava/lang/String;)Z"); if( ! mid_RJavaImport_exists ) error("cannot obtain RJavaImport.exists method ID"); // maybe add RJavaArrayTools, ... return R_NilValue; } rJava/src/callback.h0000644000176200001440000000065012256051771014020 0ustar liggesusers#ifndef __CALLBACK_H__ #define __CALLBACK_H__ #ifdef ENABLE_JRICB extern int RJava_has_control; #endif #define RJavaActivity 16 /* all IPC messages are long-alligned */ #define IPCC_LOCK_REQUEST 1 #define IPCC_LOCK_GRANTED 2 /* reponse on IPCC_LOCK_REQUEST */ #define IPCC_CLEAR_LOCK 3 #define IPCC_CALL_REQUEST 4 /* pars: */ #define IPCC_CONTROL_ADDR 5 /* ipc: request, res: */ #endif rJava/src/rJava.c0000644000176200001440000001633612256051771013332 0ustar liggesusers#include #include #include #include "rJava.h" #include #include /* determine whether eenv chache should be used (has no effect if JNI_CACHE is not set) */ int use_eenv = 1; /* cached environment. Do NOT use directly! Always use getJNIEnv()! */ JNIEnv *eenv; /* -- hack to get at the current call from C code using contexts */ #if ( R_VERSION >= R_Version(1, 7, 0) ) #include /* stuff we need to pull for Windows... */ #ifdef WIN32 /* this is from gnuwin32/fixed/h/psignal.h */ #ifndef _SIGSET_T_ #define _SIGSET_T_ typedef int sigset_t; #endif /* Not _SIGSET_T_ */ typedef struct { jmp_buf jmpbuf; /* Calling environment. */ int mask_was_saved; /* Saved the signal mask? */ sigset_t saved_mask; /* Saved signal mask. */ } sigjmp_buf[1]; /* we need to set HAVE_POSIX_SETJMP since we don't have config.h on Win */ #ifndef HAVE_POSIX_SETJMP #define HAVE_POSIX_SETJMP #endif #endif #ifdef HAVE_POSIX_SETJMP #define JMP_BUF sigjmp_buf #else #define JMP_BUF jmp_buf #endif #ifndef CTXT_BUILTIN #define CTXT_BUILTIN 64 #endif typedef struct RCNTXT { /* this RCNTXT structure is only partial since we need to get at "call" - it is safe form R 1.7.0 on */ struct RCNTXT *nextcontext; /* The next context up the chain <<-- we use this one to skip the .Call/.External call frame */ int callflag; /* The context "type" <<<-- we use this one to skip the .Call/.External call frame */ JMP_BUF cjmpbuf; /* C stack and register information */ int cstacktop; /* Top of the pointer protection stack */ int evaldepth; /* evaluation depth at inception */ SEXP promargs; /* Promises supplied to closure */ SEXP callfun; /* The closure called */ SEXP sysparent; /* environment the closure was called from */ SEXP call; /* The call that effected this context <<<--- we pass this one to the condition */ SEXP cloenv; /* The environment */ } RCNTXT; #ifndef LibExtern #define LibExtern extern #endif LibExtern RCNTXT* R_GlobalContext; static SEXP getCurrentCall() { RCNTXT *ctx = R_GlobalContext; /* skip the .External/.Call context to get at the underlying call */ if (ctx->nextcontext && (ctx->callflag & CTXT_BUILTIN)) ctx = ctx->nextcontext; /* skip .jcheck */ if (TYPEOF(ctx->call) == LANGSXP && CAR(ctx->call) == install(".jcheck") && ctx->nextcontext) ctx = ctx->nextcontext; return ctx->call; } #else static SEXP getCurrentCall() { return R_NilValue; } #endif /* -- end of hack */ /** throw an exception using R condition code. * @param msg - message string * @param jobj - jobjRef object of the exception * @param clazzes - simple name of all the classes in the inheritance tree of the exception plus "error" and "condition" */ HIDE void throwR(SEXP msg, SEXP jobj, SEXP clazzes) { SEXP cond = PROTECT(allocVector(VECSXP, 3)); SEXP names = PROTECT(allocVector(STRSXP, 3)); SET_VECTOR_ELT(cond, 0, msg); SET_VECTOR_ELT(cond, 1, getCurrentCall()); SET_VECTOR_ELT(cond, 2, jobj); SET_STRING_ELT(names, 0, mkChar("message")); SET_STRING_ELT(names, 1, mkChar("call")); SET_STRING_ELT(names, 2, mkChar("jobj")); setAttrib(cond, R_NamesSymbol, names); setAttrib(cond, R_ClassSymbol, clazzes); UNPROTECT(2); /* clazzes, names */ eval(LCONS(install("stop"), CONS(cond, R_NilValue)), R_GlobalEnv); UNPROTECT(1); /* cond */ } /* check for exceptions and throw them to R level */ HIDE void ckx(JNIEnv *env) { SEXP xr, xobj, msg = 0, xclass = 0; /* note: we don't bother counting protections becasue we never return */ jthrowable x = 0; if (env && !(x = (*env)->ExceptionOccurred(env))) return; if (!env) { env = getJNIEnv(); if (!env) error("Unable to retrieve JVM environment."); ckx(env); return; } /* env is valid and an exception occurred */ /* we create the jobj first, because the exception may in theory disappear after being cleared, yet this can be (also in theory) risky as it uses further JNI calls ... */ xobj = j2SEXP(env, x, 0); (*env)->ExceptionClear(env); /* grab the list of class names (without package path) */ SEXP clazzes = PROTECT( getSimpleClassNames_asSEXP( (jobject)x, (jboolean)1 ) ) ; /* ok, now this is a critical part that we do manually to avoid recursion */ { jclass cls = (*env)->GetObjectClass(env, x); if (cls) { jstring cname; jmethodID mid = (*env)->GetMethodID(env, cls, "toString", "()Ljava/lang/String;"); if (mid) { jstring s = (jstring)(*env)->CallObjectMethod(env, x, mid); if (s) { const char *c = (*env)->GetStringUTFChars(env, s, 0); if (c) { msg = PROTECT(mkString(c)); (*env)->ReleaseStringUTFChars(env, s, c); } } } /* beside toString() we also need to call getName() on cls to get the subclass */ cname = (jstring) (*env)->CallObjectMethod(env, cls, mid_getName); if (cname) { const char *c = (*env)->GetStringUTFChars(env, cname, 0); if (c) { /* convert full class name to JNI notation */ char *cn = strdup(c), *d = cn; while (*d) { if (*d == '.') *d = '/'; d++; } xclass = mkString(cn); free(cn); (*env)->ReleaseStringUTFChars(env, cname, c); } (*env)->DeleteLocalRef(env, cname); } if ((*env)->ExceptionOccurred(env)) (*env)->ExceptionClear(env); (*env)->DeleteLocalRef(env, cls); } else (*env)->ExceptionClear(env); if (!msg) msg = PROTECT(mkString("Java Exception ")); } /* delete the local reference to the exception (jobjRef has a global copy) */ (*env)->DeleteLocalRef(env, x); /* construct the jobjRef */ xr = PROTECT(NEW_OBJECT(MAKE_CLASS("jobjRef"))); if (inherits(xr, "jobjRef")) { SET_SLOT(xr, install("jclass"), xclass ? xclass : mkString("java/lang/Throwable")); SET_SLOT(xr, install("jobj"), xobj); } /* and off to R .. (we're keeping xr and clazzes protected) */ throwR(msg, xr, clazzes); /* throwR never returns so don't even bother ... */ } /* clear any pending exceptions */ HIDE void clx(JNIEnv *env) { if (env && (*env)->ExceptionOccurred(env)) (*env)->ExceptionClear(env); } #ifdef JNI_CACHE HIDE JNIEnv *getJNIEnvSafe(); HIDE JNIEnv *getJNIEnv() { return (use_eenv)?eenv:getJNIEnvSafe(); } HIDE JNIEnv *getJNIEnvSafe() #else HIDE JNIEnv *getJNIEnv() #endif { JNIEnv *env; jsize l; jint res; if (!jvm) { /* we're hoping that the JVM pointer won't change :P we fetch it just once */ res = JNI_GetCreatedJavaVMs(&jvm, 1, &l); if (res != 0) { error("JNI_GetCreatedJavaVMs failed! (result:%d)",(int)res); return 0; } if (l < 1) error("No running JVM detected. Maybe .jinit() would help."); if (!rJava_initialized) error("rJava was called from a running JVM without .jinit()."); } res = (*jvm)->AttachCurrentThread(jvm, (void**) &env, 0); if (res!=0) { error("AttachCurrentThread failed! (result:%d)", (int)res); return 0; } if (env && !eenv) eenv=env; /* if (eenv!=env) fprintf(stderr, "Warning! eenv=%x, but env=%x - different environments encountered!\n", eenv, env); */ return env; } REP void RuseJNICache(int *flag) { if (flag) use_eenv=*flag; } rJava/NAMESPACE0000644000176200001440000000225512256051760012544 0ustar liggesusersexportPattern("^\\.j") export( "J" ) export( "%instanceof%" ) export( clone ) S3method( clone, default ) export(is.jnull, .r2j, .rJava.base.path, toJava) exportClasses(jobjRef, jarrayRef, jrectRef, jfloat, jlong, jbyte, jchar, jclassName) exportMethods(show, "$", "$<-", "==", "!=", "<", ">", "<=", ">=", names, new, as.character, length, head, tail, "[", "[[", "[[<-", str, "dim<-", unique, duplicated, anyDuplicated, sort, rev, min, max, range, rep, clone ) import(methods) importFrom(utils,head) importFrom(utils,tail) importFrom(utils,str) S3method(with, jobjRef) S3method(with, jarrayRef) S3method(with, jclassName) S3method(within, jobjRef) S3method(within, jarrayRef) S3method(within, jclassName) # within requires that with.jobjRef is visible outside export(with.jobjRef) if( exists( ".DollarNames", asNamespace("utils") ) ) importFrom( utils, .DollarNames ) S3method(.DollarNames, jobjRef) S3method(.DollarNames, jarrayRef) S3method(.DollarNames, jrectRef) S3method(.DollarNames, jclassName) S3method( as.list, jobjRef ) S3method( as.list, jarrayRef ) S3method( as.list, jrectRef ) S3method( "$", "Throwable" ) S3method( "$<-", "Throwable" ) export( javaImport ) rJava/getsp.class0000644000176200001440000000242112256051760013471 0ustar liggesusers-Q%123CLADEFGH        ! " # $ 4( 4/ =. >) ?, @- I& K9 M/ N* O' P+ ()I()Ljava/lang/String;()V(I)C(II)Ljava/lang/String;&(Ljava/lang/Object;)Ljava/lang/String;(Ljava/lang/String;)I&(Ljava/lang/String;)Ljava/lang/String;,(Ljava/lang/String;)Ljava/lang/StringBuffer;(Ljava/lang/String;)V([Ljava/lang/String;)V-L-libs.Code ConstantValue ExceptionsLineNumberTableLjava/io/PrintStream;LocalVariables SGILineNumber SourceFileappendcharAt compareTo getPropertygetsp getsp.javajava.library.pathjava/io/PrintStreamjava/lang/Objectjava/lang/Stringjava/lang/StringBufferjava/lang/Systemlengthmainoutpath.separatorprintln substringtoStringvalueOf!  J05N ***2L**2LM>6:::6 6,6h ,U,: `6 = Y+  Y+ :*28^ !' , / 6 : OUXhqv;4(5* 8;<B;rJava/install-sh0000755000176200001440000001440612256051760013332 0ustar liggesusers#!/bin/sh # # install - install a program, script, or datafile # # This originates from X11R5 (mit/util/scripts/install.sh), which was # later released in X11R6 (xc/config/util/install.sh) with the # following copyright and license. # # Copyright (C) 1994 X Consortium # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to # deal in the Software without restriction, including without limitation the # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or # sell copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- # TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # # Except as contained in this notice, the name of the X Consortium shall not # be used in advertising or otherwise to promote the sale, use or other deal- # ings in this Software without prior written authorization from the X Consor- # tium. # # # FSF changes to this file are in the public domain. # # Calling this script install-sh is preferred over install.sh, to prevent # `make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. It can only install one file at a time, a restriction # shared with many OS's install programs. # set DOITPROG to echo to test this script # Don't use :- since 4.3BSD and earlier shells don't like it. doit="${DOITPROG-}" # put in absolute paths if you don't have them in your path; or use env. vars. mvprog="${MVPROG-mv}" cpprog="${CPPROG-cp}" chmodprog="${CHMODPROG-chmod}" chownprog="${CHOWNPROG-chown}" chgrpprog="${CHGRPPROG-chgrp}" stripprog="${STRIPPROG-strip}" rmprog="${RMPROG-rm}" mkdirprog="${MKDIRPROG-mkdir}" transformbasename="" transform_arg="" instcmd="$mvprog" chmodcmd="$chmodprog 0755" chowncmd="" chgrpcmd="" stripcmd="" rmcmd="$rmprog -f" mvcmd="$mvprog" src="" dst="" dir_arg="" while [ x"$1" != x ]; do case $1 in -c) instcmd="$cpprog" shift continue;; -d) dir_arg=true shift continue;; -m) chmodcmd="$chmodprog $2" shift shift continue;; -o) chowncmd="$chownprog $2" shift shift continue;; -g) chgrpcmd="$chgrpprog $2" shift shift continue;; -s) stripcmd="$stripprog" shift continue;; -t=*) transformarg=`echo $1 | sed 's/-t=//'` shift continue;; -b=*) transformbasename=`echo $1 | sed 's/-b=//'` shift continue;; *) if [ x"$src" = x ] then src=$1 else # this colon is to work around a 386BSD /bin/sh bug : dst=$1 fi shift continue;; esac done if [ x"$src" = x ] then echo "install: no input file specified" exit 1 else true fi if [ x"$dir_arg" != x ]; then dst=$src src="" if [ -d $dst ]; then instcmd=: chmodcmd="" else instcmd=mkdir fi else # Waiting for this to be detected by the "$instcmd $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if [ -f $src -o -d $src ] then true else echo "install: $src does not exist" exit 1 fi if [ x"$dst" = x ] then echo "install: no destination specified" exit 1 else true fi # If destination is a directory, append the input filename; if your system # does not like double slashes in filenames, you may need to add some logic if [ -d $dst ] then dst="$dst"/`basename $src` else true fi fi ## this sed command emulates the dirname command dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` # Make sure that the destination directory exists. # this part is taken from Noah Friedman's mkinstalldirs script # Skip lots of stat calls in the usual case. if [ ! -d "$dstdir" ]; then defaultIFS=' ' IFS="${IFS-${defaultIFS}}" oIFS="${IFS}" # Some sh's can't handle IFS=/ for some reason. IFS='%' set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` IFS="${oIFS}" pathcomp='' while [ $# -ne 0 ] ; do pathcomp="${pathcomp}${1}" shift if [ ! -d "${pathcomp}" ] ; then $mkdirprog "${pathcomp}" else true fi pathcomp="${pathcomp}/" done fi if [ x"$dir_arg" != x ] then $doit $instcmd $dst && if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi else # If we're going to rename the final executable, determine the name now. if [ x"$transformarg" = x ] then dstfile=`basename $dst` else dstfile=`basename $dst $transformbasename | sed $transformarg`$transformbasename fi # don't allow the sed command to completely eliminate the filename if [ x"$dstfile" = x ] then dstfile=`basename $dst` else true fi # Make a temp file name in the proper directory. dsttmp=$dstdir/#inst.$$# # Move or copy the file name to the temp name $doit $instcmd $src $dsttmp && trap "rm -f ${dsttmp}" 0 && # and set any options; do chmod last to preserve setuid bits # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $instcmd $src $dsttmp" command. if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && # Now rename the file to the real destination. $doit $rmcmd -f $dstdir/$dstfile && $doit $mvcmd $dsttmp $dstdir/$dstfile fi && exit 0 rJava/version0000755000176200001440000000024112256051760012731 0ustar liggesusers#!/bin/sh VER=`awk -v ORS= '/rJava v/ { print substr($6,2) }' src/rJava.h` if test "$1" == "-f"; then echo "rJava_${VER}.tar.gz" else echo "${VER}" fi rJava/NEWS0000644000176200001440000005044712256051760012032 0ustar liggesusers NEWS/ChangeLog for rJava -------------------------- 0.9-6 2012-12-23 o bugfix: the first JVM parameters was shadowed by headless mode parameter if enabled (default on OS X). 0.9-5 2012-12-03 o add more debugging information in RJavaClassLoader to trace cases where class path entries are invalid or discarded o detect support for -Xrs and enable it by default (this prevents Java from killing R process on interrupt) o restore locales after Java initialization (some JVMs clobber locales with incompatible settings). o add --enable-headless option which sets the java.awt.headless to true. In the auto mode this flag is only enabled on Mac OS X. Note that it is only set upon initialization, it does not affect already running JVMs. 0.9-4 2013-03-11 o added support for unboxing of Double[], Integer[] and Boolean[] to .jevalArray(.., simplify=TRUE) and thus also to .jcall() o Windows: add Java configuartion paths before existing PATH entries o Windows: honor a new option "java.home" to override JAVA_HOME environment variable and system settings to allow co-existence of other tools that may require differen Java paths. o Windows: fix a buglet in error reporting when no Java is installed o raise an error if the number of arguments to a Java call exceeds maxJavaPars. Previously, calls woud be silently truncated. Note that maxJavaPars can be raised by compiling rJava, e.g. with: PKG_CFLAGS=-DmaxJavaPars=96 R CMD INSTAL rJava_... 0.9-3 2011-12-10 o bugfix: .jinit() was failing on Java 1.4 with "cannot obtain Class.getSimpleName method ID" since the method is only present in Java 1.5+ This was inadvertent, rJava aims to support Java 1.2+ 0.9-2 2011-10-26 o When NOAWT is set, rJava will enable headless mode in the JVM by setting the java.awt.headless property to true during initialization in .jinit() o All C-level entry points are now pre-cached when rJava is loaded such that calls can be made much faster since symbols don't need to be looked up. This should speed up calls to methods that take very little time as well as other parts such as checking for exceptions. 0.9-1 2011-06-28 o fixed Java detection from registry on Windows (bug introduced in 0.9-0) 0.9-0 2011-06-22 o fixes issues introduced by several new features in the late 0.8 series. Most imporantly .jarray() and .jevalArray() behave as intended (and as implemented in previous versions). The same applies to .jcall() behavior with respect to arrays and its evalArray arument. The defaults for some new arguments have been changed to reflect the original behavior. o .jevalArray() has an additional argument `simplify' which allows multi-dimensional arrays to be converted to native R types. Use with care - it may convert more recursive types in the future so it should be used preferrably where you have control over the types converted. o fixed a bug in .jevalArray that was not simplifying string vectors correctly when the array type was not specified (.jclass returns dot notation whereas signatures use JNI notation so a conversion was necessary) o use install.libs.R in R 2.13.1 to install multi-arch JRI 0.8-8 2010-12-20 o Add support for r.arch in RJavaClassLoader on Windows as well o javaImport was only able to import java packages from the system class loader (not from additional jars) 0.8-7 2010-10-18 o Windows updates to accomodate changes in R 2.12 and layout changes in recent Sun Java installations. 0.8-6 2010-09-17 o JRI 0.5-4: rniStop() provides several ways to notify R on unix. It improves handing of user interrupts via rniStop() by allowing to avoid signals (signals can cause problems in some recent JVM implementations). 0.8-5 2010-09-02 o fix a bug introduced in 0.8-2 where .jclassPath() would not show the real class path o if the rJava class loader is used as a primary loader it will also register as the context class loader. Some projects rely on the thread context class loader instead of Class.getClassLoader() [which is still more reliable] so those will now work as well. o JRI 0.5-3 (bugfixes) 0.8-4 2010-04-28 o JRI 0.5-2 IMPORTANT NOTE: handling of NAs in character vectors has been fixed, NAs were incorrectly passed as "NA" from R to Java instead of nulls (it was correct the other way round). Any code that relies on such incorrect behavior will need to be fixed! Other changes in JRI are mostly related to Windows support (bugfixes R 2.11.0 and Windows 64-bit support) o run.bat is now installed as part of JRI 0.8-3 2010-03-16 o REngine and JRIEngine classes are now included in rJava/JRI although they are not loaded by default. o .r2j now has convert parameter to allow the creation of pure references (convert=FALSE) o toJava() is a new function equivalent to .r2j but resulting in REngine API references (instances of REXPReference). By default the references are not resolved since the primary use is to pass R functions to Java for callbacks. o set text mode for stdin on Windows (thanks to Brian Ripley) o fix support of NULL arguments in new(J("SomeClass"), ...) o fixed issues in with() and within() when used on jobjRef; also the evaluation environment is now the parent frame as expected o disable AWT tests if NOAWT is set; enable a few more tests 0.8-2 2010-01-22 o faster class loader implementation o added support for 64-bit Windows (thanks to Brian Ripley) 0.8-1 2009-10-30 o fixed exception handling on Windows: the access to "call" was off for Windows builds causing incorrect "call" entries in exceptions which broke when encountered in try(). o fixed .jcall() which had inadvertently the default for use.true.class argument set to TRUE. That is considered a bug since it breaks the original behavior and is against the idea of .jcall being the low-level interface. 0.8-0 2009-10-27 o new exception handling was introduced: Java exceptions are mapped to Exception conditions which can be used to catch the exception at R level using e.g tryCatch. The class name automatically contains "Exception", "error" and "condition", as well as all the names (without package path) of the classes in the inheritance tree of the actual class of the Exception. This allows targetted handlers: tryCatch(.jnew("foo"), NoClassDefFoundError=function(e) ...) In addition JNI code now causes an error instead of a warning, however, some errors internal to JNI may not have an associated Java exception and thus will fire the usual simpleError condition. As a consequence of the new error handling exception objects are now supplied in e$jobj of the handler and .jgetEx() becomes obsolete. o added new high-level API using the "J" function. It replaces the previously used .J()/.jrnew() and .jrcall(). New Java objects are created using new(J("class"), ...) and static methods and fields are accessed using J("class")$... The corresponding implementation uses reflection in all cases. An additional class "jclassName" was created to support static calls to accessor methods such as $ and calls to new(). o [RF] arrays are now split in two classes : "jrectRef" for rectangular arrays, similar to R arrays, and jarrayRef for rugged arrays. Indexing of all arrays is supported using the double bracket indexer "[[" and "[[<-" The single indexer "[" is only currently implemented for rectangular arrays. This is experimental. Replacement ([<-) is not supported yet. o [RF] with.jclassName and within.jclassName is added to support "with" semantics on static fields and methods of java classes. Double <- J("java.lang.Double" ) with( Double, parseDouble( "10.2" ) ) o [RF] length.jarrayRef queries the number of objects in a java array. An exception is generated if the object is not an array. Also array$length can be used similary to array.length in java o [RF] .jcast gains arguments "check" and "convert.array". Their default value is FALSE for backwards compatibility with previous releases of rJava o [RF] Binary operators <, >, <=, >= to compare two objects where at least one is a java object reference. d <- new( J("java.lang.Double"), 0.0 ) d < 1.0 d < 1L Comparison of arrays is not currently supported o [RF] lapply and sapply may now be used on Iterable java objects such as Vector and java arrays. see ?as.list.jobjRef o [RF] The generic "clone" function is added, and an implementation for java objects. an Object must implement the Cloneable interface, otherwise an exception will be raised. Furthermore, careful reading of the java documentation of Object#clone is recommended since this is not standard java behaviour. Currently "clone" is not supported on arrays o [RF] A mechanism for "attach"ing java packages has been introduced, following the mechanism of the RObjectTables package from the OmegaHat project. This allows to "attach" a set of java package paths to R's search path: > attach( javaImport( "java.util", "java.lang" ) ) and then use classes from this package like this : > new( Vector ) > new( HashMap ) > new( Double, 10.2 ) > new( Integer, 10L ) > Collections$EMPTY_MAP This feature is currently __very__ experimental and is as dangerous as any other use of attach 0.7-1 (never released) o [RF] added .J high-level java constructor (based on reflection as opposed to complete match as .jnew does) o [RF] added .jinstanceof and instanceof operator o when loaded into another JVM (e.g. via JRI), rJava would crash on any call if .jinit() was missing. Now it correctly reports the error. o fixed synchronization issues in both JRI and REngine 0.7-0 2009-08-22 o fixed bug in $ getter of fields using old .jfield API o fixed a bug in .jevalArray which failed when the signature was specified directly (and subsequently .jfield failed in most cases) o improve speed of reflection-based API (.jrcall and `$') by using native array support in rJava o reflection API now returns NULL invisibly for void results o try to find the best match in reflection-based API using internal Java code (code and idea by Romain Francois) o added with() method for jobjRef (by Romain Francois), see http://romainfrancois.blog.free.fr/index.php? post/2009/06/17/with-semantics-for-java-objects-in-rJava o added names() method for jobjRef to facilitate code completion (based on code by RF: http://tr.im/w33B) o update to JRI 0.5-0 0.6-3 2009-06-14 o update to JRI 0.4-3 (adds REngine API, enhanced support for environments and references) o allow signatures longer than 256 bytes o added lib.loc parameter to .jpackage() 0.6-2 2009-01-26 o fix --enable-debug to really enable debug code o improve Windows setup (add only paths if they are not already listed and check thier presence first) and warn if the system suffers from PATH truncation bug (or PATH is truncated in general) [0.6-branch is created as a stable branch -- see trunk for development] 0.6-1 2008-12-23 o substitute $(JAVA_HOME) in configuration flags when necessary o flag generated strings as UTF-8 and convert incoming strings into UTF-8 (see note in ?.jcall for details) This should improve interoperability in non-UTF-8 locales (most prominent example is Windows) 0.6-0 2008-09-22 o add support for object cache - see .jcache() - based on Java serialization 0.5-2 (never released, turned into 0.6-0) o add direct support for raw vectors as method parameters (before .jarray(r) had to be used) o add .jserialize() and .junserialize() functions for Java-serialization (do not confuse with R serialization!) 0.5-1 2007-11-05 o fix crashes in Windows when Java calls the vfprintf hook o enhance Java environment checks, add more specific errors o add support for r.arch system property which allows multi-arch support on platforms that don't have fat binaries (e.g. Linux) 0.5-0 2007-08-22 o **API CHANGE** The order of arguments of .jfield has been changed to match the order used in .jcall and the return value is as expected and doesn't need .jsimplify anymore. o The implementation of .jfield no longer uses reflection it supports static fields and .jfield<-() was added. o Consolidate interface code for static/non-static calls. It is now possible to call a static method using a non-static object. o Add .jpackage function for initialization of Java packages. See documentation for details, packages should no longer use .jinit in their initialization code. o Add preliminary JRI support from R (see .jengine) o Prepare hooks for de-serialization o Add support for short Java type o Add support for convertors o Fix R-devel compatibility issues o Fix a memory leak in string array handling o Use Java settings from R for compilation o Add a custom class loader o Fix a bug in .jcastToArray that produced invalid signatures o Added support for [Z in .jevalArray o Fix a bug in .jarray missing [ prefix for native type arrays 0.4 branch has been branched off the trunk, see 0.4-branch for NEWS 0.4-13 2007-01-14 o Fix Java-side memory leaks (temporary parameters to methods were not propery released, thanks to Erik van Barneveld for supplying a reproducible example). o Fix a bug that caused only the first VM parameter to be passed on during initialization (thanks to Bernard Rosman for reporting). o .jmkref now accepts plain class names (with .) o Fix bug in .jarray (and underlying RcreateArray) that was returning wrong class name if the contents class was an array. o Add --enable-callbacks option to configure (disabled by default). The callbacks support is currently incomplete and experimental. o Update URL to http://www.rforge.net/rJava/ o Update to JRI 0.3-7 (LCons, createRJavaRef, assign XT_NONE) 0.4-12 2006-11-29 o Added documentation for .jthrow, .jclear and .jgetEx and a bugfix in .jgetEx o rJava now uses a namespace. This is still somewhat experimental, because rJava needs to perform some dirty tricks to unseal the namespace during initialization. Please test and report! o Update to JRI 0.3-6 (GIJ fix and fix for R-devel interface changes) 0.4-11 2006-10-10 o Replace variadic macros with wrappers (for compilers that don't support ISO C99). o Modify JNI error reporting - use warnings instead of direct stderr. o Update to JRI 0.3-5 0.4-10 2006-09-14 o Removed obsolete JNI 1.1 support that is no longer provided in JDK 1.6 and thus prevented rJava from being used with JDK 1.6 o Update to JRI 0.3-4 (change compilation to force Java 1.4 compatibility even when more recent JDK is used) 0.4-9 2006-09-12 o Update to JRI 0.3-3 which fixes API version mistake which 0.4-8 2006-09-11 o Added --enable-jri=auto option which will build JRI only if R shared library is present. It is now the default. o Update to JRI 0.3-2 (added boolean support) 0.4-7 2006-09-05 o .jevalArray now works with Java objects that have not been cast to a Java array explicitly. The function is now also documented properly. o Added .jgetEx and .jclear functions for querying and clearing of Java exceptions/throwables. o Added .jthrow to allow throwing of exceptions from R code. o Fixed a typo in .jrcall when handling string return values. 0.4-6 2006-08-20 o Fixed bug in initialization on Windows, introduced in 0.4-4 0.4-5 2006-06-24 o Added support for scalar bytes as .jbyte (byte arrays are still natively represented as RAW vectors) o Added .r2j function which allows to push R objects into Java as references. This works only if R is run via JRI, because it requires a working Rengine instance. 0.4-4 2006-06-21 o Fixed bug that prevented loading into existing VM if the classpath contained duplicate items. .jmergeClassPath now filters out duplicate paths. o .jcall and .jnew discard all named parameters that are passed as `...'. Named parameters are now reserved for future call options o Converted all S3-methods into S4 methods. Also `show' is now used instead of `print' and the output format was changed. o Protoype for jobjRef is now a valid null-Object o Added .jequals and corresponding ==, != op methods. Currently == and != operators feature the same behavior as .jequals(...,strict=FALSE), i.e. scalar non-Java objects are converted into Java objects if possible and then compared, so s <- .jnew("java/lang/String","foo") s == "foo" # returns TRUE o Added .jinherits which allows to check Java-side inheritance using JNI (= isAssignableTo). o Added .jfindClass and .jclassRef that return Java class object o Added check parameter to .jcall and .jnew that allows the caller to prevent implicit call to .jcheck It is mainly useful in cases where silent operation is desired (e.g. in conjunction with try). Additionally, silent parameter was added to .jnew o Added is.jnull which is like is.null but also returns TRUE if the supplied Java object is a null-reference o Added jlong class and .jlong function. Those were documented in the tutorial but never really implemented. Still, they may not be supported in all parts of rJava. WARNING: conversion between Java's long and R's jlong is lossy! R stores jlong in doubles so the conversion implies loss of precision. 0.4-3 2006-05-16 o improved, documented and fixed handling of fields .jfield is dedicated accessor with more options 0.4-2 2006-05-08 o Update to JRI 0.2-5 (no change in rJava) 0.4-1 2006-05-05 o Fixed bug in Windows initialization 0.4-0 2006-05-03 o JRI is now included in rJava 0.3-9 2006-04-20 o fixed a minor bug in Rglue.c that may prevent older compilers from compiling it. 0.3-8 2006-04-17 o .jinit has an additional parameter 'parameters' that allows users to pass additional parameters to the VM (such as -X...) o .jinit now uses a hack (defined in .jmergeClassPath) that allows us to modify the class path of a running VM. This may or may not work for a specific VM, because it is an ugly hack exploiting some implementational features of the VM. See .jmergeClassPath source for reference and explanation. o .jarray now supports the use of .jarray(x) where x is a Java reference. The documentation requires you to use .jarray(list(x)), but since the use of .jarray(x) seems to be a very common mistake, we may as well silently support it. o .jarray has an optional parameter contents.class which allows the global specification of the class type for arrays of objects. (Untested, use with care! In most cases .jcast is probably what you really want.) o Added some more support for floats, longs and byte arrays. (Again, untested) 0.3-7 2006-01-31 (non-public release) o New, experimental feature has been added - JNI cache. This feature can be enabled by passing --enable-jni-cache argument to configure. Normally, each time we access JVM we retrieve new JNI environment to make sure there are no threading issues. In single-threaded environment this is superfluous, so we may as well cache it. The idea is to reduce the overhead. However, the gain is not as huge as expected, so it is not enabled by default. Also note that threads and jni-cache are mutually exclusive. o Another even more experimental feature has been added - support for threads. This feature is enabled by using --enable-threads configure argument. When threads support is enabled, JVM is started on a thread separate from the main thread. Some implementations of AWT classes require this. However, it is not always safe to use, because R event loop is unaware of the separate thread and can deadlock it. 0.3-6 2006-01-30 0.3-5 2006-01-02 0.3-4 2005-12-28 0.3-3 2005-12-20 0.3 2005-12-19 [finalizers, arrays] 0.2 2005-09-03 [S4 classes] 0.1 2003-08-26 [initial release] rJava/R/0000755000176200001440000000000012256051760011522 5ustar liggesusersrJava/R/memprof.R0000644000176200001440000000020012256051760013302 0ustar liggesusers.jmemprof <- function(file = "-") { if (is.null(file)) file <- "" invisible(.Call(RJava_set_memprof, as.character(file))) } rJava/R/jri.R0000644000176200001440000000671412256051760012441 0ustar liggesusers## bindings into JRI ## warning: JRI REXP class has currently no finalizers! (RReleaseREXP must be used manually for now) ## warning: this produces JRI-API pbjects - that should go away! use toJava below .r2j <- function(x, engine = NULL, convert = TRUE) { if (is.null(engine)) engine <- .jcall("org/rosuda/JRI/Rengine","Lorg/rosuda/JRI/Rengine;","getMainEngine") if (!is(engine, "jobjRef")) stop("invalid or non-existent engine") new("jobjRef",jobj=.Call(PushToREXP,"org/rosuda/JRI/REXP",engine@jobj,engine@jclass,x,convert),jclass="org/rosuda/JRI/REXP") } toJava <- function(x, engine = NULL) { ## this is really the wrong place for all this REngine checking stuff, but so far .jengine uses JRI API only and legacy code may rely on that ## so this is the only place that assumes REngine API and thus will load it ... ec <- .jfindClass("org.rosuda.JRI.Rengine", silent=TRUE) if (is.jnull(ec)) { .jcheck(TRUE) stop("JRI is not loaded. Please start JRI first - see ?.jengine") } ec <- .jfindClass("org.rosuda.REngine.REngine", silent=TRUE) if (is.jnull(ec)) { .jcheck(TRUE) fn <- system.file("jri","REngine.jar",package="rJava") if (nzchar(fn)) .jaddClassPath(fn) fn <- system.file("jri","JRIEngine.jar",package="rJava") if (nzchar(fn)) .jaddClassPath(fn) ec <- .jfindClass("org.rosuda.REngine.REngine", silent=TRUE) if (is.jnull(ec)) { .jcheck(TRUE) stop("Cannot find REngine API classes. Please make sure you have installed and loaded the REngine API") } } if (is.null(engine)) engine <- .jcall("org/rosuda/REngine/REngine","Lorg/rosuda/REngine/REngine;","getLastEngine") if (is.jnull(engine)) { # no last engine, but there may be JRI engine already running ... me <- .jcall("org/rosuda/JRI/Rengine","Lorg/rosuda/JRI/Rengine;","getMainEngine", check=FALSE) .jcheck(TRUE) if (is.jnull(me)) stop("JRI is not running. Please start JRI first - see ?.jengine") engine <- .jnew("org/rosuda/REngine/JRI/JRIEngine", me) .jcheck(TRUE) } .jcheck(TRUE) if (!is(engine, "jobjRef")) stop("invalid or non-existent engine") new("jobjRef",jobj=.Call(PushToREXP,"org/rosuda/REngine/REXPReference",engine@jobj,"org/rosuda/REngine/REngine",x,NULL),jclass="org/rosuda/REngine/REXPReference") } .setupJRI <- function(new=TRUE) { ec <- .jfindClass("org.rosuda.JRI.Rengine", silent=TRUE) if (is.jnull(ec)) { .jcheck(TRUE) .jaddClassPath(system.file("jri","JRI.jar",package="rJava")) ec <- .jfindClass("org.rosuda.JRI.Rengine", silent=TRUE) .jcheck(TRUE) if (is.jnull(ec)) stop("Cannot find JRI classes") } me <- .jcall("org/rosuda/JRI/Rengine","Lorg/rosuda/JRI/Rengine;","getMainEngine", check=FALSE) .jcheck(TRUE) if (!is.jnull(me)) { if (!new) return(TRUE) warning("JRI engine is already running.") return(FALSE) } e <- .jnew("org/rosuda/JRI/Rengine") !is.jnull(e) } .jengine <- function(start=FALSE, silent=FALSE) { me <- NULL ec <- .jfindClass("org.rosuda.JRI.Rengine", silent=TRUE) .jcheck(TRUE) if (!is.jnull(ec)) { me <- .jcall("org/rosuda/JRI/Rengine","Lorg/rosuda/JRI/Rengine;","getMainEngine", check=FALSE) .jcheck(TRUE) } if (is.jnull(me)) { if (!start) { if (silent) return(NULL) stop("JRI engine is not running.") } .setupJRI(FALSE) me <- .jcall("org/rosuda/JRI/Rengine","Lorg/rosuda/JRI/Rengine;","getMainEngine", check=FALSE) .jcheck(TRUE) } if (is.jnull(me) && !silent) stop("JRI engine is not running.") me } rJava/R/reflection.R0000644000176200001440000002520112256051760013777 0ustar liggesusers### reflection functions - convenience function relying on the low-level ### functions .jcall/.jnew and friends ### reflection tools (inofficial so far, because it returns strings ### instead of the reflection objects - it's useful for quick checks, ### though) .jmethods <- function(o, name=NULL, as.obj=FALSE) { cl <- if (is(o, "jobjRef")) .jcall(o, "Ljava/lang/Class;", "getClass") else if (is(o, "jclassName")) o@jobj else .jfindClass(as.character(o)) ms<-.jcall(cl,"[Ljava/lang/reflect/Method;","getMethods") if (isTRUE(as.obj)) return(ms) ss<-unlist(lapply(ms,function(x) .jcall(x,"S","toString"))) if (!is.null(name)) grep(paste("\\.",name,"\\(",sep=''),ss,value=TRUE) else ss } .jconstructors <- function(o, as.obj=FALSE) { cl <- if (is(o, "jobjRef")) .jcall(o, "Ljava/lang/Class;", "getClass") else if (is(o, "jclassName")) o@jobj else .jfindClass(as.character(o)) cs<-.jcall(cl,"[Ljava/lang/reflect/Constructor;","getConstructors") if (isTRUE(as.obj)) return(cs) unlist(lapply(cs,function(x) .jcall(x,"S","toString"))) } ### this list maps R class names to Java class names for which the constructor does the necessary conversion (for use in .jrcall) .class.to.jclass <- c(character= "java/lang/String", jbyte = "java/lang/Byte", integer = "java/lang/Integer", numeric = "java/lang/Double", logical = "java/lang/Boolean", jlong = "java/lang/Long", jchar = "java/lang/Character", jshort = "java/lang/Short", jfloat = "java/lang/Float") ### Java classes that have a corresponding primitive type and thus a corresponding TYPE field to use with scalars .primitive.classes = c("java/lang/Byte", "java/lang/Integer", "java/lang/Double", "java/lang/Boolean", "java/lang/Long", "java/lang/Character", "java/lang/Short", "java/lang/Float") ### creates a valid java object ### if a is already a java object reference, all is good ### otherwise some primitive conversion occurs # this is used for internal purposes only, in particular # it does not dispatch arrays to jrectRef ._java_valid_object <- function(a) { if (is(a, "jobjRef")) a else if (is.null(a)) .jnull() else { cm <- match(class(a)[1], names(.class.to.jclass)) if (!any(is.na(cm))) { if (length(a) == 1) { y <- .jnew(.class.to.jclass[cm], a) if (.class.to.jclass[cm] %in% .primitive.classes) attr(y, "primitive") <- TRUE y } else .jarray(a, dispatch = FALSE) } else { stop("Sorry, parameter type `", cm ,"' is ambiguous or not supported.") } } } ### creates a list of valid java parameters, used in both .J and .jrcall ._java_valid_objects_list <- function( ... ) lapply(list(...), ._java_valid_object ) ### returns a list of Class objects ### this is used in both .J and .jrcall ._isPrimitiveReference <- function(x) isTRUE(attr(x, "primitive")) ._java_class <- function( x ){ if (is.jnull(x)) { if (is(x,"jobjRef")) .jfindClass(x@jclass) else .jclassObject } else { if (._isPrimitiveReference(x)) .jfield(x, "Ljava/lang/Class;", "TYPE") else .jcall(x, "Ljava/lang/Class;", "getClass") } } ._java_class_list <- function( objects_list ) lapply(objects_list, ._java_class ) ### reflected call - this high-level call uses reflection to call a method ### it is much less efficient than .jcall but doesn't require return type ### specification or exact matching of parameter types .jrcall <- function(o, method, ..., simplify=TRUE) { if (!is.character(method) | length(method) != 1) stop("Invalid method name - must be exactly one character string.") if (inherits(o, "jobjRef") || inherits(o, "jarrayRef")) cl <- .jcall(o, "Ljava/lang/Class;", "getClass") else cl <- .jfindClass(o) if (is.null(cl)) stop("Cannot find class of the object.") # p is a list of parameters that are formed solely by valid Java objects p <- ._java_valid_objects_list(...) # list of classes pc <- ._java_class_list( p ) # invoke the method directly from the RJavaTools class # ( this throws the actual exception instead of an InvocationTargetException ) j_p <- .jarray(p, "java/lang/Object" , dispatch = FALSE ) j_pc <- .jarray(pc, "java/lang/Class" , dispatch = FALSE ) r <- .jcall( "RJavaTools", "Ljava/lang/Object;", "invokeMethod", cl, .jcast(if(inherits(o,"jobjRef") || inherits(o, "jarrayRef")) o else cl, "java/lang/Object"), .jnew( "java/lang/String", method), j_p, j_pc, use.true.class = TRUE, evalString = simplify, evalArray = FALSE ) # null is returned when the return type of the method is void # TODO[romain]: not sure how to distinguish when the result is null but the # return type is not null if( is.jnull( r ) || is.null(r) ){ return( invisible( NULL ) ) } # simplify if needed and return the object if( is(r, "jarrayRef" ) && simplify ){ ._jarray_simplify( r ) } else if (simplify){ .jsimplify(r) } else { r } } ### reflected construction of java objects ### This uses reflection to call a suitable constructor based ### on the classes of the ... it does not require exact match between ### the objects and the constructor parameters ### This is to .jnew what .jrcall is to .jcall .J <- function(class, ...) { # allow non-JNI specifiation class <- gsub("\\.","/",class) # p is a list of parameters that are formed solely by valid Java objects p <- ._java_valid_objects_list(...) # list of classes pc <- ._java_class_list( p ) # use RJavaTools to find create the object o <- .jcall("RJavaTools", "Ljava/lang/Object;", "newInstance", .jfindClass(class), .jarray(p,"java/lang/Object", dispatch = FALSE ), .jarray(pc,"java/lang/Class", dispatch = FALSE ), evalString = FALSE, evalArray = FALSE, use.true.class = TRUE ) o } ### simplify non-scalar reference to a scalar object if possible .jsimplify <- function(o) { if (!inherits(o, "jobjRef") && !inherits(o, "jarrayRef")) return(o) cn <- .jclass(o, true=TRUE) if (cn == "java.lang.Boolean") .jcall(o, "Z", "booleanValue") else if (cn == "java.lang.Integer" || cn == "java.lang.Short" || cn == "java.lang.Character" || cn == "java.lang.Byte") .jcall(o, "I", "intValue") else if (cn == "java.lang.Number" || cn == "java.lang.Double" || cn == "java.lang.Long" || cn == "java.lang.Float") .jcall(o, "D", "doubleValue") else if (cn == "java.lang.String") .jstrVal(.jcast(o, "java/lang/String")) else o } #! ### get the value of a field (static class fields are not supported yet) #! .jrfield <- function(o, name, simplify=TRUE, true.class=TRUE) { #! if (!inherits(o, "jobjRef") && !inherits(o, "jarrayRef") && !is.character(o)) #! stop("Object must be a Java reference or class name.") #! if (is.character(o)) { #! cl <- .jfindClass(o) #! .jcheck(silent=TRUE) #! if (is.null(cl)) #! stop("class not found") #! o <- .jnull() #! } else { #! cl <- .jcall(o, "Ljava/lang/Class;", "getClass") #! o <- .jcast(o, "java/lang/Object") #! } #! f <- .jcall(cl, "Ljava/lang/reflect/Field;", "getField", name) #! r <- .jcall(f,"Ljava/lang/Object;","get",o) #! if (simplify) r <- .jsimplify(r) #! if (true.class && (inherits(r, "jobjRef") || inherits(r, "jarrayRef"))) { #! cl <- .jcall(r, "Ljava/lang/Class;", "getClass") #! cn <- .jcall(cl, "Ljava/lang/String;", "getName") #! if (substr(cn,1,1) != '[') #! r@jclass <- gsub("\\.","/",cn) #! } #! r #! } ### list the fields of a class or object .jfields <- function(o, name=NULL, as.obj=FALSE) { cl <- if (is(o, "jobjRef")) .jcall(o, "Ljava/lang/Class;", "getClass") else if (is(o, "jclassName")) o@jobj else .jfindClass(as.character(o)) f <- .jcall(cl, "[Ljava/lang/reflect/Field;", "getFields") if (isTRUE(as.obj)) return(f) fl <- unlist(lapply(f, function(x) .jcall(x, "S", "toString"))) if (!is.null(name)) grep(paste("\\.",name,"$",sep=''), fl) else fl } ._must_be_character_of_length_one <- function(name){ if( !is.character(name) || length(name) != 1L ){ stop( "'name' must be a character vector of length one" ) } } ### checks if the java object x has a field called name hasField <- function( x, name ){ ._must_be_character_of_length_one(name) .jcall("RJavaTools", "Z", "hasField", .jcast( x, "java/lang/Object" ), name) } hasJavaMethod <- function( x, name ){ ._must_be_character_of_length_one(name) .jcall("RJavaTools", "Z", "hasMethod", .jcast( x, "java/lang/Object" ), name) } hasClass <- function( x, name){ ._must_be_character_of_length_one(name) .jcall("RJavaTools", "Z", "hasClass", .jcast( x, "java/lang/Object" ), name) } ### the following ones are needed for the static version of $ classHasField <- function(x, name, static=FALSE) { if (is(x, "jclassName")) x <- x@jobj else if (!is(x, "jobjRef")) x <- .jfindClass(as.character(x)) ._must_be_character_of_length_one(name) .jcall("RJavaTools", "Z", "classHasField", x, name, static) } classHasMethod <- function(x, name, static=FALSE) { if (is(x, "jclassName")) x <- x@jobj else if (!is(x, "jobjRef")) x <- .jfindClass(as.character(x)) ._must_be_character_of_length_one(name) .jcall("RJavaTools", "Z", "classHasMethod", x, name, static) } classHasClass <- function(x, name, static=FALSE) { if (is(x, "jclassName")) x <- x@jobj else if (!is(x, "jobjRef")) x <- .jfindClass(as.character(x)) ._must_be_character_of_length_one(name) .jcall("RJavaTools", "Z", "classHasClass", x, name, static) } ### syntactic sugar to allow object$field and object$methods(...) ### first attempts to find a field of that name and then a method ._jobjRef_dollar <- function(x, name) { if (hasField(x, name) ){ .jfield(x, , name) } else if( hasJavaMethod( x, name ) ) { function(...) .jrcall(x, name, ...) } else if( hasClass(x, name) ) { cl <- .jcall( x, "Ljava/lang/Class;", "getClass" ) inner.cl <- .jcall( "RJavaTools", "Ljava/lang/Class;", "getClass", cl, name, FALSE ) new("jclassName", name=.jcall(inner.cl, "S", "getName"), jobj=inner.cl) } else if( is.character(name) && length(name) == 1L && name == "length" && isJavaArray(x) ){ length( x ) } else { stop( sprintf( "no field, method or inner class called '%s' ", name ) ) } } setMethod("$", c(x="jobjRef"), ._jobjRef_dollar ) ### support for object$field<-... ._jobjRef_dollargets <- function(x, name, value) { if( hasField( x, name ) ){ .jfield(x, name) <- value } x } setMethod("$<-", c(x="jobjRef"), ._jobjRef_dollargets ) # get a class name for an object .jclass <- function(o, true=TRUE) { if (true) .jcall(.jcall(o, "Ljava/lang/Class;", "getClass"), "S", "getName") else if( inherits( o, "jarrayRef" ) ) o@jsig else o@jclass } rJava/R/zzz.R.in0000644000176200001440000000036512256051760013113 0ustar liggesusers.onLoad <- function(libname, pkgname) { Sys.setenv("LD_LIBRARY_PATH"=paste(Sys.getenv("LD_LIBRARY_PATH"),"@JAVA_LD@",sep=':')) library.dynam("rJava", pkgname, libname) # pass on to the system-independent part .jfirst(libname, pkgname) } rJava/R/comparison.R0000644000176200001440000000320512256051760014017 0ustar liggesusers #' if a and b are compatable, #' in the sense of the java.util.Comparable interface #' then the result of the compareTo method is returned #' otherwise an error message is generated .jcompare <- function(a, b) { if (is.null(a)) a <- new("jobjRef") if (is.null(b)) b <- new("jobjRef") if( isJavaArray(a) || isJavaArray(b) ){ stop( "comparison (<,>,<=,>=) is not implemented for java arrays yet" ) } if( !is(a, "jobjRef" ) ) a <- ._java_valid_object( a ) if( !is(b, "jobjRef" ) ) b <- ._java_valid_object( b ) .jcall( "RJavaComparator", "I", "compare", .jcast(a), .jcast(b) ) } ._lower <- function(e1, e2){ .jcompare( e1, e2 ) <= 0L } ._greater <- function(e1, e2 ){ .jcompare( e1, e2 ) >= 0L } ._strictly_lower <- function(e1, e2 ){ .jcompare( e1, e2 ) < 0L } ._strictly_greater <- function(e1, e2 ){ .jcompare( e1, e2 ) > 0L } setMethod("<" , c(e1="jobjRef",e2="jobjRef"), ._strictly_lower ) setMethod("<" , c(e1="jobjRef") , ._strictly_lower ) setMethod("<" , c(e2="jobjRef") , ._strictly_lower ) setMethod(">" , c(e1="jobjRef",e2="jobjRef"), ._strictly_greater ) setMethod(">" , c(e1="jobjRef") , ._strictly_greater ) setMethod(">" , c(e2="jobjRef") , ._strictly_greater ) setMethod("<=", c(e1="jobjRef",e2="jobjRef"), ._lower ) setMethod("<=", c(e1="jobjRef") , ._lower ) setMethod("<=", c(e2="jobjRef") , ._lower ) setMethod(">=", c(e1="jobjRef",e2="jobjRef"), ._greater ) setMethod(">=", c(e1="jobjRef") , ._greater ) setMethod(">=", c(e2="jobjRef") , ._greater ) rJava/R/completion.R0000644000176200001440000000341612256051760014022 0ustar liggesusers# :tabSize=4:indentSize=4:noTabs=false:folding=explicit:collapseFolds=1: # S4 dispatch does not work for .DollarNames, so we'll use S3 # {{{ bring .DollarNames from the future if necessary if( !exists( ".DollarNames", envir = asNamespace("utils") ) ){ .DollarNames <- function(x, pattern) UseMethod(".DollarNames") } # }}} # {{{ support function to retrieve completion names from RJavaTools ### get completion names from RJavaTools classNamesMethod <- function (cl, static.only = TRUE ) { # TODO: return both from java instead of two java calls fieldnames <- .jcall( "RJavaTools", "[Ljava/lang/String;", "getFieldNames", cl, static.only ) methodnames <- .jcall( "RJavaTools", "[Ljava/lang/String;", "getMethodNames", cl, static.only ) c(fieldnames, methodnames) } # }}} # {{{ jclassName ._names_jclassName <- function(x){ c( "class", classNamesMethod(x@jobj, static.only = TRUE ) ) } .DollarNames.jclassName <- function(x, pattern = "" ){ grep( pattern, ._names_jclassName(x), value = TRUE ) } setMethod("names", c(x="jclassName"), ._names_jclassName ) # }}} # {{{ jobjRef ._names_jobjRef <- function(x){ classNamesMethod(.jcall(x, "Ljava/lang/Class;", "getClass"), static.only = FALSE ) } .DollarNames.jobjRef <- function(x, pattern = "" ){ grep( pattern, ._names_jobjRef(x), value = TRUE ) } setMethod("names", c(x="jobjRef"), ._names_jobjRef ) # }}} # {{{ jarrayRef and jrectRef ._names_jarrayRef <- function(x ){ c("length", classNamesMethod(.jcall(x, "Ljava/lang/Class;", "getClass"), static.only = FALSE ) ) } .DollarNames.jarrayRef <- .DollarNames.jrectRef <- function(x, pattern = ""){ grep( pattern, ._names_jarrayRef(x), value = TRUE ) } setMethod("names", c(x="jarrayRef"), ._names_jarrayRef ) setMethod("names", c(x="jrectRef"), ._names_jarrayRef ) # }}} rJava/R/arrays.R0000644000176200001440000006017512256051760013157 0ustar liggesusers# :tabSize=4:indentSize=4:noTabs=false:folding=explicit:collapseFolds=1: # {{{ utilities to deal with arrays #' Indicates if a object refers to a java array #' #' @param o object #' @return TRUE if the object is a java array, FALSE if not #' (including when the object is not even a java reference) isJavaArray <- function( o ){ if( ( is( o, "jobjRef" ) || is( o, "jarrayRef") || is( o, "jrectRef") ) && !is.jnull(o) ){ .jcall( "RJavaArrayTools", "Z", "isArray", .jcast(o) ) } else FALSE } ._must_be_java_array <- function( o, message = "object is not a java array" ){ if( !isJavaArray(o ) ){ stop( message ) } } isJavaArraySignature <- function( sig ){ identical( substr( sig, 1, 1 ), '[' ) } #' get the component type of a java array getComponentType <- function( o, check = TRUE ){ if( check ) ._must_be_java_array( o ) .jcall( .jcall( o, "Ljava/lang/Class;", "getClass" ), "Ljava/lang/Class;", "getComponentType" ) } ._jarray_simplify <- function( x ){ ._must_be_java_array( x ) clname <- .jclass(x, true = TRUE ) Array <- "java/lang/reflect/Array" obj <- switch( clname, # deal with array of primitive first "[I" = .Call(RgetIntArrayCont , x@jobj), "[J" = .Call(RgetLongArrayCont , x@jobj), "[Z" = .Call(RgetBoolArrayCont , x@jobj) , "[B" = .Call(RgetByteArrayCont , x@jobj) , "[D" = .Call(RgetDoubleArrayCont, x@jobj) , "[S" = .Call(RgetShortArrayCont , x@jobj) , "[C" = .Call(RgetCharArrayCont , x@jobj) , "[F" = .Call(RgetFloatArrayCont , x@jobj) , "[Ljava.lang.String;" = .Call(RgetStringArrayCont, x@jobj), # otherwise, just get the object x ) obj } # }}} # {{{ length #' get the length of the array ._length_java_array <- function(x){ if( isJavaArray( x ) ){ .jcall( "java/lang/reflect/Array", "I", "getLength", .jcast( x, check = FALSE, convert.array = FALSE) ) } else{ stop( "the supplied object is not a java array" ) } } setMethod( "length", "jarrayRef", ._length_java_array ) setMethod( "length", "jrectRef", ._length_java_array ) setGeneric( "str" ) setMethod("str", "jarrayRef", function(object, ...){ txt <- sprintf( "Formal class 'jarrayRef' [package \"rJava\"] with 2 slots ..@ jobj : ..@ jclass: chr \"%s\" ..@ jsig : chr \"%s\" ", object@jclass, object@jsig ) cat( txt ) } ) setMethod("str", "jrectRef", function(object, ...){ dim <- object@dimension dim.txt <- if( length( dim ) == 1L ){ sprintf( "int %d", dim ) } else { sprintf( "int[1:%d] %s", length(dim), paste( if( length(dim) > 6 ) c( dim[1:6], "...") else dim, collapse = " ") ) } txt <- sprintf( "Formal class 'jrectRef' [package \"rJava\"] with 2 slots ..@ jobj : ..@ jclass : chr \"%s\" ..@ jsig : chr \"%s\" ..@ dimension: %s ", object@jclass, object@jsig, dim.txt ) cat( txt ) } ) # }}} # {{{ single bracket indexing : [ # indexing of .jarrayRef # is is not quite clear what the proper result should be, because technically # [ should always return a jarrayRef, but it's not the most useful thing to do. # the code below (ab)uses drop to try to deal with that, but it's not optimal ... # ._jctype <- function(x) if (is.jnull(x)) NA else if(is(x, "jarrayRef")) x@jsig else paste("L", x@jclass, ";", sep='') # #' index a java array # #' # #' @param x a reference to a java array # #' @param i indexer (only 1D indexing supported so far) # #' @param drop if the result if of length 1, just return the java object instead of an array of length one # #' @param simplify further simplify the result # ._java_array_single_indexer <- function( x, i, j, drop, simplify = FALSE, silent = FALSE, ... ){ # # arrays only # # if( !silent ){ # if( ! missing( j ) ){ # warning( "only one dimensional indexing is currently supported in i, ignoring j argument" ) # } # dots <- list( ... ) # if( length(dots) ){ # unnamed.dots <- dots[ names(dots) == "" ] # if( length( unnamed.dots ) ){ # warning( "only one dimensional indexing is currently supported in [, ignoring ... arguments" ) # } # } # } # # # the component type of the array - maybe used to make # # arrays with the same component type, but of length 0 # component.type <- getComponentType( x, check = FALSE ) # # # 'eval' the array # ja <- .jevalArray( x ) # # # native type - use R subsetting and maybe remap to java # if (!is.list(ja)) { # # perform the subset # o <- ja[i] # # # return native type if simplify # if( simplify ){ # return(o) # } # # if( length(o) == 0L) { # # return an array of the same component type as the original array # # but of length 0 # return( .jcall( "java/lang/reflect/Array", "Ljava/lang/Object;", "newInstance", component.type, 0L ) ) # } else { # # drop makes no sense here # return( .jarray( o ) ) # } # } # # # the result an array of java objects # sl <- ja[i] # # if( length( sl ) == 0L ){ # # TODO: make simplify influencial here # # for example if x is int[] then we want to get integer(0) # return( .jcall( "java/lang/reflect/Array", "Ljava/lang/Object;", "newInstance", component.type, 0L ) ) # } else{ # # just return the array # return( .jarray( sl ) ) # } # } # ## this is all weird - we need to distinguish between x[i] and x[i,] yet S4 fails to do so ... setMethod( "[", signature( x = "jarrayRef" ), function(x, i, j, ..., drop = FALSE){ # the code above is not good enough .NotYetImplemented() } ) # }}} # {{{ double bracket indexing : [[ ._collectIndex <- function( i, j, ...){ dots <- list( ... ) unnamed.dots <- if( length( dots ) ){ dots[ names(dots) == "" ] } firstInteger <- function(.) as.integer(.)[1] firstIntegerOfEach <- function(.) sapply( ., firstInteger ) index <- c( if( !missing(i) ) firstInteger(i), if( !missing(j) ) firstInteger(j), if( !is.null(unnamed.dots) && length(unnamed.dots) ) firstIntegerOfEach( unnamed.dots ) ) } # R version of RJavaArrayTools#getDimensionLength # it only works on the signature so should be used with caution getDimensionLength <- function( x, true.class = TRUE ){ nchar( sub( "[^[]+", "", .jclass(x, true = true.class) ) ) } # R version of RJavaArrayTools#getObjectTypeName getObjectTypeName <- function( x, true.class=TRUE){ sub( "^[[]*(.*);?$", "\\1", .jclass(x, true = true.class) ) } ._java_array_double_indexer <- function( x, i, j, ..., evalArray = FALSE, evalString = FALSE ){ # initial checks ._must_be_java_array( x ) index <- ._collectIndex( i, j, ... ) if( !length(index) || is.null(index) ){ # return the full object x } else{ # shift one left (java style indexing starts from 0 ) index <- index - 1L depth <- getDimensionLength( x ) typename <- getObjectTypeName( x ) if( length( index) == depth ){ # we need to dispatch primitive if( isPrimitiveTypeName( typename ) ){ res <- switch( typename, # deal with array of primitive first "I" = .jcall( "RJavaArrayTools", "I", "getInt" , .jcast(x), index ) , "J" = .jcall( "RJavaArrayTools", "J", "getLong" , .jcast(x), index ) , "Z" = .jcall( "RJavaArrayTools", "Z", "getBoolean", .jcast(x), index ) , "B" = .jcall( "RJavaArrayTools", "B", "getByte" , .jcast(x), index ) , "D" = .jcall( "RJavaArrayTools", "D", "getDouble" , .jcast(x), index ) , "S" = .jcall( "RJavaArrayTools", "S", "getShort" , .jcast(x), index ) , "C" = .jcall( "RJavaArrayTools", "C", "getChar" , .jcast(x), index ) , "F" = .jcall( "RJavaArrayTools", "F", "getFloat" , .jcast(x), index ), stop( "wrong primitive" ) # should never happen ) return( res ) } } # otherwise use the Object version .jcall( "RJavaArrayTools", "Ljava/lang/Object;", "get", .jcast(x), index, evalArray = evalArray, evalString = evalString ) } } # this is the only case that makes sense: i is an integer or a numeric of length one # we cannot use logical indexing or indexing by name because there is no such thing in java setMethod( "[[", signature( x = "jarrayRef" ), function(x, i, j, ...){ ._java_array_double_indexer( x, i, j, ... ) } ) ._java_array_double_replacer <- function( x, i, j, ..., value ){ # initial checks ._must_be_java_array( x ) index <- ._collectIndex( i, j, ... ) if( !length(index) || is.null(index) ){ # allow for x[[]] <- value newArray( value , simplify = FALSE ) } else{ jvalue <- ._java_valid_object( value ) if( ._isPrimitiveReference( value ) ){ # then use a primitive version .jcall( "RJavaArrayTools", "V", "set", .jcast(x), index - 1L, value ) } else{ # use the Object version .jcall( "RJavaArrayTools", "V", "set", .jcast(x), index - 1L, .jcast( jvalue ) ) if( isJavaArray( jvalue ) ){ # rectangularity might have changed # we have no choice but to reset the array x <- newArray( jobj = x@jobj, signature = x@jsig ) } } x } } setReplaceMethod( "[[", signature( x = "jarrayRef" ), function(x, i, j, ..., value ){ ._java_array_double_replacer( x, i, j, ..., value = value) } ) # }}} # {{{ head and tail setGeneric( "head" ) setMethod("head", signature( x = "jarrayRef" ), function(x, n = 6L, ... ){ if( !isJavaArray( x ) ){ stop( "not a java array" ) } # FIXME : this only makes sense for 1d arays n_objs <- length(x) if( abs( n ) >= n_objs ){ return( x ) } len <- if( n > 0L ) n else n_objs + n x[seq_len(n), ... ] } ) setGeneric( "tail" ) setMethod("tail", signature( x = "jarrayRef" ), function(x, n = 6L, ... ){ if( !isJavaArray( x ) ){ stop( "not a java array" ) } # FIXME : this only makes sense for 1d arays n_objs <- length(x) if( abs( n ) >= n_objs ) return(x) if( n < 0L){ n <- n_objs + n } return( x[ seq.int( n_objs-n+1, n_objs ) , ... ] ) } ) # }}} # {{{ newArray - dispatch to jarrayRef or jrectRef #' creates a new jarrayRef or jrectRef depending on the rectangularity #' of the array #' #' @param o a jobjRef object #' @param simplify if TRUE and the result is a rectangular array #' of primitives, simplify it to an R object newArray <- function( o, simplify = TRUE, jobj, signature ){ if( !missing(jobj) ){ o <- new("jobjRef", jobj = jobj, jclass = signature) } if( !isJavaArray( o ) ){ stop( "o does not refer to a java array" ) } if( inherits( o, "jrectRef" ) ){ # no need to go further return(o) } clazz <- tojni( .jclass( o, true = TRUE ) ) wrapper <- .jnew("ArrayWrapper", .jcast(o) ) isRect <- .jcall( wrapper, "Z", "isRectangular" ) if( isRect ){ dims <- .jcall( wrapper, "[I", "getDimensions" ) if( !simplify ){ # no need to go further down, return a reference return( new( "jrectRef", jobj = o@jobj, jsig = clazz, jclass = clazz, dimension = dims ) ) } isprim <- .jcall( wrapper, "Z", "isPrimitive" ) typename <- .jcall( wrapper, "Ljava/lang/String;", "getObjectTypeName" ) isstrings <- identical( typename, "java.lang.String" ) if( !isprim && !isstrings ){ # cannot simplify, return a reference return( new( "jrectRef", jobj = o@jobj, jsig = clazz, jclass = clazz, dimension = dims ) ) } if( isprim || isstrings ){ # array of java primitives, we can translate this to R array out <- structure( switch( typename , "I" = .jcall( wrapper, "[I" , "flat_int" ), "Z" = .jcall( wrapper, "[Z" , "flat_boolean" ), "B" = .jcall( wrapper, "[B" , "flat_byte" ), "J" = .jlong( .jcall( wrapper, "[J" , "flat_long" ) ), "S" = .jshort( .jcall( wrapper, "[T" , "flat_short" ) ), # [T is remapped to [S in .jcall "D" = .jcall( wrapper, "[D" , "flat_double" ), "C" = .jchar( .jcall( wrapper, "[C" , "flat_char" ) ), "F" = .jfloat( .jcall( wrapper, "[F" , "flat_float" ) ), "java.lang.String" = .jcall( wrapper, "[Ljava/lang/String;", "flat_String" ), stop( sprintf("cannot simplify type : ", typename) ) # this should not happen ), dim = dims ) return( out ) } } else { # not a rectangular array -> jarrayRef new( "jarrayRef", jobj = o@jobj, jsig = clazz, jclass = clazz ) } } # }}} # {{{ [ indexing of rectangular arrays setMethod( "[", signature( x = "jrectRef" ), function(x, i, j, ..., simplify = FALSE, drop = TRUE ){ # first we extract th data as a flat (one dimensional) R array # called 'flat' dim <- x@dimension wrapper <- .jnew( "ArrayWrapper", .jcast(x) ) typename <- .jcall( wrapper, "Ljava/lang/String;", "getObjectTypeName" ) isprim <- .jcall( wrapper, "Z", "isPrimitive" ) flat <- switch( typename, "I" = .jcall( wrapper, "[I" , "flat_int" , evalArray = TRUE ), "Z" = .jcall( wrapper, "[Z" , "flat_boolean" , evalArray = TRUE ), "B" = .jcall( wrapper, "[B" , "flat_byte" , evalArray = TRUE ), "J" = .jcall( wrapper, "[J" , "flat_long" , evalArray = TRUE ), "S" = .jcall( wrapper, "[T" , "flat_short" , evalArray = TRUE ), # [T is remapped to [S in .jcall "D" = .jcall( wrapper, "[D" , "flat_double" , evalArray = TRUE ), "C" = .jcall( wrapper, "[C" , "flat_char" , evalArray = TRUE ) , "F" = .jcall( wrapper, "[F" , "flat_float" , evalArray = TRUE ), "java.lang.String" = .jcall( wrapper, "[Ljava/lang/String;" , "flat_String" , evalArray = TRUE ), .jcall( wrapper, "[Ljava/lang/Object;" , "flat_Object" , evalArray = TRUE ) ) # then we give to flat the correct dimensions if( length(dim) != 1L ){ dim( flat ) <- dim } # now we construct the call to '[' on flat. # this call uses all the regular R indexing call <- match.call( call = sys.call(sys.parent()) ) n.args <- nargs( ) e <- as.list( call )[ -(1:2) ] names.e <- names(e) if( any( have.name <- (names.e != "") ) ){ # we need to extract drop and simplify nam <- names.e[ have.name ] if( !all( nam %in% c("simplify", "drop", "i", "j" ) ) ){ stop( "only 'drop' and 'simplify' are allowed as named arguments, they need to be written exactly" ) } } if( missing(i) && missing(j) && all( names.e != "" ) ){ # special case with no indexing at all actual.call <- sprintf( "flat[ , drop = %s ]", as.character(drop) ) } else if( !missing(i) && missing(j) && all( names.e != "" ) ){ # special case where there is only one index actual.call <- sprintf( "flat[ %s , drop = %s ]", deparse(i), as.character(drop) ) } else{ # we need to be careful about the missing's # we cannot just do things like list(...) because with missings # it just does not work actual.call <- "flat[" itoken <- if( missing(i ) ) " " else deparse(i) jtoken <- if( missing(j ) ) " " else deparse(j) actual.call <- sprintf( "flat[ %s , %s", itoken, jtoken ) iii <- 1L for( a in e ){ if( missing(a) ){ actual.call <- sprintf( "%s , ", actual.call ) } else if( have.name[iii] ) { # we put both at the end } else { # not missing, not named actual.call <- sprintf( "%s, %s", actual.call, deparse(a) ) } iii <- iii + 1L } actual.call <- sprintf( "%s, drop = %s ]", actual.call, as.character(drop) ) } # now we eval the call subs <- eval( parse( text = actual.call ) ) # now if we need and can simplify it, we return the subsetted array as is # otherwise, we rewrap it to java if( simplify && (typename == "java.lang.String" || isprim ) ) subs else .jarray( subs, dispatch = TRUE ) } ) # }}} # {{{ dim.jrectRef setMethod( "dim", signature( x = "jrectRef" ), function(x) x@dimension ) setReplaceMethod( "dim", signature( x = "jrectRef" ), function(x, value){ expected_prod <- prod( x@dimension ) if( is.null( value ) ){ value <- expected_prod } else{ received_prod <- prod(value) if( received_prod != expected_prod ){ stop( sprintf("dims [product %d] do not match the length of object [%d]", received_prod, expected_prod ) ) } } dim <- x@dimension wrapper <- .jnew( "ArrayWrapper", .jcast(x) ) typename <- .jcall( wrapper, "Ljava/lang/String;", "getObjectTypeName" ) flat <- structure( switch( typename, "I" = .jcall( wrapper, "[I" , "flat_int" , evalArray = TRUE ), "Z" = .jcall( wrapper, "[Z" , "flat_boolean" , evalArray = TRUE ), "B" = .jcall( wrapper, "[B" , "flat_byte" , evalArray = TRUE ), "J" = .jcall( wrapper, "[J" , "flat_long" , evalArray = TRUE ), "S" = .jcall( wrapper, "[T" , "flat_short" , evalArray = TRUE ), # [T is remapped to [S in .jcall "D" = .jcall( wrapper, "[D" , "flat_double" , evalArray = TRUE ), "C" = .jcall( wrapper, "[C" , "flat_char" , evalArray = TRUE ) , "F" = .jcall( wrapper, "[F" , "flat_float" , evalArray = TRUE ), "java.lang.String" = .jcall( wrapper, "[Ljava/lang/String;" , "flat_String" , evalArray = TRUE ), .jcall( wrapper, "[Ljava/lang/Object;" , "flat_Object" , evalArray = TRUE ) ) , dim = value ) .jarray(flat, dispatch = TRUE) } ) # }}} PRIMITIVE_TYPES <- c( "I", "Z", "B", "J", "S", "D", "C", "F" ) isPrimitiveTypeName <- function( type, include.strings = TRUE ){ type %in% PRIMITIVE_TYPES || ( include.strings && identical( type, "java.lang.String" ) ) } PRIMITIVE_TYPES_RX <- sprintf( "^[[]+[%s]$" , paste( PRIMITIVE_TYPES, collapse = "" ) ) isPrimitiveArraySignature <- function( x, ... ){ regexpr( PRIMITIVE_TYPES_RX, x, ... ) > 0 } isArraySignature <- function( x ){ substr( x, 1, 1 ) == "[" } # {{{ unique.jarrayRef setGeneric( "unique" ) ._unique_jrectRef <- function( x, incomparables = FALSE, ...){ dim <- x@dimension if( length( dim ) > 1L ){ stop( "'unique' only implemented for 1d array so far" ) } typename <- .jcall( "RJavaArrayTools", "Ljava/lang/String;", "getObjectTypeName", .jcast(x) ) if( isPrimitiveTypeName( typename, include.strings = TRUE ) ){ .jarray( unique( .jevalArray( x ) ), dispatch = TRUE ) } else{ .jcall( "RJavaArrayTools", "[Ljava/lang/Object;", "unique", .jcast( x, "[Ljava/lang/Object;" ), evalArray = TRUE, simplify = TRUE ) } } setMethod( "unique", "jarrayRef", function(x, incomparables = FALSE, ...){ .NotYetImplemented() } ) setMethod( "unique", "jrectRef", ._unique_jrectRef ) # }}} # {{{ duplicated setGeneric( "duplicated" ) ._duplicated_jrectRef <- function( x, incomparables = FALSE, ...){ dim <- x@dimension if( length( dim ) > 1L ){ stop( "'duplicated' only implemented for 1d array so far" ) } typename <- .jcall( "RJavaArrayTools", "Ljava/lang/String;", "getObjectTypeName", .jcast(x) ) if( isPrimitiveTypeName( typename, include.strings = TRUE ) ){ duplicated( .jevalArray( x ) ) } else{ .jcall( "RJavaArrayTools", "[Z", "duplicated", .jcast( x, "[Ljava/lang/Object;" ), evalArray = TRUE ) } } setMethod( "duplicated", "jrectRef", ._duplicated_jrectRef ) setMethod( "duplicated", "jarrayRef", function( x, incomparables = FALSE, ...){ .NotYetImplemented() }) # }}} # {{{ anyDuplicated .base.has.anyDuplicated <- exists("anyDuplicated", asNamespace("base")) if (!.base.has.anyDuplicated) { anyDuplicated <- function(x, incomparables = FALSE, ...) UseMethod("anyDuplicated") } setGeneric( "anyDuplicated" ) ._anyduplicated_jrectRef <- function( x, incomparables = FALSE, ...){ dim <- x@dimension if( length( dim ) > 1L ){ stop( "'anyDuplicated' only implemented for 1d array so far" ) } typename <- .jcall( "RJavaArrayTools", "Ljava/lang/String;", "getObjectTypeName", .jcast(x) ) if( isPrimitiveTypeName( typename, include.strings = TRUE ) ){ anyDuplicated( .jevalArray( x ) ) } else{ .jcall( "RJavaArrayTools", "I", "anyDuplicated", .jcast( x, "[Ljava/lang/Object;" ), evalArray = TRUE ) + 1L } } setMethod( "anyDuplicated", "jrectRef", ._anyduplicated_jrectRef ) setMethod( "anyDuplicated", "jarrayRef", function( x, incomparables = FALSE, ...){ .NotYetImplemented() }) # }}} # {{{ flat #' utility to flatten an array flat <- function(x, simplify = FALSE){ stop( "undefined" ) } setGeneric( "flat") ._flat_jrectRef <- function( x, simplify = FALSE ){ dim <- dim(x) if( length(dim) == 1L ) { if( !simplify) x else x[ simplify = TRUE ] } else { x[ seq_len(prod(dim)), drop = TRUE, simplify = simplify ] } } setMethod( "flat", "jrectRef", ._flat_jrectRef ) setMethod( "flat", "jarrayRef", function(x, simplify=FALSE){ .NotYetImplemented() } ) # }}} # {{{ sort setGeneric( "sort" ) ._sort_jrectRef <- function( x, decreasing = FALSE, ...){ x <- flat( x ) dim <- x@dimension typename <- .jcall( "RJavaArrayTools", "Ljava/lang/String;", "getObjectTypeName", .jcast(x) ) if( isPrimitiveTypeName( typename, include.strings = TRUE ) ){ .jarray( sort( .jevalArray( x ), decreasing = decreasing ), dispatch = TRUE ) } else{ .jcall( "RJavaArrayTools", "[Ljava/lang/Object;", "sort", .jcast( x, "[Ljava/lang/Object;" ), decreasing, evalArray = TRUE, simplify = TRUE ) } } setMethod( "sort", "jrectRef", ._sort_jrectRef ) setMethod( "sort", "jarrayRef", function(x, decreasing=FALSE, ...){ .NotYetImplemented() }) # }}} # {{{ rev setGeneric( "rev" ) setMethod( "rev", "jrectRef", function(x){ x <- flat( x ) dim <- x@dimension typename <- .jcall( "RJavaArrayTools", "Ljava/lang/String;", "getObjectTypeName", .jcast(x) ) if( isPrimitiveTypeName( typename, include.strings = TRUE ) ){ .jarray( rev( .jevalArray( x ) ), dispatch = TRUE ) } else{ .jcall( "RJavaArrayTools", "[Ljava/lang/Object;", "rev", .jcast( x, "[Ljava/lang/Object;" ), evalArray = TRUE, simplify = TRUE ) } } ) setMethod( "rev", "jarrayRef", function(x){ .NotYetImplemented() }) # }}} # {{{ as.list # S4 dispatch does not work as.list.jarrayRef <- function(x, ... ){ .jevalArray( x ) } as.list.jrectRef <- function( x, ...){ .jevalArray( x ) } as.list.jobjRef <- function( x, ... ){ if( ! .jinstanceof( x, "java.lang.Iterable" ) ){ stop( "only objects that implements java.lang.Iterable can be converted to lists" ) } .jcall( "RJavaArrayTools", "[Ljava/lang/Object;", "getIterableContent", .jcast(x, "java/lang/Iterable") , evalArray = TRUE, ... ) } # }}} # {{{ min, max, range setMethod("min", "jrectRef", function(x, ...,na.rm=TRUE){ dim <- x@dimension typename <- .jcall( "RJavaArrayTools", "Ljava/lang/String;", "getObjectTypeName", .jcast(x) ) if( isPrimitiveTypeName( typename, include.strings = TRUE ) ){ min( x[simplify=TRUE], na.rm = na.rm ) } else{ summarizer <- .jnew( "RectangularArraySummary", .jcast(x), dim ) .jcall( summarizer, "Ljava/lang/Object;", "min", na.rm ) } } ) setMethod("min", "jarrayRef", function(x, ...,na.rm=TRUE){ .NotYetImplemented() }) setMethod("max", "jrectRef", function(x, ..., na.rm=TRUE){ dim <- x@dimension typename <- .jcall( "RJavaArrayTools", "Ljava/lang/String;", "getObjectTypeName", .jcast(x) ) if( isPrimitiveTypeName( typename, include.strings = TRUE ) ){ max( x[simplify=TRUE], na.rm = na.rm ) } else{ summarizer <- .jnew( "RectangularArraySummary", .jcast(x), dim ) .jcall( summarizer, "Ljava/lang/Object;", "max", na.rm ) } } ) setMethod("max", "jarrayRef", function(x, ..., na.rm=TRUE){ .NotYetImplemented() } ) setMethod("range", "jrectRef", function(x, ..., na.rm=TRUE){ dim <- x@dimension typename <- .jcall( "RJavaArrayTools", "Ljava/lang/String;", "getObjectTypeName", .jcast(x) ) if( isPrimitiveTypeName( typename, include.strings = TRUE ) ){ range( x[simplify=TRUE], na.rm = na.rm ) } else{ summarizer <- .jnew( "RectangularArraySummary", .jcast(x), dim ) .jcall( summarizer, "[Ljava/lang/Object;", "range", na.rm, evalArray = TRUE, simplify = TRUE ) } } ) setMethod("range", "jarrayRef", function(x, ..., na.rm=TRUE){ .NotYetImplemented() }) # }}} rJava/R/methods.R0000644000176200001440000000204612256051760013312 0ustar liggesusers## methods for jobjRef class ## ## additional methods ($ and $<-) are defined in reflection.R # show method # FIXME: this should show the class of the object instead of Java-Object setMethod("show", c(object="jobjRef"), function(object) { if (is.jnull(object)) show("Java-Object") else show(paste("Java-Object{", .jstrVal(object), "}", sep='')) invisible(NULL) }) setMethod("show", c(object="jarrayRef"), function(object) { show(paste("Java-Array-Object",object@jsig,":", .jstrVal(object), sep='')) invisible(NULL) }) # map R comparison operators to .jequals setMethod("==", c(e1="jobjRef",e2="jobjRef"), function(e1,e2) .jequals(e1,e2)) setMethod("==", c(e1="jobjRef"), function(e1,e2) .jequals(e1,e2)) setMethod("==", c(e2="jobjRef"), function(e1,e2) .jequals(e1,e2)) setMethod("!=", c(e1="jobjRef",e2="jobjRef"), function(e1,e2) !.jequals(e1,e2)) setMethod("!=", c(e1="jobjRef"), function(e1,e2) !.jequals(e1,e2)) setMethod("!=", c(e2="jobjRef"), function(e1,e2) !.jequals(e1,e2)) # other operators such as <,> are defined in comparison.R rJava/R/windows/0000755000176200001440000000000012256051760013214 5ustar liggesusersrJava/R/windows/FirstLib.R0000755000176200001440000000521612256051760015064 0ustar liggesusers.onLoad <- function(libname, pkgname) { OPATH <- Sys.getenv("PATH") javahome <- if (!is.null(getOption("java.home"))) getOption("java.home") else Sys.getenv("JAVA_HOME") if(!nchar(javahome)) { ## JAVA_HOME was not set explicitly find.java <- function() { for (root in c("HLM", "HCU")) for(key in c("Software\\JavaSoft\\Java Runtime Environment", "Software\\JavaSoft\\Java Development Kit")) { hive <- try(utils::readRegistry(key, root, 2), silent=TRUE) if (!inherits(hive, "try-error")) return(hive) } hive } hive <- find.java() if (inherits(hive, "try-error")) stop("JAVA_HOME cannot be determined from the Registry") if (!length(hive$CurrentVersion)) stop("No CurrentVersion entry in Software/JavaSoft registry! Try re-installing Java and make sure R and Java have matching architectures.") this <- hive[[hive$CurrentVersion]] javahome <- this$JavaHome paths <- dirname(this$RuntimeLib) # wrong on 64-bit } else paths <- character() if(is.null(javahome) || !length(javahome) || !nchar(javahome)) stop("JAVA_HOME is not set and could not be determined from the registry") #else cat("using JAVA_HOME =", javahome, "\n") ## we need to add Java-related library paths to PATH curPath <- OPATH paths <- c(paths, file.path(javahome, "bin", "client"), # 32-bit file.path(javahome, "bin", "server"), # 64-bit file.path(javahome, "bin"), # base (now needed for MSVCRT in recent Sun Java) file.path(javahome, "jre", "bin", "client")) # old 32-bit cpc <- strsplit(curPath, ";", fixed=TRUE)[[1]] ## split it up so we can check presence/absence of a path ## add paths only if they are not in already and they exist for (path in unique(paths)) if (!path %in% cpc && file.exists(path)) curPath <- paste(path, curPath, sep=";") ## set PATH only if it's not correct already (cannot use identical/isTRUE because of PATH name attribute) if (curPath != OPATH) { Sys.setenv(PATH = curPath) # check the resulting PATH - if they don't match then Windows has truncated it if (curPath != Sys.getenv("PATH")) warning("*** WARNING: your Windows system seems to suffer from truncated PATH bug which will likely prevent rJava from loading.\n Either reduce your PATH or read http://support.microsoft.com/kb/906469 on how to fix your system.") } library.dynam("rJava", pkgname, libname) Sys.setenv(PATH = OPATH) .jfirst(libname, pkgname) } rJava/R/options.R0000644000176200001440000000044412256051760013342 0ustar liggesusers.joptions <- function(...) { l <- list(...) if (length(l)==0) return(list()) if ("jni.cache" %in% names(l)) { v <- l[["jni.cache"]] if (!is.logical(v) || length(v)!=1) stop("jni.cache must be a logical vector of length 1") .C(RuseJNICache,v) invisible(NULL) } } rJava/R/exceptions.R0000644000176200001440000000175612256051760014037 0ustar liggesusers## functions for some basic exception handling # FIXME: should all these actually be deprecated or defunct ## poll for an exception .jgetEx <- function(clear=FALSE) { exo <- .Call(RpollException) if (is.null(exo)) return(NULL) x <- new("jobjRef", jobj=exo, jclass="java/lang/Throwable") if (clear) .jclear() x } ## explicitly clear any pending exceptions .jclear <- function() { .C(RclearException) invisible(NULL) } ## throw an exception .jthrow <- function(exception, message=NULL) { if (is.character(exception)) exception <- .jnew(exception, as.character(message)) if (is(exception, "jobjRef")) .Call(RthrowException, exception) else stop("Invalid exception.") } "$.Throwable" <- function( x, name ){ if( name %in% names(x) ){ x[[ name ]] } else{ ._jobjRef_dollar( x[["jobj"]], name ) } } "$<-.Throwable" <- function( x, name, value ){ if( name %in% names(x) ){ x[[ name ]] <- value } else{ ._jobjRef_dollargets( x[["jobj"]], name, value ) } x } rJava/R/import.R0000644000176200001440000000734612256051760013171 0ustar liggesusers IMPORTER <- ".__rjava__import" java_class_importers <- new.env() assign( ".namespaces", NULL, envir = java_class_importers ) getImporterFromNamespace <- function( nm, create = TRUE ){ .namespaces <- get(".namespaces", envir = java_class_importers ) if( !is.null( .namespaces ) ){ for( item in .namespaces ){ if( identical( item$nm, nm ) ){ return( item$importer ) } } } if( create ){ addImporterNamespace(nm) } } addImporterNamespace <- function( nm ){ importer <- .jnew( "RJavaImport", .jcast( .rJava.class.loader, "java/lang/ClassLoader" ) ) assign( ".namespaces", append( list( list( nm = nm, importer = importer ) ), get(".namespaces", envir = java_class_importers ) ), envir = java_class_importers ) importer } getImporterFromEnvironment <- function(env, create = TRUE){ if( isNamespace( env ) ){ getImporterFromNamespace( env ) } else if( exists(IMPORTER, envir = env ) ){ get( IMPORTER, envir = env ) } else if( create ){ addImporterNamespace(env) } } getImporterFromGlobalEnv <- function( ){ if( exists( "global", envir = java_class_importers ) ){ get( "global", envir = java_class_importers ) } else{ initGlobalEnvImporter() } } initGlobalEnvImporter <- function(){ importer <- .jnew( "RJavaImport", .jcast( .rJava.class.loader, "java/lang/ClassLoader" ) ) assign( "global", importer , envir = java_class_importers ) importer } import <- function( package = "java.util", env = sys.frame(sys.parent()) ){ if( missing(env) ){ caller <- sys.function(-1) env <- environment( caller ) if( isNamespace( env ) ){ importer <- getImporterFromNamespace( env ) } } else{ force(env) if( !is.environment( env ) ){ stop( "env is not an environment" ) } if( ! exists( IMPORTER, env ) || is.jnull( get( IMPORTER, envir = env ) ) ){ importer <- .jnew( "RJavaImport", .jcast( .rJava.class.loader, "java/lang/ClassLoader" ) ) if( isNamespace(env) ){ unlockBinding( IMPORTER, env = env ) assignInNamespace( IMPORTER, importer, envir = env ) } assign( IMPORTER, importer, envir = env ) } else{ importer <- get( IMPORTER, envir = env ) } } mustbe.importer( importer ) .jcall( importer, "V", "importPackage", package ) } is.importer <- function(x){ is( x, "jobjRef" ) && .jinherits( x, "RJavaImport" ) } mustbe.importer <- function(x){ if( !is.importer(x) ){ stop( "object not a suitable java package importer" ) } } #' collect importers getAvailableImporters <- function( frames = TRUE, namespace = TRUE, global = TRUE, caller = sys.function(-1L) ){ importers <- .jnew( "java/util/HashSet" ) addImporter <- function( importer ){ if( is.importer( importer ) ){ .jcall( importers, "Z", "add", .jcast(importer) ) } } if( isTRUE( global ) ){ addImporter( getImporterFromGlobalEnv() ) } if( isTRUE( frames ) ){ frames <- sys.frames() if( length(frames) > 1L ){ sapply( head( frames, -1L ), function(env) { if( !identical( env, .GlobalEnv ) ){ addImporter( getImporterFromEnvironment( env ) ) } } ) } } if( isTRUE( namespace ) ){ force(caller) env <- environment( caller ) if( isNamespace( env ) ){ addImporter( getImporterFromNamespace( env ) ) } } importers } #' lookup for a class name in the available importers lookup <- function( name = "Object", ..., caller = sys.function(-1L) ){ force(caller) importers <- getAvailableImporters(..., caller = caller) .jcall( "RJavaImport", "Ljava/lang/Class;", "lookup", name, .jcast( importers, "java/util/Set" ) ) } javaImport <- function( packages = "java.lang" ){ importer <- .jnew( "RJavaImport", .jcast( .rJava.class.loader, "java/lang/ClassLoader" ) ) .jcall( importer, "V", "importPackage", packages ) .Call( "newRJavaLookupTable" , importer, PACKAGE = "rJava" ) } rJava/R/0classes.R0000644000176200001440000000307612256051760013370 0ustar liggesusers## S4 classes (jobjRef is re-defined in .First.lib to contain valid jobj) #' java object reference setClass("jobjRef", representation(jobj="externalptr", jclass="character"), prototype=list(jobj=NULL, jclass="java/lang/Object")) #' rugged arrays setClass("jarrayRef", representation("jobjRef", jsig="character")) #' rectangular java arrays double[][] d = new double[m][n] setClass("jrectRef", representation("jarrayRef", dimension="integer" ) ) # we extend array here so that we can keep dimensions # in the helper functions below, the storage mode is # set when the objects are built # TODO: maybe an initialize method is needed here # TODO: maybe a validate method is needed here as well setClass("jfloat", representation("array" ) ) setClass("jlong", representation("array" ) ) setClass("jbyte", representation("array" ) ) setClass("jshort", representation("array" ) ) setClass("jchar", representation("array" ) ) # there is no way to distinguish between double and float in R, so we need to mark floats specifically .jfloat <- function(x) { storage.mode( x ) <- "double" new("jfloat", x ) } # the same applies to long .jlong <- function(x) { storage.mode( x ) <- "double" new("jlong", x) } # and byte .jbyte <- function(x) { storage.mode( x ) <- "integer" new("jbyte", x) } # and short .jshort <- function(x){ storage.mode( x ) <- "integer" new("jshort", x) } # and char (experimental) .jchar <- function(x){ storage.mode( x ) <- "integer" new("jchar", as.integer(x)) } rJava/R/tools.R0000644000176200001440000000121112256051760013000 0ustar liggesusers#' converts a java class name to jni notation tojni <- function( cl = "java.lang.Object" ){ gsub( "[.]", "/", cl ) } tojniSignature <- function( cl ){ sig <- tojni( cl ) if( isPrimitiveTypeName(sig) || isPrimitiveArraySignature(sig) ){ return( sig ) } n <- nchar( sig ) last <- substr( sig, n, n ) add.semi <- last != ";" first <- substr( sig, 1, 1 ) add.L <- ! first %in% c("L", "[" ) sig <- if( !add.L && !add.semi) sig else sprintf( "%s%s%s", if( add.L ) "L" else "", sig, if( add.semi ) ";" else "" ) sig } #' converts jni notation to java notation tojava <- function( cl = "java/lang/Object" ){ gsub( "/", ".", cl ) } rJava/R/serialize.R0000644000176200001440000000157212256051760013641 0ustar liggesusers## Java serialization/unserialization .jserialize <- function(o) { if (!is(o, "jobjRef")) stop("can serialize Java objects only") .jcall("RJavaClassLoader","[B","toByte",.jcast(o, "java.lang.Object")) } .junserialize <- function(data) { if (!is.raw(data)) stop("can de-serialize raw vectors only") o <- .jcall("RJavaClassLoader","Ljava/lang/Object;","toObjectPL",.jarray(data, dispatch = FALSE)) if (!is.jnull(o)) { cl<-try(.jclass(o), silent=TRUE) if (all(class(cl) == "character")) o@jclass <- gsub("\\.","/",cl) } o } .jcache <- function(o, update=TRUE) { if (!is(o, "jobjRef")) stop("o must be a Java object") if (!is.null(update) && (!is.logical(update) || length(update) != 1)) stop("update must be TRUE, FALSE of NULL") what <- update if (isTRUE(what)) what <- .jserialize(o) invisible(.Call(javaObjectCache, o@jobj, what)) } rJava/R/rep.R0000644000176200001440000000160312256051760012433 0ustar liggesusers# :tabSize=4:indentSize=4:noTabs=false:folding=explicit:collapseFolds=1: # {{{ rep setGeneric("rep") setMethod( "rep", "jobjRef", function( x, times = 1L, ... ){ .jcall( "RJavaArrayTools", "[Ljava/lang/Object;", "rep", .jcast(x), as.integer(times), evalArray = FALSE ) } ) setMethod( "rep", "jarrayRef", function(x, times = 1L, ...){ .NotYetImplemented() } ) setMethod( "rep", "jrectRef", function(x, times = 1L, ...){ .NotYetImplemented() } ) # }}} # {{{ clone clone <- function( x, ... ){ UseMethod( "clone" ) } clone.default <- function( x, ... ){ .NotYetImplemented() } setGeneric( "clone" ) setMethod( "clone", "jobjRef", function(x, ...){ .jcall( "RJavaArrayTools", "Ljava/lang/Object;", "cloneObject", .jcast( x ) ) } ) setMethod( "clone", "jarrayRef", function(x, ...){ .NotYetImplemented( ) } ) setMethod( "clone", "jrectRef", function(x, ...){ .NotYetImplemented( ) } ) # }}} rJava/R/converter.R0000644000176200001440000000175312256051760013662 0ustar liggesusers# in: Java -> R .conv.in <- new.env(parent=emptyenv()) .conv.in$. <- FALSE # out: R -> Java .conv.out <- new.env(parent=emptyenv()) .conv.out$. <- FALSE # --- internal fns .convert.in <- function(jobj, verify.class=TRUE) { jcl <- if (verify.class) .jclass(jobj) else gsub("/",".",jobj@jclass) cv <- .conv.in[[jcl]] if (!is.null(cv)) jobj else cv$fn(jobj) } .convert.out <- function(robj) { for (cl in class(robj)) { cv <- .conv.out[[cl]] if (!is.null(cv)) return(cv$fn(robj)) } robj } # external fns .jsetJConvertor <- function(java.class, fn) { if (is.null(fn)) { rm(list=java.class, envir=.conv.in) if (!length(ls(.conv.in))) .conv.in$. <- FALSE } else { .conv.in$. <- TRUE .conv.in[[java.class]] <- list(fn=fn) } } .jsetRConvertor <- function(r.class, fn) { if (is.null(fn)) { rm(list=r.class, envir=.conv.out) if (!length(ls(.conv.out))) .conv.out$. <- FALSE } else { .conv.out$. <- TRUE .conv.out[[r.class]] <- list(fn=fn) } } rJava/R/with.R0000644000176200001440000001226612256051760012627 0ustar liggesusers## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 2 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## ## Author: Romain Francois ._populate_with_fields_and_methods <- function( env, fields, methods, classes, data, only.static = FALSE ){ object <- if( only.static ) .jnull() else .jcast( data ) # fields if( !is.jnull(fields) ) { lapply( fields, function(x ){ n <- .jcall( x, "S", "getName" ) type <- .jcall( .jcall( x, "Ljava/lang/Class;", "getType"), "Ljava/lang/String;" , "getName" ) suffix <- switch( type, "boolean" = "Boolean", "byte" = "Byte", "char" = "Char", "double" = "Double", "float" = "Float", "int" = "Int", "long" = "Long", "short" = "Short", "" ) target <- switch( type, "boolean" = "Z", "byte" = "B", "char" = "C", "double" = "D", "float" = "F", "int" = "I", "long" = "L", "short" = "S", "Ljava/lang/Object;" ) set_method <- sprintf( "set%s", suffix) get_method <- sprintf( "get%s", suffix ) makeActiveBinding( n, function(v){ if( missing(v) ){ ## get .jcall( x, target, get_method, object ) } else { ## set .jcall( x, "V", set_method , object, v ) } }, env ) } ) } # methods if( !is.jnull(methods) ){ done.this <- NULL lapply( methods, function(m){ n <- .jcall( m, "S", "getName" ) if( n %in% done.this ) return() fallback <- tryCatch( match.fun( n ), error = function(e) NULL ) assign( n, function(...) { tryCatch( .jrcall( if(only.static) data@name else data , n, ...), error = function(e){ if( !is.null(fallback) && inherits(fallback, "function") ){ fallback( ... ) } } ) }, env ) done.this <<- c( done.this, n ) } ) } # classes if( !is.jnull( classes ) ){ lapply( classes, function( cl ){ name <- .jcall( cl, "S", "getSimpleName" ) assign( name, new("jclassName", name=.jcall(cl, "S", "getName"), jobj=cl), env ) } ) } } grabDots <- function( env, ...){ dots <- list(...) if( length( dots ) ){ dots.names <- names(dots) sapply( dots.names, function( name ){ if( name != "" ){ assign( name, dots[[ name ]], env ) } } ) } } with.jobjRef <- function( data, expr, ...){ env <- new.env( parent = parent.frame() ) clazz <- .jcall( data, "Ljava/lang/Class;", "getClass") fields <- .jcall( clazz, "[Ljava/lang/reflect/Field;", "getFields" ) methods <- .jcall( clazz, "[Ljava/lang/reflect/Method;", "getMethods" ) classes <- .jcall( clazz, "[Ljava/lang/Class;" , "getClasses" ) ._populate_with_fields_and_methods( env, fields, methods, classes, data, only.static = FALSE ) assign( "this", data, env ) grabDots( env, ... ) eval( substitute( expr ), env ) } within.jobjRef <- function(data, expr, ... ){ call <- match.call() call[[1]] <- as.name("with.jobjRef") eval( call, parent.frame() ) data } with.jarrayRef <- function( data, expr, ...){ env <- new.env( parent = environment() ) clazz <- .jcall( data, "Ljava/lang/Class;", "getClass") fields <- .jcall( clazz, "[Ljava/lang/reflect/Field;", "getFields" ) methods <- .jcall( clazz, "[Ljava/lang/reflect/Method;", "getMethods" ) classes <- .jcall( clazz, "[Ljava/lang/Class;" , "getClasses" ) ._populate_with_fields_and_methods( env, fields, methods, classes, data, only.static = FALSE ) assign( "this", data, env ) # add "length" pseudo field makeActiveBinding( "length", function(v){ if( missing( v ) ){ ._length_java_array( data ) } else{ stop( "cannot modify length of java array" ) } }, env ) grabDots( env, ... ) eval( substitute( expr ), env ) } within.jarrayRef <- function(data, expr, ... ){ call <- match.call() call[[1]] <- as.name("with.jarrayRef") eval( call, parent.frame() ) data } with.jclassName <- function( data, expr, ... ){ env <- new.env( parent = environment() ) clazz <- data@jobj static_fields <- .jcall( "RJavaTools", "[Ljava/lang/reflect/Field;", "getStaticFields", clazz ) static_methods <- .jcall( "RJavaTools", "[Ljava/lang/reflect/Method;", "getStaticMethods", clazz ) static_classes <- .jcall( clazz, "[Ljava/lang/Class;", "getClasses" ) ._populate_with_fields_and_methods( env, static_fields, static_methods, static_classes, data, only.static = TRUE ) grabDots( env, ... ) eval( substitute( expr ), env ) } within.jclassName <- function(data, expr, ... ){ call <- match.call() call[[1]] <- as.name("with.jclassName") eval( call, parent.frame() ) data } rJava/R/loader.R0000644000176200001440000000404612256051760013117 0ustar liggesusers.jaddClassPath <- function(path) { if (!length(path)) return(invisible(NULL)) if (!is.jnull(.rJava.class.loader)) invisible(.jcall(.rJava.class.loader,"V","addClassPath",as.character(path))) else { cpr <- try(.jmergeClassPath(paste(path,collapse=.Platform$path.sep)), silent=TRUE) invisible(!inherits(cpr, "try-error")) } } .jclassPath <- function() { if (is.jnull(.rJava.class.loader)) { cp <- .jcall("java/lang/System", "S", "getProperty", "java.class.path") unlist(strsplit(cp, .Platform$path.sep)) } else { .jcall(.rJava.class.loader,"[Ljava/lang/String;","getClassPath") } } .jaddLibrary <- function(name, path) { if (!is.jnull(.rJava.class.loader)) invisible(.jcall(.rJava.class.loader, "V", "addRLibrary", as.character(name)[1], as.character(path)[1])) } .jrmLibrary <- function(name) { ## FIXME: unimplemented } .jclassLoader <- function() { .rJava.class.loader } .jpackage <- function(name, jars='*', morePaths='', nativeLibrary=FALSE, lib.loc=NULL) { if (!.jniInitialized) .jinit() classes <- system.file("java", package=name, lib.loc=lib.loc) if (nchar(classes)) { .jaddClassPath(classes) if (length(jars)) { if (length(jars)==1 && jars=='*') { jars <- grep(".*\\.jar",list.files(classes,full.names=TRUE),TRUE,value=TRUE) if (length(jars)) .jaddClassPath(jars) } else .jaddClassPath(paste(classes,jars,sep=.Platform$file.sep)) } } if (any(nchar(morePaths))) { cl <- as.character(morePaths) cl <- cl[nchar(cl)>0] .jaddClassPath(cl) } if (is.logical(nativeLibrary)) { if (nativeLibrary) { libs <- "libs" if (nchar(.Platform$r_arch)) lib <- file.path("libs", .Platform$r_arch) lib <- system.file(libs, paste(name, .Platform$dynlib.ext, sep=''), package=name, lib.loc=lib.loc) if (nchar(lib)) .jaddLibrary(name, lib) else warning("Native library for `",name,"' could not be found.") } } else { .jaddLibrary(name, nativeLibrary) } invisible(TRUE) } rJava/R/jfirst.R0000644000176200001440000000502612256051760013151 0ustar liggesusers# this part is common to all platforms and must be invoked # from .First.lib after library.dynam # actual namespace environment of this package .env <- environment() # variables in the rJava environment that will be initialized *after* the package is loaded # they need to be pre-created at load time and populated later by .jinit .delayed.export.variables <- c(".jniInitialized", ".jclassObject", ".jclassString", ".jclassClass", ".jclass.int", ".jclass.double", ".jclass.float", ".jclass.boolean", ".jclass.void", ".jinit.merge.error") # variables that are delayed but not exported are added here .delayed.variables <- c(.delayed.export.variables, ".rJava.class.loader") # C entry points to register .register.addr <- c( # .Call "PushToREXP", "RJava_checkJVM", "RJava_needs_init", "RJava_new_class_loader", "RJava_primary_class_loader", "RJava_set_class_loader", "RJava_set_memprof", "RJavaCheckExceptions", "RcreateArray", "RgetBoolArrayCont", "RgetByteArrayCont", "RgetCharArrayCont", "RgetDoubleArrayCont", "RgetField", "RgetFloatArrayCont", "RgetIntArrayCont", "RgetLongArrayCont", "RgetNullReference", "RgetObjectArrayCont", "RgetShortArrayCont", "RgetStringArrayCont", "RidenticalRef", "RisAssignableFrom", "RpollException", "RsetField", "RthrowException", "javaObjectCache", # .External "RcreateObject", "RgetStringValue", "RinitJVM", "RtoString", # .C "RclearException", "RuseJNICache" ) .jfirst <- function(libname, pkgname) { # register all C entry points addr <- getNativeSymbolInfo(.register.addr, pkgname) for (name in .register.addr) .env[[name]] <- addr[[name]]$address assign(".rJava.base.path", paste(libname, pkgname, sep=.Platform$file.sep), .env) assign(".jzeroRef", .Call(RgetNullReference), .env) for (x in .delayed.variables) assign(x, NULL, .env) assign(".jniInitialized", FALSE, .env) # default JVM initialization parameters if (is.null(getOption("java.parameters"))) options("java.parameters"="-Xmx512m") ## S4 classes update - all classes are created earlier in classes.R, but jobjRef's prototype is only valid after the dylib is loaded setClass("jobjRef", representation(jobj="externalptr", jclass="character"), prototype=list(jobj=.jzeroRef, jclass="java/lang/Object"), where=.env) } rJava/R/J.R0000644000176200001440000000275112256051760012043 0ustar liggesuserssetClass("jclassName", representation(name="character", jobj="jobjRef")) jclassName <- function(class){ if( is( class, "jobjRef" ) && .jinherits(class, "java/lang/Class" ) ){ jobj <- class name <- .jcall( class, "Ljava/lang/String;", "getName", evalString = TRUE ) } else{ name <- gsub("/",".",as.character(class)) jobj <- .jfindClass(as.character(class)) } new("jclassName", name=name, jobj=jobj) } setGeneric("new") setMethod("new", signature(Class="jclassName"), function(Class, ...) .J(Class@name, ...)) setMethod("$", c(x="jclassName"), function(x, name) { if( name == "class" ){ x@jobj } else if (classHasField(x@jobj, name, TRUE)){ .jfield(x@name, , name) } else if (classHasMethod(x@jobj, name, TRUE)){ function(...) .jrcall(x@name, name, ...) } else if( classHasClass(x@jobj, name, FALSE) ){ inner.cl <- .jcall( "RJavaTools", "Ljava/lang/Class;", "getClass", x@jobj, name, FALSE ) new("jclassName", name=.jcall(inner.cl, "S", "getName"), jobj=inner.cl) } else { stop("no static field, method or inner class called `", name, "' in `", x@name, "'") } }) setMethod("$<-", c(x="jclassName"), function(x, name, value) .jfield(x@name, name) <- value) setMethod("show", c(object="jclassName"), function(object) invisible(show(paste("Java-Class-Name:",object@name)))) setMethod("as.character", c(x="jclassName"), function(x, ...) x@name) ## the magic `J' J<-function(class, method, ...) if (nargs() == 1L && missing(method)) jclassName(class) else .jrcall(class, method, ...) rJava/R/instanceof.R0000644000176200001440000000117012256051760013775 0ustar liggesusers`%instanceof%` <- .jinstanceof <- function( o, cl ){ if( !inherits( o, "jobjRef" ) ){ stop( "o is not a java object" ) } # first get the class object that represents cl if( inherits( cl, "jobjRef" ) ){ if( .jclass( cl ) == "java.lang.Class" ){ clazz <- cl } else { clazz <- .jcall( cl, "Ljava/lang/Class;", "getClass" ) } } else if( inherits( cl, "jclassName" ) ) { clazz <- cl@jobj } else if( inherits( cl, "character" ) ){ clazz <- .jfindClass(cl) } else { return(FALSE) } # then find out if o is an instance of the class .jcall( clazz , "Z", "isInstance", .jcast(o, "java/lang/Object" ) ) } rJava/R/call.R0000644000176200001440000003503212256051760012563 0ustar liggesusers## This file is part of the rJava package - low-level R/Java interface ## (C)2006 Simon Urbanek ## For license terms see DESCRIPTION and/or LICENSE ## ## $Id: call.R 578 2013-03-11 15:36:39Z urbanek $ # create a new object .jnew <- function(class, ..., check=TRUE, silent=!check) { class <- gsub("\\.", "/", as.character(class)) # allow non-JNI specifiation # TODO: should this do "S" > "java/lang/String", ... like .jcall if (check) .jcheck(silent=TRUE) o<-.External(RcreateObject, class, ..., silent=silent) if (check) .jcheck(silent=silent) if (is.null(o)) { if (!silent) { stop("Failed to create object of class `",class,"'") } else { o <- .jzeroRef } } new("jobjRef", jobj=o, jclass=class) } # create a new object reference manually (avoid! for backward compat only!) # the problem with this is that you need a valid `jobj' which # is implementation-dependent so it is undefined outside rJava internals # it is now used by JRI.createRJavaRef, though .jmkref <- function(jobj, jclass="java/lang/Object") { new("jobjRef", jobj=jobj, jclass=gsub('\\.','/',as.character(jclass))) } # evaluates an array reference. If rawJNIRefSignature is set, then obj is not assumed to be # jarrayRef, but rather direct JNI reference with the corresponding signature .jevalArray <- function(obj, rawJNIRefSignature=NULL, silent=FALSE, simplify=FALSE) { jobj<-obj sig<-rawJNIRefSignature if (is.null(rawJNIRefSignature)) { if(!inherits(obj,"jarrayRef")) { if (!inherits(obj,"jobjRef")) stop("object is not a Java object reference (jobjRef/jarrayRef).") cl <- gsub("\\.","/",.jclass(obj)) if (is.null(cl) || !isJavaArraySignature(cl) ) stop("object is not a Java array.") sig <- cl } else sig <- obj@jsig jobj<-obj@jobj } else if (is(obj, "jobjRef")) jobj<-obj@jobj if (sig=="[I") return(.Call(RgetIntArrayCont, jobj)) else if (sig=="[J") return(.Call(RgetLongArrayCont, jobj)) else if (sig=="[Z") return(.Call(RgetBoolArrayCont, jobj)) else if (sig=="[B") return(.Call(RgetByteArrayCont, jobj)) else if (sig=="[D") return(.Call(RgetDoubleArrayCont, jobj)) else if (sig=="[S") return(.Call(RgetShortArrayCont, jobj)) else if (sig=="[C") return(.Call(RgetCharArrayCont, jobj)) else if (sig=="[F") return(.Call(RgetFloatArrayCont, jobj)) else if (sig=="[Ljava/lang/String;") return(.Call(RgetStringArrayCont, jobj)) else if (sig=="[Ljava/lang/Double;" && simplify) { obj@jclass <- sig; return(.jcall("RJavaArrayTools", "[D", "unboxDoubles", obj)) } else if (sig=="[Ljava/lang/Integer;" && simplify) { obj@jclass <- sig; return(.jcall("RJavaArrayTools", "[I", "unboxIntegers", obj)) } else if (sig=="[Ljava/lang/Boolean;" && simplify) { obj@jclass <- sig; return(as.logical(.jcall("RJavaArrayTools", "[I", "unboxBooleans", obj))) } else if (substr(sig,1,2)=="[L") return(lapply(.Call(RgetObjectArrayCont, jobj), function(x) new("jobjRef", jobj=x, jclass=substr(sig, 3, nchar(sig)-1)) )) else if (substr(sig,1,2)=="[[") { if (simplify) { # try to figure out if this is a rectangular array in which case we can do better o <- newArray(simplify=TRUE, jobj=jobj, signature=sig) # if o is not a reference then we were able to simplify it if (!is(o, "jobjRef")) return(o) } # otherwise simplify has no effect return(lapply(.Call(RgetObjectArrayCont, jobj), function(x) newArray(jobj=x, signature=substr(sig, 2, 999), simplify=simplify))) } # if we don't know how to evaluate this, issue a warning and return the jarrayRef if (!silent) warning(paste("I don't know how to evaluate an array with signature",sig,". Returning a reference.")) newArray(jobj = jobj, signature = sig, simplify = FALSE) } .jcall <- function(obj, returnSig="V", method, ..., evalArray=TRUE, evalString=TRUE, check=TRUE, interface="RcallMethod", simplify=FALSE, use.true.class = FALSE) { if (check) .jcheck() iaddr <- .env[[interface]] interface <- if (is.null(iaddr)) getNativeSymbolInfo(interface, "rJava", TRUE, FALSE)$address else iaddr r<-NULL # S is a shortcut for Ljava/lang/String; if (returnSig=="S") returnSig<-"Ljava/lang/String;" if (returnSig=="[S") returnSig<-"[Ljava/lang/String;" # original S (short) is now mapped to T so we need to re-map it (we don't really support short, though) if (returnSig=="T") returnSig <- "S" if (returnSig=="[T") returnSig <- "[S" if (inherits(obj,"jobjRef") || inherits(obj,"jarrayRef") || inherits(obj,"jrectRef") ) r<-.External(interface, obj@jobj, returnSig, method, ...) else r<-.External(interface, as.character(obj), returnSig, method, ...) if (returnSig=="V") return(invisible(NULL)) if( use.true.class && !is.null( r ) ){ if( ! ( isPrimitiveTypeName(returnSig) || isArraySignature(returnSig) ) ){ # avoid calling .jcall since we work on external pointers directly here clazz <- .External(interface, r , "Ljava/lang/Class;", "getClass") clazzname <- .External(interface, clazz, "Ljava/lang/String;", "getName") clazzname <- .External(RgetStringValue, clazzname) returnSig <- tojniSignature( clazzname ) } } if (isJavaArraySignature(returnSig)) { # eval or return a reference r <- if (evalArray) .jevalArray(r, rawJNIRefSignature=returnSig, simplify=simplify) else newArray(jobj = r, signature = returnSig, simplify = FALSE) } else if ( substr(returnSig,1,1)=="L") { if (is.null(r)){ if( check ) .jcheck( silent = FALSE ) return(r) } if (returnSig=="Ljava/lang/String;" && evalString){ if( check ) .jcheck( silent = FALSE ) return(.External(RgetStringValue, r)) } r <- new("jobjRef", jobj=r, jclass=substr(returnSig,2,nchar(returnSig)-1)) } if (check) .jcheck() if (.conv.in$.) .convert.in(r) else r } .jstrVal <- function(obj) { # .jstrVal(.jstrVal(...)) = .jstrVal(...) if (is.character(obj)) return(obj) r<-NULL if (!is(obj,"jobjRef")) stop("can get value of Java objects only") if (!is.null(obj@jclass) && obj@jclass=="lang/java/String") r<-.External(RgetStringValue, obj@jobj) else r<-.External(RtoString, obj@jobj) r } #' casts java object into new.class #' #' @param obj a java object reference #' @param new.class the new class (in JNI or Java) #' @param check logical. If TRUE the cast if checked #' @param convert.array logical. If TRUE and the new class represents an array, then a jarrayRef object is made .jcast <- function(obj, new.class="java/lang/Object", check = FALSE, convert.array = FALSE) { if (!is(obj,"jobjRef")) stop("cannot cast anything but Java objects") if( check && !.jinstanceof( obj, new.class) ){ stop( sprintf( "cannot cast object to '%s'", new.class ) ) } new.class <- gsub("\\.","/", as.character(new.class)) # allow non-JNI specifiation if( convert.array && !is( obj, "jarrayRef" ) && isJavaArray( obj ) ){ r <- .jcastToArray( obj, signature = new.class) } else { r <- obj r@jclass <- new.class } r } # makes sure that a given object is jarrayRef .jcastToArray <- function(obj, signature=NULL, class="", quiet=FALSE) { if (!is(obj, "jobjRef")) return(.jarray(obj)) if (is.null(signature)) { # TODO: factor out these two calls into a separate function cl <- .jcall(obj, "Ljava/lang/Class;", "getClass") cn <- .jcall(cl, "Ljava/lang/String;", "getName") if ( !isJavaArraySignature(cn) ) { if (quiet) return(obj) else stop("cannot cast to array, object signature is unknown and class name is not an array") } signature <- cn } else{ if( !isJavaArraySignature(signature) ){ if( quiet ) { return( obj ) } else{ stop( "cannot cast to array, signature is not an array signature" ) } } } signature <- gsub('\\.', '/', signature) if (inherits(obj, "jarrayRef")) { obj@jsig <- signature return(obj) } newArray(obj, simplify=FALSE) } # creates a new "null" object of the specified class # although it sounds weird, the class is important when passed as # a parameter (you can even cast the result) .jnull <- function(class="java/lang/Object") { new("jobjRef", jobj=.jzeroRef, jclass=as.character(class)) } .jcheck <- function(silent=FALSE) invisible(.Call(RJavaCheckExceptions, silent)) .jproperty <- function(key) { if (length(key)>1) sapply(key, .jproperty) else .jcall("java/lang/System", "S", "getProperty", as.character(key)[1]) } #' gets the dim of an array, or its length if it is just a vector getDim <- function(x){ dim <- dim(x) if( is.null( dim ) ) dim <- length(x) dim } .jarray <- function(x, contents.class = NULL, dispatch = FALSE) { # this already is an array, so don't bother if( isJavaArray( x ) ) return( newArray( x, simplify = FALSE) ) # this is a two stage process, first we need to convert into # a flat array using the jni code # TODO: but this needs to move to the internal jni world to avoid # too many copies # common mistake is to not specify a list but just a single Java object # but, well, people just keep doing it so we may as well support it dim <- if (inherits(x,"jobjRef")) { x <- list(x) 1L } else getDim(x) # the jni call array <- .Call(RcreateArray, x, contents.class) if (!dispatch) return( array ) if( is.list( x ) ){ # if the input of RcreateArray was a list, we need some more care # because we cannot be sure the array is rectangular so we have to # check it newArray( array, simplify = FALSE ) } else { # then we transform this to a rectangular array of the proper dimensions if( length( dim ) == 1L ) { # single dimension array new( "jrectRef", jobj = array@jobj, jsig = array@jsig, jclass = array@jclass, dimension = dim ) } else { builder <- .jnew( "RectangularArrayBuilder", .jcast(array), dim ) clazz <- .jcall( builder, "Ljava/lang/String;", "getArrayClassName" ) # we cannot use .jcall here since it will try to simplify the array # or go back to java to calculate its dimensions, ... r <- .External( "RcallMethod", builder@jobj, "Ljava/lang/Object;", "getArray", PACKAGE="rJava") new( "jrectRef", jobj = r, dimension = dim, jclass = clazz, jsig = tojni( clazz ) ) } } } # works on EXTPTR or jobjRef or NULL. NULL is always silently converted to .jzeroRef .jidenticalRef <- function(a,b) { if (is(a,"jobjRef")) a<-a@jobj if (is(b,"jobjRef")) b<-b@jobj if (is.null(a)) a <- .jzeroRef if (is.null(b)) b <- .jzeroRef if (!inherits(a,"externalptr") || !inherits(b,"externalptr")) stop("Invalid argument to .jidenticalRef, must be a pointer or jobjRef") .Call(RidenticalRef,a,b) } # returns TRUE only for NULL or jobjRef with jobj=0x0 is.jnull <- function(x) { (is.null(x) || (is(x,"jobjRef") && .jidenticalRef(x@jobj,.jzeroRef))) } # should we move this to C? .jclassRef <- function(x, silent=FALSE) { if (is.jnull(x)) { if (silent) return(NULL) else stop("null reference has no class") } if (!is(x, "jobjRef")) { if (silent) return(NULL) else stop("invalid object") } cl <- NULL try(cl <- .jcall(x, "Ljava/lang/Class;", "getClass", check=FALSE)) .jcheck(silent=TRUE) if (is.jnull(cl) && !silent) stop("cannot get class object") cl } # return class object for a given class name; silent determines whether # an error should be thrown on failure (FALSE) or just null reference (TRUE) .jfindClass <- function(cl, silent=FALSE) { if (inherits(cl, "jclassName")) return(cl@jobj) if (!is.character(cl) || length(cl)!=1) stop("invalid class name") cl<-gsub("/",".",cl) a <- NULL if (!is.jnull(.rJava.class.loader)) try(a <- .jcall("java/lang/Class","Ljava/lang/Class;","forName",cl,TRUE,.jcast(.rJava.class.loader,"java.lang.ClassLoader"), check=FALSE)) else try(a <- .jcall("java/lang/Class","Ljava/lang/Class;","forName",cl,check=FALSE)) # this is really .jcheck but we don't want it to appear on the call stack .C(RJavaCheckExceptions, silent, FALSE, PACKAGE = "rJava") if (!silent && is.jnull(a)) stop("class not found") a } # Java-side inheritance check; NULL inherits from any class, because # it can be cast to any class type; cl can be a class name or a jobjRef to a class object .jinherits <- function(o, cl) { if (is.jnull(o)) return(TRUE) if (!is(o, "jobjRef")) stop("invalid object") if (is.character(cl)) cl <- .jfindClass(cl) else if (inherits(cl, "jclassName")) cl <- cl@jobj if (!is(cl, "jobjRef")) stop("invalid class object") ocl <- .jclassRef(o) .Call(RisAssignableFrom, ocl@jobj, cl@jobj) } # compares two things which may be Java objects. invokes Object.equals if applicable and thus even different pointers can be equal. if one parameter is not Java object, but scalar string/int/number/boolean then a corresponding Java object is created for comparison # strict comparison returns FALSE if Java-reference is compared with non-reference. otherwise conversion into Java scalar object is attempted .jequals <- function(a, b, strict=FALSE) { if (is.null(a)) a <- new("jobjRef") if (is.null(b)) b <- new("jobjRef") if (is(a,"jobjRef")) o <- a else if (is(b,"jobjRef")) { o <- b; b <- a } else return(all.equal(a,b)) if (!is(b,"jobjRef")) { if (strict) return(FALSE) if (length(b)!=1) { warning("comparison of non-scalar values is always FALSE"); return(FALSE) } if (is.character(b)) b <- .jnew("java/lang/String",b) else if (is.integer(b)) b <- .jnew("java/lang/Integer",b) else if (is.numeric(b)) b <- .jnew("java/lang/Double",b) else if (is.logical(b)) b <- .jnew("java/lang/Boolean", b) else { warning("comparison of non-trivial values to Java objects is always FALSE"); return(FALSE) } } if (is.jnull(a)) is.jnull(b) else .jcall(o, "Z", "equals", .jcast(b, "java/lang/Object")) } .jfield <- function(o, sig=NULL, name, true.class=is.null(sig), convert=TRUE) { if (length(sig)) { if (sig=='S') sig<-"Ljava/lang/String;" if (sig=='T') sig<-"S" if (sig=='[S') sig<-"[Ljava/lang/String;" if (sig=='[T') sig<-"[S" } r <- .Call(RgetField, o, sig, as.character(name), as.integer(true.class)) if (inherits(r, "jobjRef")) { if (isJavaArraySignature(r@jclass)) { r <- if (convert) .jevalArray(r, rawJNIRefSignature=r@jclass, simplify=TRUE) else newArray(r, simplify=FALSE) } if (convert && inherits(r, "jobjRef")) { if (r@jclass == "java/lang/String") return(.External(RgetStringValue, r@jobj)) if (.conv.in$.) return(.convert.in(r)) } } r } ".jfield<-" <- function(o, name, value) .Call(RsetField, o, name, value) rJava/R/jinit.R0000644000176200001440000002560112256051760012766 0ustar liggesusers## This file is part of the rJava package - low-level R/Java interface ## (C)2006 Simon Urbanek ## For license terms see DESCRIPTION and/or LICENSE ## ## $Id: jinit.R 587 2013-11-19 21:45:06Z urbanek $ .check.JVM <- function() .Call(RJava_checkJVM) .need.init <- function() .Call(RJava_needs_init) ## initialization .jinit <- function(classpath=NULL, parameters=getOption("java.parameters"), ..., silent=FALSE, force.init=FALSE) { running.classpath <- character() if (!.need.init()) { running.classpath <- .jclassPath() if (!force.init) { if (length(classpath)) { cpc <- unique(unlist(strsplit(classpath, .Platform$path.sep))) if (length(cpc)) .jaddClassPath(cpc) } return(0) } } ## determine path separator path.sep <- .Platform$path.sep if (!is.null(classpath)) { classpath <- as.character(classpath) if (length(classpath)) classpath <- paste(classpath,collapse=path.sep) } # merge CLASSPATH environment variable if present cp<-Sys.getenv("CLASSPATH") if (!is.null(cp)) { if (is.null(classpath)) classpath<-cp else classpath<-paste(classpath,cp,sep=path.sep) } # set rJava/java/boot for boostrap (so we can get RJavaClassLoader) boot.classpath <- file.path(.rJava.base.path,"java","boot") # if running in a sub-arch, append -Dr.arch in case someone gets the idea to start JRI if (is.character(.Platform$r_arch) && nzchar(.Platform$r_arch) && length(grep("-Dr.arch", parameters, fixed=TRUE)) == 0L) parameters <- c(paste("-Dr.arch=/", .Platform$r_arch, sep=''), as.character(parameters)) ## unfortunately Sys/setlocale()/Sys.getlocale() have incompatible interfaces so there ## is no good way to get/set locales -- so we have to hack around it ... locale.list <- c("LC_COLLATE", "LC_CTYPE", "LC_MONETARY", "LC_NUMERIC", "LC_TIME", "LC_MESSAGES", "LC_PAPER", "LC_MEASUREMENT") locales <- sapply(locale.list, Sys.getlocale) loc.sig <- Sys.getlocale() #cat(">> init CLASSPATH =",classpath,"\n") #cat(">> boot class path: ", boot.classpath,"\n") # call the corresponding C routine to initialize JVM xr <- .External(RinitJVM, boot.classpath, parameters) ## we have to re-set the locales right away suppressWarnings(try(if (!identical(Sys.getlocale(), loc.sig)) for (i in names(locales)) try(Sys.setlocale(i, locales[i]), silent=TRUE), silent=TRUE)) if (xr==-1) stop("Unable to initialize JVM.") if (xr==-2) stop("Another VM is already running and rJava was unable to attach to that VM.") # we'll handle xr==1 later because we need fully initialized rJava for that # this should remove any lingering .jclass objects from the global env # left there by previous versions of rJava pj <- grep("^\\.jclass",ls(1,all.names=TRUE),value=TRUE) if (length(pj)>0) { rm(list=pj,pos=1) if (exists(".jniInitialized",1)) rm(list=".jniInitialized",pos=1) if (!silent) warning("rJava found hidden Java objects in your workspace. Internal objects from previous versions of rJava were deleted. Please note that Java objects cannot be saved in the workspace.") } ##--- HACK-WARNING: we're operating directly on the namespace environment ## this could be dangerous. for (x in .delayed.variables) unlockBinding(x, .env) assign(".jniInitialized", TRUE, .env) # get cached class objects for reflection assign(".jclassObject", .jcall("java/lang/Class","Ljava/lang/Class;","forName","java.lang.Object"), .env) assign(".jclassClass", .jcall("java/lang/Class","Ljava/lang/Class;","forName","java.lang.Class"), .env) assign(".jclassString", .jcall("java/lang/Class","Ljava/lang/Class;","forName","java.lang.String"), .env) ic <- .jcall("java/lang/Class","Ljava/lang/Class;","forName","java.lang.Integer") f<-.jcall(ic,"Ljava/lang/reflect/Field;","getField", "TYPE") assign(".jclass.int", .jcast(.jcall(f,"Ljava/lang/Object;","get",.jcast(ic,"java/lang/Object")),"java/lang/Class"), .env) ic <- .jcall("java/lang/Class","Ljava/lang/Class;","forName","java.lang.Double") f<-.jcall(ic,"Ljava/lang/reflect/Field;","getField", "TYPE") assign(".jclass.double", .jcast(.jcall(f,"Ljava/lang/Object;","get",.jcast(ic,"java/lang/Object")),"java/lang/Class"), .env) ic <- .jcall("java/lang/Class","Ljava/lang/Class;","forName","java.lang.Float") f<-.jcall(ic,"Ljava/lang/reflect/Field;","getField", "TYPE") assign(".jclass.float", .jcast(.jcall(f,"Ljava/lang/Object;","get",.jcast(ic,"java/lang/Object")),"java/lang/Class"), .env) ic <- .jcall("java/lang/Class","Ljava/lang/Class;","forName","java.lang.Boolean") f<-.jcall(ic,"Ljava/lang/reflect/Field;","getField", "TYPE") assign(".jclass.boolean", .jcast(.jcall(f,"Ljava/lang/Object;","get",.jcast(ic,"java/lang/Object")),"java/lang/Class"), .env) ic <- .jcall("java/lang/Class","Ljava/lang/Class;","forName","java.lang.Void") f<-.jcall(ic,"Ljava/lang/reflect/Field;","getField", "TYPE") assign(".jclass.void", .jcast(.jcall(f,"Ljava/lang/Object;","get",.jcast(ic,"java/lang/Object")),"java/lang/Class"), .env) ## if NOAWT is set, set AWT to headless if (nzchar(Sys.getenv("NOAWT"))) .jcall("java/lang/System","S","setProperty","java.awt.headless","true") lib <- "libs" if (nchar(.Platform$r_arch)) lib <- file.path("libs", .Platform$r_arch) rjcl <- NULL if (xr==1) { # && nchar(classpath)>0) { # ok, so we're attached to some other JVM - now we need to make sure that # we can load our class loader. If we can't then we have to use our bad hack # to be able to squeeze our loader in # first, see if this is actually JRIBootstrap so we have a loader already rjcl <- .Call(RJava_primary_class_loader) if (is.null(rjcl) || .jidenticalRef(rjcl,.jzeroRef)) rjcl <- NULL else rjcl <- new("jobjRef", jobj=rjcl, jclass="RJavaClassLoader") if (is.jnull(rjcl)) rjcl <- .jnew("RJavaClassLoader", .rJava.base.path, file.path(.rJava.base.path, lib), check=FALSE) .jcheck(silent=TRUE) if (is.jnull(rjcl)) { ## it's a hack, so we run it in try(..) in case BadThings(TM) happen ... cpr <- try(.jmergeClassPath(boot.classpath), silent=TRUE) if (inherits(cpr, "try-error")) { .jcheck(silent=TRUE) if (!silent) warning("Another VM is running already and the VM did not allow me to append paths to the class path.") assign(".jinit.merge.error", cpr, .env) } if (length(parameters)>0 && any(parameters!=getOption("java.parameters")) && !silent) warning("Cannot set VM parameters, because VM is running already.") } } if (is.jnull(rjcl)) rjcl <- .jnew("RJavaClassLoader", .rJava.base.path, file.path(.rJava.base.path, lib), check=FALSE ) if (!is.jnull(rjcl)) { ## init class loader assign(".rJava.class.loader", rjcl, .env) ##-- set the class for native code .Call(RJava_set_class_loader, .env$.rJava.class.loader@jobj) ## now it's time to add any additional class paths cpc <- unique(strsplit(classpath, .Platform$path.sep)[[1]]) if (length(cpc)) .jaddClassPath(cpc) } else stop("Unable to create a Java class loader.") ##.Call(RJava_new_class_loader, .rJava.base.path, file.path(.rJava.base.path, lib)) ## lock namespace bindings for (x in .delayed.variables) lockBinding(x, .env) ## now we need to update the attached namespace (package env) as well m <- match(paste("package", getNamespaceName(.env), sep = ":"), search())[1] if (!is.na(m)) { ## only is it is attached pe <- as.environment(m) for (x in .delayed.export.variables) { unlockBinding(x, pe) pe[[x]] <- .env[[x]] lockBinding(x, pe) } } # FIXME: is this the best place or should this be done # internally right after the RJavaClassLoader is instanciated # init the cached RJavaTools class in the jni side .Call( "initRJavaTools", PACKAGE = "rJava" ) # not yet # import( c( "java.lang", "java.util") ) invisible(xr) } # FIXME: this is not always true: osgi, eclipse etc use a different # class loader strategy, we should add some sort of hook to let people # define how they want this to be done .jmergeClassPath <- function(cp) { ccp <- .jcall("java/lang/System","S","getProperty","java.class.path") ccpc <- strsplit(ccp, .Platform$path.sep)[[1]] cpc <- strsplit(cp, .Platform$path.sep)[[1]] rcp <- unique(cpc[!(cpc %in% ccpc)]) if (length(rcp) > 0) { # the loader requires directories to include trailing slash # Windows: need / or \ ? (untested) dirs <- which(file.info(rcp)$isdir) for (i in dirs) if (substr(rcp[i],nchar(rcp[i]),nchar(rcp[i]))!=.Platform$file.sep) rcp[i]<-paste(rcp[i], .Platform$file.sep, sep='') ## this is a hack, really, that exploits the fact that the system class loader ## is in fact a subclass of URLClassLoader and it also subverts protection ## of the addURL class using reflection - yes, bad hack, but we use it ## only if the boot class path doesn't contain our own class loader so ## we cannot replace the system loader with our own (this will happen when we ## need to attach to an existing VM) ## The original discussion and code for this hack was at: ## http://forum.java.sun.com/thread.jspa?threadID=300557&start=15&tstart=0 ## it should probably be run in try(..) because chances are that it will ## break if Sun changes something... cl <- .jcall("java/lang/ClassLoader", "Ljava/lang/ClassLoader;", "getSystemClassLoader") urlc <- .jcall("java/lang/Class", "Ljava/lang/Class;", "forName", "java.net.URL") clc <- .jcall("java/lang/Class", "Ljava/lang/Class;", "forName", "java.net.URLClassLoader") ar <- .jcall("java/lang/reflect/Array", "Ljava/lang/Object;", "newInstance", .jclassClass, 1:1) .jcall("java/lang/reflect/Array", "V", "set", .jcast(ar, "java/lang/Object"), 0:0, .jcast(urlc, "java/lang/Object")) m<-.jcall(clc, "Ljava/lang/reflect/Method;", "getDeclaredMethod", "addURL", .jcast(ar,"[Ljava/lang/Class;")) .jcall(m, "V", "setAccessible", TRUE) ar <- .jcall("java/lang/reflect/Array", "Ljava/lang/Object;", "newInstance", .jclassObject, 1:1) for (fn in rcp) { f <- .jnew("java/io/File", fn) url <- .jcall(f, "Ljava/net/URL;", "toURL") .jcall("java/lang/reflect/Array", "V", "set", .jcast(ar, "java/lang/Object"), 0:0, .jcast(url, "java/lang/Object")) .jcall(m, "Ljava/lang/Object;", "invoke", .jcast(cl, "java/lang/Object"), .jcast(ar, "[Ljava/lang/Object;")) } # also adjust the java.class.path property to not confuse others if (length(ccp)>1 || (length(ccp)==1 && nchar(ccp[1])>0)) rcp <- c(ccp, rcp) acp <- paste(rcp, collapse=.Platform$path.sep) .jcall("java/lang/System","S","setProperty","java.class.path",as.character(acp)) } # if #rcp>0 invisible(.jcall("java/lang/System","S","getProperty","java.class.path")) } rJava/MD50000644000176200001440000004355312256142141011635 0ustar liggesusers51454d4fb3b67dcd2a2fa2d50199cbe7 *DESCRIPTION d1d0f4f32aa8fbd87915ae6773c08f03 *NAMESPACE c6c4701a71b9a630b040d4cbcc3185b7 *NEWS fb03ffac65f44f5620f9e41bb6849303 *R/0classes.R 42839b45c629f05aaa233258ee22cd99 *R/J.R f3fb76b841a4385db9de77094ac040a8 *R/arrays.R b31458f4cd06055026736255227893fc *R/call.R d8cc518e9ea16eb69b0327656e06680c *R/comparison.R 39cf1690ea4419bdd52312deddcd0b46 *R/completion.R 46c1f5556d33f24415687bda1385bfc1 *R/converter.R 72c7f5a694692d82b5b0068e9f2b48c1 *R/exceptions.R 5fc1deb8a280850b9564178e877e2166 *R/import.R b1d5e8e5f1a708e1e532e98ca015c3a9 *R/instanceof.R b92109b1e5765682a464a29c3eb7cc0a *R/jfirst.R 1b21364b3fe7e07127aac2210d93870e *R/jinit.R f44033bcd8b55df5059790d9f48ccf6f *R/jri.R b3e4df4d9330dc369e271b4129809273 *R/loader.R d7b68d370d30c42b76e1c09a1af3553e *R/memprof.R ced216e362b0e2ef2c6b0a2a0510e63a *R/methods.R 703bbb660c9c9c3b87c1901d7cc62d08 *R/options.R db5979ee68a1c717a204f3744d230d72 *R/reflection.R 66cc978228108a49c39e159b419e97a6 *R/rep.R 511ad995209293a190a876a22f31d84d *R/serialize.R 2d5a4d95db9f3435aa627aef91275514 *R/tools.R 836ae5bfd41fc0a36ffbe7a47c313adc *R/windows/FirstLib.R ec712e3a2878c7c6f4058402208bd8fa *R/with.R f58247b0887a066804ee157cbbba73f9 *R/zzz.R.in a69bbdefa2e124693271ef540ae984d7 *configure 3fae4240eb6db17b873ca6462d786548 *configure.ac 4a650d97ce711674fcbd700bc973310c *configure.win 923cb33d4665ca8dd4775ef06db29a8f *getsp.class 1e50e375949e0109a5b69fde529b4080 *getsp.java f23da3195f2b976762201cb94d37a6f4 *inst/java/ArrayDimensionException.class 645da70472ece119aaedfc3ad77ed754 *inst/java/ArrayDimensionException.java fb02f8e5be1d7538e31704f63c747620 *inst/java/ArrayWrapper.class bb367164aa632388f6c075a8987f4557 *inst/java/ArrayWrapper.java 19bd4ec85a7cd697a6f37000968854d9 *inst/java/ArrayWrapper_Test.class b549a0e92555b691c3a9054377bc8b9b *inst/java/ArrayWrapper_Test.java 4ed5014a7af8dccad4e04fd37c97255f *inst/java/DummyPoint.class 74c293d19b618a08f3702a75e420efa4 *inst/java/DummyPoint.java 522f8ea7625320de49f20396f509017f *inst/java/FlatException.class 481d3ff09ad6d5c55402290148a89bda *inst/java/FlatException.java 477f4d557f74f3cfca4a70a3254ad5b2 *inst/java/NotAnArrayException.class ef9ef7beaa915a26925cc20c4fbefda6 *inst/java/NotAnArrayException.java 0c088471697bcafed5f1b2c79a7b2d6c *inst/java/NotComparableException.class 63c0ebbfb86bdde4bff8ebcfd1ece554 *inst/java/NotComparableException.java f48654f0162c58ed24c2ba5c2ddac78c *inst/java/ObjectArrayException.class b5b83ff7ddd4c072a50f0b0368e16373 *inst/java/ObjectArrayException.java 3c77c04d81ebf842d6e7995942ce4cdd *inst/java/PrimitiveArrayException.class 2387add3987f5fd7e415945ccf6d6076 *inst/java/PrimitiveArrayException.java 94e3528b9190a0c2ab3710c5aad12490 *inst/java/RJavaArrayIterator.class fa661d0a7c1aba53de50900ed2b8b209 *inst/java/RJavaArrayIterator.java 69b8157c2c0af3b3a7ff3534f085d2e9 *inst/java/RJavaArrayTools$ArrayDimensionMismatchException.class 6bc41c33cfb30497fbd744ee3c999f3e *inst/java/RJavaArrayTools.class 1e2944f6e49845746d6ba381a8210b3c *inst/java/RJavaArrayTools.java eff3a780fe8a710695657c46993c9779 *inst/java/RJavaArrayTools_Test.class 8ae0ed82627e91c5b9ff53ff5c655d51 *inst/java/RJavaArrayTools_Test.java b16e6bb527d8276b1ed62c8665517901 *inst/java/RJavaComparator.class f68641ae71d7b387c2c9cfc081bdfcc6 *inst/java/RJavaComparator.java 7426b29a5c2243d44c9e9867ed6ac749 *inst/java/RJavaImport.class c5cc1afb6939863d51df4b05173c7bba *inst/java/RJavaImport.java 640858a467bf6f50a79d8ed1da2c166e *inst/java/RJavaTools.class 8a4a0f66ecd8590d945f56ca73c358ae *inst/java/RJavaTools.java f858220d5c986652e11661c113e8b5ea *inst/java/RJavaTools_Test$DummyNonStaticClass.class 83155178bbb8eb4f8196d98410a44db0 *inst/java/RJavaTools_Test$ExampleClass.class 0ea7150ff4cb2501f3cebdefbc004e16 *inst/java/RJavaTools_Test$TestException.class c0147a25dc52bb35639cf56bfdae628d *inst/java/RJavaTools_Test.class b70f8216c0c1f0886c68c9579722c0d9 *inst/java/RJavaTools_Test.java 88f9ad70a3364b3432158c409285153b *inst/java/RectangularArrayBuilder.class fc86e40dc5ac9044d5a030417bb2ea80 *inst/java/RectangularArrayBuilder.java deb7c9b2742679cd9fec5e409bb856b5 *inst/java/RectangularArrayBuilder_Test.class c2b39d8cf9759c0be3f5792471d8fc7b *inst/java/RectangularArrayBuilder_Test.java 134534a7c14e585d26abedbb8f6017d8 *inst/java/RectangularArrayExamples.class 015e6e1f80e15ea50c218c615a17eaa5 *inst/java/RectangularArrayExamples.java ec301c12f3f9b7f76266a5427956624c *inst/java/RectangularArraySummary.class 20d22ec2a9b22d70ab0bccf67c655ad7 *inst/java/RectangularArraySummary.java 7460fc408bd457c89ae663410981125e *inst/java/TestException.class 3cad65c59f482541f8f2181585b30dc2 *inst/java/TestException.java 47b2eee421d339d69148414e36f2d52b *inst/java/boot/RJavaClassLoader$RJavaObjectInputStream.class 9cd0fc025db84ce9cd20a23292e25089 *inst/java/boot/RJavaClassLoader$UnixDirectory.class 9207f868a45e76ea693376c431fa3102 *inst/java/boot/RJavaClassLoader$UnixFile.class 44ccb8e39c87a8f5222b63ab80282c2e *inst/java/boot/RJavaClassLoader$UnixJarFile.class f0f5717532405b8bd8d05a7a910bdfc8 *inst/java/boot/RJavaClassLoader.class e191f24895e2a788852c5f9dd62c855d *inst/java/boot/RJavaClassLoader.java c464bc6bba4186f25eebe324468bd2ad *inst/javadoc/ArrayDimensionException.html a0076bf2ff7cef55ca523d12d92958d9 *inst/javadoc/ArrayWrapper.html 74ea38781b3c10190feae515d59e2daa *inst/javadoc/ArrayWrapper_Test.html f6fbb6ad4ef2dc0a20ae98e0a4ededc4 *inst/javadoc/DummyPoint.html e54de15fc5209c21e8221738df2296c6 *inst/javadoc/FlatException.html 3313e91a2bdc0b13fcf87e7eb9d03af6 *inst/javadoc/NotAnArrayException.html 96084dbb1a67a5d5bd18e668e6315fcd *inst/javadoc/NotComparableException.html f6b915e9abfc84f62e25bf74e60b6019 *inst/javadoc/ObjectArrayException.html 7b4f1b6788fb5d10adc157a1458a7981 *inst/javadoc/PrimitiveArrayException.html 7da0f2a9929d9968d2660060e44e6f13 *inst/javadoc/RJavaArrayIterator.html bea45c1fecddf92277096f13e7c5aefc *inst/javadoc/RJavaArrayTools.ArrayDimensionMismatchException.html 7b00093e0809e044ddc8859ce0436365 *inst/javadoc/RJavaArrayTools.html 44231bf7b430582aacc0d0f69a7ed7ad *inst/javadoc/RJavaArrayTools_Test.html 3a1ad65894b4e69009f485fe3f91e8b7 *inst/javadoc/RJavaClassLoader.html 3a2013a02b216bbd3be777d25055b50d *inst/javadoc/RJavaComparator.html b8b429027779d0d4ef47de6f8a0d351a *inst/javadoc/RJavaImport.html a58b95bc47a3377758c20b87dd179acd *inst/javadoc/RJavaTools.html ee306a891f91cfaca5f92cd9a9c74af7 *inst/javadoc/RJavaTools_Test.DummyNonStaticClass.html 2b66bb19deea661626d2231c164e2345 *inst/javadoc/RJavaTools_Test.TestException.html 87153f1cb504b8995730a2cdf405a50b *inst/javadoc/RJavaTools_Test.html e886dbb8d2a503185d75b6b224b70f17 *inst/javadoc/RectangularArrayBuilder.html 167a36b2c63b4cb3f30054bb6fb0f9b2 *inst/javadoc/RectangularArrayBuilder_Test.html cb9e1797d7dd47c8eedcf5c34e69726e *inst/javadoc/RectangularArrayExamples.html f53025056be66f22e4cef311044e3141 *inst/javadoc/RectangularArraySummary.html 319644e7e46308772611c3817f33bf35 *inst/javadoc/TestException.html c6a71f61fc1e3dbc9f9e0b8b7fce0fdd *inst/javadoc/allclasses-frame.html 0ea6f95466053a783a0a0223385ea806 *inst/javadoc/allclasses-noframe.html f8cbb5573f19d5df545dfd7cd8007470 *inst/javadoc/constant-values.html e14dd33181fa7240ee8b0f9cf489070f *inst/javadoc/deprecated-list.html ae13232486143bf981df2eb783665f28 *inst/javadoc/help-doc.html 37f56c6c037dc8e3ffad555d1fd0974d *inst/javadoc/index-all.html e35194b83ba4379543799612b8e7bdad *inst/javadoc/index.html 0b1ee6d6daedc0f7f22de9fa7379df8b *inst/javadoc/overview-tree.html e07ddd38fe3de1178654edc4dd7cdd1e *inst/javadoc/package-frame.html 68b329da9893e34099c7d8ad5cb9c940 *inst/javadoc/package-list 39f650131de7afdebdaa57b21b4eca54 *inst/javadoc/package-summary.html bd8036ad8a6b76271edeeb2030c33de7 *inst/javadoc/package-tree.html 1585f724123802e311ffda9fe3daec1d *inst/javadoc/resources/background.gif 104b9cce4c6e7939d704a3622f3af134 *inst/javadoc/resources/tab.gif ffafa018717176c6a8dcc231cfb737e6 *inst/javadoc/resources/titlebar.gif afc6e5230ea7870c515dddb0bc48486d *inst/javadoc/resources/titlebar_end.gif 7467b2cb1957b5c1346325f4cc984422 *inst/javadoc/serialized-form.html a724e5f04f149d2e888b5b287d1c725f *inst/javadoc/stylesheet.css b28eccda096c9c0cd54cb91315f5a280 *inst/jri/JRIEngine.jar c18d116839a663452543972cc0e3cdeb *inst/jri/REngine.jar 80e1ad62ecac019d0b982b2cf8401256 *install-sh 1702a92c723f09e3fab3583b165a8d90 *jri/LGPL.txt 93f82aebab3ff00b332cf772f576bd74 *jri/LICENSE 4aa47604ee53e07a0d467cb02e0113c0 *jri/Makefile.all 76993d81fed7053ab28279307973a6c8 *jri/Makefile.in 03c49ba859c5d95faaad26a62504c927 *jri/Makefile.win 8c30e2798f5449c3978d892fcef1e693 *jri/Makevars.win bc7cf887c8e1b1f5b1f32df716797bac *jri/Mutex.java e75fa4d48f316428848ee28ca152821b *jri/NEWS d89806a15972a35208e44cfe67a4c858 *jri/RBool.java 1367ccf5ff46ad11852fd7ad1cbcd3d2 *jri/RConsoleOutputStream.java 111dc569d5346a1f1c817851ae182385 *jri/README 9e80eef6103fd497f9e6f699417cc04e *jri/REXP.java 7d6e3edfe602bc0524c4e230bc7bb8ce *jri/RFactor.java 65da163f74e942405100f51457c7c5c7 *jri/RList.java e2ccb469e563006e901b2ed0148a288a *jri/RMainLoopCallbacks.java eeb974948e12d6b2601750ad44ed9763 *jri/RVector.java f429158d091d30f51d9d88281f1bacd7 *jri/Rengine.java 3c803b79f3a2dd308f063cb2dc229c6e *jri/bootstrap/Boot.java b8f50d514a93033cc3417b177aae49da *jri/bootstrap/DelegatedClassLoader.java 9d13bd7a1ab846c16892114d544d1c46 *jri/bootstrap/DelegatedURLClassLoader.java 1da78200bd47f7f5600dd603eb17a490 *jri/bootstrap/JRIBootstrap.c 81926a811f52a81cbf79e83ec3b01b51 *jri/bootstrap/JRIBootstrap.h 0e73e0900e11eedef4c3ed1d5358351f *jri/bootstrap/JRIBootstrap.java 1e2605e758ac858a45315877f68e8f45 *jri/bootstrap/JRIClassLoader.java 0e41a1d775ca59467d394b1e5dc57ff5 *jri/bootstrap/Makefile 49b41100efbcb02fdc7d3289851f0c11 *jri/bootstrap/mft 7781658bda6085d3331ecd9b5ddf9fd0 *jri/configure 6a2fbfd74967d6407795dc0ca32b2fed *jri/configure.ac ec5713c3b705880e6b76ea91cf5aecc2 *jri/configure.win 520e423abb56c3b7d2634accf990913f *jri/examples/rtest.java 46e7ae225494cdb2a91b2de96a9ea18b *jri/examples/rtest2.java c69b549f536d2c4fdc7dd6fb2c0c8682 *jri/package-info.java bc8dfbefbb4c8a177682898bfcbe5f54 *jri/run.in 67e21a6f700b4316f33601774d5dc19a *jri/src/Makefile.all f78f89a3e935cebd1aab7b2d75b143e8 *jri/src/Makefile.in 40bd09315359bb8d8a0efff9ef832890 *jri/src/Makefile.win 201d53f6cdb464bbccd22803661a1d68 *jri/src/Rcallbacks.c 4cf9af0c71b5d5469162f9ba99bcdfd5 *jri/src/Rcallbacks.h 3a493d1e77fa4cc782cbdcfb87f95660 *jri/src/Rdecl.h 729bbbd86c5a34059fd23d8a7916d42a *jri/src/Rengine.c d0a294da40687b9db009404262c728cc *jri/src/Rinit.c 9ff613eb944a0cc29866791a4a921916 *jri/src/Rinit.h a82a2294e9ca2d0740821c2a18d98c4c *jri/src/config.h.in a38fc939f86e56b41e19f1d8b28d99ab *jri/src/globals.c 5b9ab765ae9e2e779a7c5d8d7d3c6714 *jri/src/globals.h 095b90e2fa094c201ae5973db032a508 *jri/src/h2ic 745271aa43ba90186f2aa8d11adeefe1 *jri/src/jri.c 2380687e0b1b2bcff1e4cd6c2babdf74 *jri/src/jri.h cb39d09dba9e5cec189ff7156370bf32 *jri/src/rjava.c eff37b05a777274778356bcaeb0db778 *jri/src/rjava.h cd0f80b7eeaeaf7217e8212de507c401 *jri/src/win32/Makefile 0b2595409ffe3fefe30765a9005b22c0 *jri/src/win32/findjava.c 1c78151860d82da04c904b023d8a57e8 *jri/src/win32/jvm.def 7bbc4291d8011614923e56506dc24ac2 *jri/src/win32/jvm64.def 9a410124d044b90b8a239012b6b78377 *jri/tools/config.guess 2cae972bdd36f215dfa400ecbe91ec16 *jri/tools/config.sub 672477de1f5fdf535c609e3682b525f0 *jri/tools/getsp.class 43b35b5a5710eeb2f6e83239be854220 *jri/tools/getsp.java e7e174685c6ae852e4b5e7431fddc5c8 *jri/tools/install-sh ce1fb6b579015b49d94f3b093f4cb332 *jri/tools/mkinstalldirs ba381d3e918922f6c208ad8225f7e8cd *jri/version 6b0228b2fa88da85179313bcf9058425 *man/Exceptions.Rd 6be9c534e3753eaf0f87a2981de2e0f6 *man/J.Rd 84f8c557ebfaac24118626e77aaf1b32 *man/accessOp.Rd 40fff74556d98fbedbc6854e7f53c23d *man/aslist.Rd c352abc5c3e258de0130127a0577076d *man/clone.Rd dee5645f1ea27113b6bf07173087b1b4 *man/instanceof.Rd 2a4f5ba920a94467207299423cbb369e *man/jarray.Rd 482be28ccfa570c39ac8ab70673bfa55 *man/jarrayRef-class.Rd 6a249a9357ad9a69fb4781af82cb9ee3 *man/java-tools.Rd 1ea3b8fcc10815bee75d883870e0a36a *man/javaImport.Rd e8188891eee9f8ea359ffe6780c21fae *man/jcall.Rd e7eb063c7ba073ffb0945860b26afa02 *man/jcast.Rd a34aa36de31e52e7c03e78a949858296 *man/jcastToArray.Rd 5a18abc638da4e3d04643860759c3480 *man/jcheck.Rd eba4e14cb341f44147aa373a327b440c *man/jclassName.Rd c1ee05e48bb0af24b350ffdae0b9b1ee *man/jengine.Rd bc02763db0a94e3730d5c50ea6b37d26 *man/jequals.Rd ab8001198d504cbb346e8e4aee68783d *man/jfield.Rd eaf6a0e7498d10be9dcfc84d329e05b9 *man/jfloat-class.Rd fd89f0199a8a17dea1b6388cd4f2eb8d *man/jfloat.Rd 7d67a6f2ba0803934ec4abbd61213392 *man/jinit.Rd 87bab4a36a363330398959cbb86413f7 *man/jmemprof.Rd 9c4859ba7da5765866af1efa9a9bdff0 *man/jnew.Rd 69f03cbdc43217f5ceeb39965c3654a8 *man/jnull.Rd c8ac98bcf860cbbc8ceab596a889bb32 *man/jobjRef-class.Rd fe1d73c008e625368b76e37d2970f6d9 *man/jpackage.Rd d7e43237e487ea08766a14fa81b8a065 *man/jrectRef-class.Rd 0c25faad0b0762ee265c8ec982479afd *man/jreflection.Rd 9bff8c35fcf61e8def16f9870515936a *man/jserialize.Rd d8b2b5645502b7e80a2d59f4703e4b4c *man/jsimplify.Rd 7caae6e9ab24060e9e2916f025ccf1e4 *man/loader.Rd f42971d8c1454f57226b8607a2f2e1bb *man/new.Rd 393c606a669eb9bacc7e4234bae53ecf *man/rep.Rd b5ba8c698210be6a9abaa85ab25cc2c8 *man/show.Rd f0166b11caaeea7d5c14571e436563c1 *man/toJava.Rd 18b540c2852c2e9baabbb245a4ecbd09 *man/with.Rd ed0e1d62d0b00abed72380fa045c6ced *src/Makevars.in 61e341d751aa8c67162234a838b4760b *src/Makevars.win 0bdb79fbcd3e33ba9d40804cbf5084b9 *src/Rglue.c 71c752999b97f5a3d87fc4574611399d *src/arrayc.c cafc3189d76fba2ffeaf486b2ba347ba *src/callJNI.c eb839008c4a65f6dc28905c26a0bd436 *src/callback.c b0a0a1a184247e1e249b718008ca3c29 *src/callback.h b3e60bc7509411c8488dc09a590ab378 *src/config.h.in f268b61e57b0aca648069547e5149797 *src/fields.c f03ad78190e982222dfb099fb35d37e9 *src/init.c 842d77ab909b725951d16ae7d5e12836 *src/install.libs.R f23da3195f2b976762201cb94d37a6f4 *src/java/ArrayDimensionException.class 645da70472ece119aaedfc3ad77ed754 *src/java/ArrayDimensionException.java fb02f8e5be1d7538e31704f63c747620 *src/java/ArrayWrapper.class bb367164aa632388f6c075a8987f4557 *src/java/ArrayWrapper.java 19bd4ec85a7cd697a6f37000968854d9 *src/java/ArrayWrapper_Test.class b549a0e92555b691c3a9054377bc8b9b *src/java/ArrayWrapper_Test.java 4ed5014a7af8dccad4e04fd37c97255f *src/java/DummyPoint.class 74c293d19b618a08f3702a75e420efa4 *src/java/DummyPoint.java 522f8ea7625320de49f20396f509017f *src/java/FlatException.class 481d3ff09ad6d5c55402290148a89bda *src/java/FlatException.java 5ff7d68173957f8396f358ffb321d978 *src/java/Makefile 477f4d557f74f3cfca4a70a3254ad5b2 *src/java/NotAnArrayException.class ef9ef7beaa915a26925cc20c4fbefda6 *src/java/NotAnArrayException.java 0c088471697bcafed5f1b2c79a7b2d6c *src/java/NotComparableException.class 63c0ebbfb86bdde4bff8ebcfd1ece554 *src/java/NotComparableException.java f48654f0162c58ed24c2ba5c2ddac78c *src/java/ObjectArrayException.class b5b83ff7ddd4c072a50f0b0368e16373 *src/java/ObjectArrayException.java 3c77c04d81ebf842d6e7995942ce4cdd *src/java/PrimitiveArrayException.class 2387add3987f5fd7e415945ccf6d6076 *src/java/PrimitiveArrayException.java 94e3528b9190a0c2ab3710c5aad12490 *src/java/RJavaArrayIterator.class fa661d0a7c1aba53de50900ed2b8b209 *src/java/RJavaArrayIterator.java 69b8157c2c0af3b3a7ff3534f085d2e9 *src/java/RJavaArrayTools$ArrayDimensionMismatchException.class 6bc41c33cfb30497fbd744ee3c999f3e *src/java/RJavaArrayTools.class 1e2944f6e49845746d6ba381a8210b3c *src/java/RJavaArrayTools.java eff3a780fe8a710695657c46993c9779 *src/java/RJavaArrayTools_Test.class 8ae0ed82627e91c5b9ff53ff5c655d51 *src/java/RJavaArrayTools_Test.java 47b2eee421d339d69148414e36f2d52b *src/java/RJavaClassLoader$RJavaObjectInputStream.class 9cd0fc025db84ce9cd20a23292e25089 *src/java/RJavaClassLoader$UnixDirectory.class 9207f868a45e76ea693376c431fa3102 *src/java/RJavaClassLoader$UnixFile.class 44ccb8e39c87a8f5222b63ab80282c2e *src/java/RJavaClassLoader$UnixJarFile.class f0f5717532405b8bd8d05a7a910bdfc8 *src/java/RJavaClassLoader.class e191f24895e2a788852c5f9dd62c855d *src/java/RJavaClassLoader.java b16e6bb527d8276b1ed62c8665517901 *src/java/RJavaComparator.class f68641ae71d7b387c2c9cfc081bdfcc6 *src/java/RJavaComparator.java 7426b29a5c2243d44c9e9867ed6ac749 *src/java/RJavaImport.class c5cc1afb6939863d51df4b05173c7bba *src/java/RJavaImport.java 640858a467bf6f50a79d8ed1da2c166e *src/java/RJavaTools.class 8a4a0f66ecd8590d945f56ca73c358ae *src/java/RJavaTools.java f858220d5c986652e11661c113e8b5ea *src/java/RJavaTools_Test$DummyNonStaticClass.class 83155178bbb8eb4f8196d98410a44db0 *src/java/RJavaTools_Test$ExampleClass.class 0ea7150ff4cb2501f3cebdefbc004e16 *src/java/RJavaTools_Test$TestException.class c0147a25dc52bb35639cf56bfdae628d *src/java/RJavaTools_Test.class b70f8216c0c1f0886c68c9579722c0d9 *src/java/RJavaTools_Test.java 88f9ad70a3364b3432158c409285153b *src/java/RectangularArrayBuilder.class fc86e40dc5ac9044d5a030417bb2ea80 *src/java/RectangularArrayBuilder.java deb7c9b2742679cd9fec5e409bb856b5 *src/java/RectangularArrayBuilder_Test.class c2b39d8cf9759c0be3f5792471d8fc7b *src/java/RectangularArrayBuilder_Test.java 134534a7c14e585d26abedbb8f6017d8 *src/java/RectangularArrayExamples.class 015e6e1f80e15ea50c218c615a17eaa5 *src/java/RectangularArrayExamples.java ec301c12f3f9b7f76266a5427956624c *src/java/RectangularArraySummary.class 20d22ec2a9b22d70ab0bccf67c655ad7 *src/java/RectangularArraySummary.java 7460fc408bd457c89ae663410981125e *src/java/TestException.class 3cad65c59f482541f8f2181585b30dc2 *src/java/TestException.java 41401b8d0d2000735961fa64bd1f21f4 *src/jri_glue.c 18d129e1c7776247973b9eea4d406692 *src/jvm-w32/Makefile cd19ef85e932993a3012efe598a9aae7 *src/jvm-w32/WinRegistry.c 797149174d42138ab7e8444c419603f3 *src/jvm-w32/config.h 66139f05712d9cac47a353020017ee21 *src/jvm-w32/findjava.c 1c78151860d82da04c904b023d8a57e8 *src/jvm-w32/jvm.def 7bbc4291d8011614923e56506dc24ac2 *src/jvm-w32/jvm64.def 6c3bc2f0c1acbca2ba8b6ee8a1e7f70a *src/loader.c c0b788adfff4e704abf3316933cb4dfb *src/otables.c 6a21e69ce4742f2f36696726e2f3283f *src/rJava.c bcffc55eb5040045401d5bffaf6f17d2 *src/rJava.h 51fe625d188183980dc3e34cd2895489 *src/tools.c be200f18f8b59152e38675b59fd74023 *version rJava/DESCRIPTION0000644000176200001440000000104312256142140013016 0ustar liggesusersPackage: rJava Version: 0.9-6 Title: Low-level R to Java interface Author: Simon Urbanek Maintainer: Simon Urbanek Depends: R (>= 2.5.0), methods Description: Low-level interface to Java VM very much like .C/.Call and friends. Allows creation of objects, calling methods and accessing fields. License: GPL-2 URL: http://www.rforge.net/rJava/ SystemRequirements: java Packaged: 2013-12-23 15:17:13 UTC; svnuser NeedsCompilation: yes Repository: CRAN Date/Publication: 2013-12-24 00:16:48 rJava/jri/0000755000176200001440000000000012256051760012105 5ustar liggesusersrJava/jri/Mutex.java0000644000176200001440000001327112256051760014056 0ustar liggesuserspackage org.rosuda.JRI; /** This class implements a (not so) simple mutex. The initial state of the mutex is unlocked. */ public class Mutex { public static boolean verbose=false; /** defines the current mutex state */ private boolean locked=false; /** thread that locked this mutex (used for simple deadlock-detection) */ private Thread lockedBy=null; /** locks the mutex. If the mutex is already locked, waits until the mutex becomes free. Make sure the same thread doesn't issue two locks, because that will cause a deadlock. Use {@link #safeLock()} instead if you wish to detect such deadlocks. */ public synchronized void lock() { while (locked) { if (lockedBy==Thread.currentThread()) System.err.println("FATAL ERROR: org.rosuda.JRI.Mutex detected a deadlock! The application is likely to hang indefinitely!"); if (verbose) System.out.println("INFO: "+toString()+" is locked by "+lockedBy+", but "+Thread.currentThread()+" waits for release (no timeout)"); try { wait(); } catch (InterruptedException e) { if (verbose) System.out.println("INFO: "+toString()+" caught InterruptedException"); } } locked=true; lockedBy=Thread.currentThread(); if (verbose) System.out.println("INFO: "+toString()+" locked by "+lockedBy); } /** locks the mutex. If the mutex is already locked, waits until the mutex becomes free. Make sure the same thread doesn't issue two locks, because that will cause a deadlock. @param to timeout in milliseconds, see {@link #wait()}. @return true if the lock was successful, false if not */ public synchronized boolean lockWithTimeout(long to) { if (locked) { if (lockedBy==Thread.currentThread()) System.err.println("FATAL ERROR: org.rosuda.JRI.Mutex detected a deadlock! The application is likely to hang indefinitely!"); if (verbose) System.out.println("INFO: "+toString()+" is locked by "+lockedBy+", but "+Thread.currentThread()+" waits for release (timeout "+to+" ms)"); try { wait(to); } catch (InterruptedException e) { if (verbose) System.out.println("INFO: "+toString()+" caught InterruptedException"); } } if (!locked) { locked=true; lockedBy=Thread.currentThread(); if (verbose) System.out.println("INFO: "+toString()+" locked by "+lockedBy); return true; } if (verbose) System.out.println("INFO: "+toString()+" timeout, failed to obtain lock for "+Thread.currentThread()); return false; } /** attempts to lock the mutex and returns information about its success. @return 0 if the mutex was locked sucessfully
1 if the mutex is already locked by another thread
-1 is the mutex is already locked by the same thread (hence a call to {@link #lock()} would cause a deadlock). */ public synchronized int tryLock() { if (verbose) System.out.println("INFO: "+toString()+" tryLock by "+Thread.currentThread()); if (locked) return (lockedBy==Thread.currentThread())?-1:1; locked=true; lockedBy=Thread.currentThread(); if (verbose) System.out.println("INFO: "+toString()+" locked by "+lockedBy); return 0; } /** Locks the mutex. It works like {@link #lock()} except that it returns immediately if the same thread already owns the lock. It is safer to use this function rather than {@link #lock()}, because lock can possibly cause a deadlock which won't be resolved. @return true is the mutex was successfully locked, false if deadlock was detected (i.e. the same thread has already the lock). */ public synchronized boolean safeLock() { if (locked && lockedBy==Thread.currentThread()) { if (verbose) System.out.println("INFO: "+toString()+" unable to provide safe lock for "+Thread.currentThread()); return false; } lock(); return true; } /** Locks the mutex. It works like {@link #lockWithTimeout(long)} except that it returns immediately if the same thread already owns the lock. It is safer to use this function rather than {@link #lockWithTimeout(long)}, because lock can possibly cause a deadlock which won't be resolved. @return true is the mutex was successfully locked, false if deadlock was detected or timeout elapsed. */ public synchronized boolean safeLockWithTimeout(long to) { if (locked && lockedBy==Thread.currentThread()) { if (verbose) System.out.println("INFO: "+toString()+" unable to provide safe lock (deadlock detected) for "+Thread.currentThread()); return false; } return lockWithTimeout(to); } /** unlocks the mutex. It is possible to unlock an unlocked mutex, but a warning may be issued. */ public synchronized void unlock() { if (locked && lockedBy!=Thread.currentThread()) System.err.println("WARNING: org.rosuda.JRI.Mutex was unlocked by other thread than locked! This may soon lead to a crash..."); locked=false; if (verbose) System.out.println("INFO: "+toString()+" unlocked by "+Thread.currentThread()); // notify just 1 in case more of them are waiting notify(); } public String toString() { return super.toString()+"["+((locked)?"":"un")+"locked"+((!locked)?"":(", by "+((lockedBy==Thread.currentThread())?"current":"another")+" thread"))+"]"; } } rJava/jri/RBool.java0000644000176200001440000000202612256051760013765 0ustar liggesuserspackage org.rosuda.JRI; // JRclient library - client interface to Rserve, see http://www.rosuda.org/Rserve/ // Copyright (C) 2004 Simon Urbanek // --- for licensing information see LICENSE file in the original JRclient distribution --- /** Implementation of tri-state logical data type in R. The three states are TRUE, FALSE and NA. To obtain truly boolean value, you'll need to use {@link #isTRUE} or {@link #isFALSE} since there is no canonical representation of RBool in boolean @version $Id: RBool.java 2720 2007-03-15 17:35:42Z urbanek $ */ public class RBool extends Object { int val; public RBool(boolean b) { val=(b)?1:0; }; public RBool(RBool r) { val=r.val; }; public RBool(int i) { /* 0=FALSE, 2=NA, anything else = TRUE */ val=(i==0||i==2)?i:1; }; public boolean isNA() { return (val==2); }; public boolean isTRUE() { return (val==1); }; public boolean isFALSE() { return (val==0); }; public String toString() { return (val==0)?"FALSE":((val==2)?"NA":"TRUE"); }; } rJava/jri/examples/0000755000176200001440000000000012256051760013723 5ustar liggesusersrJava/jri/examples/rtest.java0000644000176200001440000002033212256051760015727 0ustar liggesusersimport java.io.*; import java.awt.Frame; import java.awt.FileDialog; import java.util.Enumeration; import org.rosuda.JRI.Rengine; import org.rosuda.JRI.REXP; import org.rosuda.JRI.RList; import org.rosuda.JRI.RVector; import org.rosuda.JRI.RMainLoopCallbacks; class TextConsole implements RMainLoopCallbacks { public void rWriteConsole(Rengine re, String text, int oType) { System.out.print(text); } public void rBusy(Rengine re, int which) { System.out.println("rBusy("+which+")"); } public String rReadConsole(Rengine re, String prompt, int addToHistory) { System.out.print(prompt); try { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); String s=br.readLine(); return (s==null||s.length()==0)?s:s+"\n"; } catch (Exception e) { System.out.println("jriReadConsole exception: "+e.getMessage()); } return null; } public void rShowMessage(Rengine re, String message) { System.out.println("rShowMessage \""+message+"\""); } public String rChooseFile(Rengine re, int newFile) { FileDialog fd = new FileDialog(new Frame(), (newFile==0)?"Select a file":"Select a new file", (newFile==0)?FileDialog.LOAD:FileDialog.SAVE); fd.show(); String res=null; if (fd.getDirectory()!=null) res=fd.getDirectory(); if (fd.getFile()!=null) res=(res==null)?fd.getFile():(res+fd.getFile()); return res; } public void rFlushConsole (Rengine re) { } public void rLoadHistory (Rengine re, String filename) { } public void rSaveHistory (Rengine re, String filename) { } } public class rtest { public static void main(String[] args) { // just making sure we have the right version of everything if (!Rengine.versionCheck()) { System.err.println("** Version mismatch - Java files don't match library version."); System.exit(1); } System.out.println("Creating Rengine (with arguments)"); // 1) we pass the arguments from the command line // 2) we won't use the main loop at first, we'll start it later // (that's the "false" as second argument) // 3) the callbacks are implemented by the TextConsole class above Rengine re=new Rengine(args, false, new TextConsole()); System.out.println("Rengine created, waiting for R"); // the engine creates R is a new thread, so we should wait until it's ready if (!re.waitForR()) { System.out.println("Cannot load R"); return; } /* High-level API - do not use RNI methods unless there is no other way to accomplish what you want */ try { REXP x; re.eval("data(iris)",false); System.out.println(x=re.eval("iris")); // generic vectors are RVector to accomodate names RVector v = x.asVector(); if (v.getNames()!=null) { System.out.println("has names:"); for (Enumeration e = v.getNames().elements() ; e.hasMoreElements() ;) { System.out.println(e.nextElement()); } } // for compatibility with Rserve we allow casting of vectors to lists RList vl = x.asList(); String[] k = vl.keys(); if (k!=null) { System.out.println("and once again from the list:"); int i=0; while (imean(iris[[1]])")); // R knows about TRUE/FALSE/NA, so we cannot use boolean[] this way // instead, we use int[] which is more convenient (and what R uses internally anyway) int[] bi = x.asIntArray(); { int i = 0; while (i to continue (time to attach the debugger if necessary)"); try { System.in.read(); } catch(Exception e) {}; System.out.println("Creating Rengine (with arguments)"); Rengine re=new Rengine(args, true, new TextConsole2()); System.out.println("Rengine created, waiting for R"); if (!re.waitForR()) { System.out.println("Cannot load R"); return; } System.out.println("re-routing stdout/err into R console"); System.setOut(new PrintStream(new RConsoleOutputStream(re, 0))); System.setErr(new PrintStream(new RConsoleOutputStream(re, 1))); System.out.println("Letting go; use main loop from now on"); } } rJava/jri/configure.ac0000644000176200001440000002407412256051760014402 0ustar liggesusersAC_INIT([JRI],[0.3],[simon.urbanek@r-project.org]) AC_CONFIG_SRCDIR([src/jri.h]) AC_CONFIG_HEADER([src/config.h]) AC_CONFIG_AUX_DIR([tools]) AC_CANONICAL_BUILD AC_CANONICAL_HOST # find R home : ${R_HOME=`R RHOME`} if test -z "${R_HOME}"; then echo "could not determine R_HOME" exit 1 fi # we attempt to use the same compiler as R did RBIN="${R_HOME}/bin/R" R_CC=`"${RBIN}" CMD config CC` R_CPP=`"${RBIN}" CMD config CPP` R_CFLAGS=`"${RBIN}" CMD config CFLAGS` # find R_SHARE_DIR : ${R_SHARE_DIR=`"${RBIN}" CMD sh -c 'echo $R_SHARE_DIR'`} if test -z "${R_SHARE_DIR}"; then echo "could not determine R_SHARE_DIR" exit 1 fi # find R_DOC_DIR : ${R_DOC_DIR=`"${RBIN}" CMD sh -c 'echo $R_DOC_DIR'`} if test -z "${R_DOC_DIR}"; then echo "could not determine R_DOC_DIR" exit 1 fi # find R_INCLUDE_DIR : ${R_INCLUDE_DIR=`"${RBIN}" CMD sh -c 'echo $R_INCLUDE_DIR'`} if test -z "${R_INCLUDE_DIR}"; then echo "could not determine R_INCLUDE_DIR" exit 1 fi # if user did not specify CC then we use R's settings. # if CC was set then user is responsible for CFLAGS as well! if test -z "${CC}"; then CC="${R_CC}" CPP="${R_CPP}" CFLAGS="${R_CFLAGS}" fi RINC=`"${RBIN}" CMD config --cppflags` RLD=`"${RBIN}" CMD config --ldflags` if test -z "$RLD"; then AC_MSG_ERROR([R was not compiled with --enable-R-shlib *** You must have libR.so or equivalent in order to use JRI *** ]) fi AC_SUBST(R_HOME) AC_SUBST(R_SHARE_DIR) AC_SUBST(R_DOC_DIR) AC_SUBST(R_INCLUDE_DIR) AC_PROG_CC AC_HEADER_STDC ## RUN_JAVA(variable for the result, parameters) ## ---------- ## runs the java interpreter ${JAVA_PROG} with specified parameters and ## saves the output to the supplied variable. The exit value is ignored. AC_DEFUN([RUN_JAVA], [ acx_java_result= if test -z "${JAVA_PROG}"; then echo "$as_me:$LINENO: JAVA_PROG is not set, cannot run java $2" >&AS_MESSAGE_LOG_FD else echo "$as_me:$LINENO: running ${JAVA_PROG} $2" >&AS_MESSAGE_LOG_FD acx_java_result=`${JAVA_PROG} $2 2>&AS_MESSAGE_LOG_FD` echo "$as_me:$LINENO: output: '$acx_java_result'" >&AS_MESSAGE_LOG_FD fi $1=$acx_java_result ]) if test -n "${CONFIGURED}"; then ## re-map varibles that don't match JAVA_PROG="${JAVA}" JAVA_INC="${JAVA_CPPFLAGS}" JAVA_LD_PATH="${JAVA_LD_LIBRARY_PATH}" else ## find java compiler binaries if test -z "${JAVA_HOME}" ; then JAVA_PATH=${PATH} else JAVA_PATH=${JAVA_HOME}:${JAVA_HOME}/jre/bin:${JAVA_HOME}/bin:${JAVA_HOME}/../bin:${PATH} fi ## if 'java' is not on the PATH or JAVA_HOME, add some guesses as of ## where java could live JAVA_PATH=${JAVA_PATH}:/usr/java/bin:/usr/jdk/bin:/usr/lib/java/bin:/usr/lib/jdk/bin:/usr/local/java/bin:/usr/local/jdk/bin:/usr/local/lib/java/bin:/usr/local/lib/jdk/bin AC_PATH_PROGS(JAVA_PROG,java,,${JAVA_PATH}) ## FIXME: we may want to check for jikes, kaffe and others... AC_PATH_PROGS(JAVAC,javac,,${JAVA_PATH}) AC_PATH_PROGS(JAVAH,javah,,${JAVA_PATH}) AC_PATH_PROGS(JAR,jar,,${JAVA_PATH}) fi have_all_java=yes if test -z "$JAVA_PROG"; then have_all_java=no; fi if test -z "$JAVAC"; then have_all_java=no; fi if test -z "$JAVAH"; then have_all_java=no; fi if test -z "$JAR"; then have_all_java=no; fi if test ${have_all_java} = no; then AC_MSG_ERROR([one or more Java tools are missing. *** JDK is incomplete! Please make sure you have a complete JDK. JRE is *not* sufficient.]) fi ## this is where our test-class lives getsp_cp=tools AC_MSG_CHECKING([whether Java interpreter works]) acx_java_works=no if test -n "${JAVA_PROG}" ; then RUN_JAVA(acx_jc_result,[-classpath ${getsp_cp} getsp -test]) if test "${acx_jc_result}" = "Test1234OK"; then acx_java_works=yes fi acx_jc_result= fi if test -z "${CONFIGURED}"; then if test ${acx_java_works} = yes; then AC_MSG_RESULT([yes]) AC_MSG_CHECKING([for Java environment]) ## retrieve JAVA_HOME from Java itself if not set if test -z "${JAVA_HOME}" ; then RUN_JAVA(JAVA_HOME,[-classpath ${getsp_cp} getsp java.home]) fi ## the availability of JAVA_HOME will tell us whether it's supported if test -z "${JAVA_HOME}" ; then if test x$acx_java_env_msg != xyes; then AC_MSG_RESULT([not found]) fi else AC_MSG_RESULT([in ${JAVA_HOME}]) case "${host_os}" in darwin*) JAVA_LIBS="-framework JavaVM" JAVA_LD_PATH= ;; *) RUN_JAVA(JAVA_LIBS, [-classpath ${getsp_cp} getsp -libs]) JAVA_LIBS="${JAVA_LIBS} -ljvm" RUN_JAVA(JAVA_LD_PATH, [-classpath ${getsp_cp} getsp java.library.path]) ;; esac ## note that we actually don't test JAVA_LIBS - we hope that the detection ## was correct. We should also test the functionality for javac. have_java=yes fi else AC_MSG_RESULT([no]) AC_MSG_ERROR([Java not found. Please install JDK 1.4 or later, make sure that the binaries are on the PATH and re-try. If that doesn't work, set JAVA_HOME correspondingly.]) fi AC_CHECK_FILE(${JAVA_HOME}/include/jni.h, [JNI_H="${JAVA_HOME}/include"], [AC_CHECK_FILE(${JAVA_HOME}/jni.h, [JNI_H="${JAVA_HOME}"], [AC_CHECK_FILE(${JAVA_HOME}/../include/jni.h, [JNI_H="${JAVA_HOME}/../include"], [AC_MSG_ERROR([jni headers not found. Please make sure you have a proper JDK installed.]) ]) ]) ]) JAVA_INC="-I${JNI_H}" : ${JAVA_CFLAGS=-D_REENTRANT} # Sun's JDK needs jni_md.h in in addition to jni.h and unfortunately it's stored somewhere else ... # this should be become more general at some point - so far we're checking linux and solaris only # (well, those are presumably the only platforms supported by Sun's JDK and others don't need this # at least as of now - 01/2004) jac_found_md=no for mddir in . linux solaris ppc irix alpha aix hp-ux genunix cygwin win32 freebsd; do AC_CHECK_FILE(${JNI_H}/$mddir/jni_md.h,[JAVA_INC="${JAVA_INC} -I${JNI_H}/$mddir" jac_found_md=yes]) if test ${jac_found_md} = yes; then break; fi done fi ## the configure variables may contain $(JAVA_HOME) which for testing needs to be replaced by the real path if test `echo foo | sed -e 's:foo:bar:'` = bar; then JAVA_INC0=`echo ${JAVA_INC} | sed -e 's:$(JAVA_HOME):'${JAVA_HOME}':g'` JAVA_LIBS0=`echo ${JAVA_LIBS} | sed -e 's:$(JAVA_HOME):'${JAVA_HOME}':g'` JAVA_LD_PATH0=`echo ${JAVA_LD_PATH} | sed -e 's:$(JAVA_HOME):'${JAVA_HOME}':g'` else AC_MSG_WARN([sed is not working properly - the configuration may fail]) JAVA_INC0="${JAVA_INC}" JAVA_LIBS0="${JAVA_LIBS}" JAVA_LD_PATH0="${JAVA_LD_PATH}" fi LIBS="${LIBS} ${JAVA_LIBS0}" CFLAGS="${CFLAGS} ${JAVA_CFLAGS} ${JAVA_INC0}" AC_MSG_CHECKING([whether JNI programs can be compiled]) AC_LINK_IFELSE([ #include int main(void) { jobject o; return 0; } ],[AC_MSG_RESULT(yes)], [AC_MSG_ERROR([Cannot compile a simple JNI program. See config.log for details.])]) LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${JAVA_LD_PATH0} export LD_LIBRARY_PATH AC_MSG_CHECKING([whether JNI programs can be run]) AC_RUN_IFELSE([ #include int main(void) { jobject o; return 0; } ],[AC_MSG_RESULT(yes)], [AC_MSG_ERROR([Cannot run a simple JNI program - probably your jvm library is in non-standard location or JVM is unsupported. See config.log for details.])]) AC_MSG_CHECKING([JNI data types]) AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include int main(void) { return (sizeof(int)==sizeof(jint) && sizeof(long)==sizeof(long) && sizeof(jbyte)==sizeof(char) && sizeof(jshort)==sizeof(short) && sizeof(jfloat)==sizeof(float) && sizeof(jdouble)==sizeof(double))?0:1; } ]])],[AC_MSG_RESULT([ok])],[AC_MSG_ERROR([One or more JNI types differ from the corresponding native type. You may need to use non-standard compiler flags or a different compiler in order to fix this.])],[]) JNIPREFIX=lib CPICF=`"${RBIN}" CMD config CPICFLAGS` JNISO=.so JNILD=`"${RBIN}" CMD config SHLIB_LDFLAGS`" ${JAVA_LIBS}" # we need to adjust a few things according to OS .. case "${host_os}" in darwin*) JNISO=.jnilib JNILD="-dynamiclib -framework JavaVM" CPICF=-fno-common if test -e "${R_HOME}/lib/i386" -a -e "${R_HOME}/lib/ppc" -a -e "${R_HOME}/lib/libR.dylib"; then # we have an universal framework, so we will use stubs and fat lib RLD="-framework R" RINC="-I${R_HOME}/include" # we can even cross-compile, maybe if test -z "${FORCE_NATIVE}"; then # find out the archs of JavaVM and build all of them jarchs=`file -L /System/Library/Frameworks/JavaVM.framework/JavaVM 2>/dev/null | sed -n 's/.*for architecture //p' | sed 's:).*::' | sed 's:ppc7.*:ppc:' | tr '\n' ' '` jrarchs='' ## ok, we have Java archs, but R may not be available for all of those for a in ${jarchs}; do if test -e "${R_HOME}/lib/$a"; then jrarchs="${jrarchs} $a"; fi done ## if have have more than one arch, display info and add -arch flags if test -n "${jrarchs}"; then echo "*** building fat JNI with gcc for architectures: ${jrarchs} ***" echo "*** use FORCE_NATIVE=yes to avoid this and use R settings ***" CFLAGS="" LDFLAGS="" CC="gcc" for a in ${jrarchs}; do CC="${CC} -arch $a"; done fi fi fi ;; *) ;; esac origCFLAGS=$CFLAGS CFLAGS="${CFLAGS} ${R_CFLAGS} ${RINC}" AC_MSG_CHECKING([whether Rinterface.h exports R_CStackXXX variables]) AC_COMPILE_IFELSE([ #define CSTACK_DEFNS #include #include int main(void) { return R_CStackLimit?0:1; } ],[AC_MSG_RESULT(yes) DEFFLAGS="${DEFFLAGS} -DRIF_HAS_CSTACK"], [AC_MSG_RESULT(no)]) AC_MSG_CHECKING([whether Rinterface.h exports R_SignalHandlers]) AC_COMPILE_IFELSE([ #include #include int main(void) { return R_SignalHandlers; } ],[AC_MSG_RESULT(yes) DEFFLAGS="${DEFFLAGS} -DRIF_HAS_RSIGHAND"], [AC_MSG_RESULT(no)]) CFLAGS=${origCFLAGS} AC_SUBST(JAVA_HOME) AC_SUBST(JAVA_PROG) AC_SUBST(JAVA_LD_PATH) AC_SUBST(JAVA_LIBS) AC_SUBST(JAVA_INC) AC_SUBST(JAVA_CFLAGS) AC_SUBST(JAVAC) AC_SUBST(JAVAH) AC_SUBST(JAR) AC_SUBST(JNILD) AC_SUBST(JNISO) AC_SUBST(JNIPREFIX) AC_SUBST(CPICF) AC_SUBST(CFLAGS) AC_SUBST(LDFLAGS) AC_SUBST(RINC) AC_SUBST(RLD) AC_SUBST(CC) AC_SUBST(DEFFLAGS) AC_CONFIG_FILES([src/Makefile]) AC_CONFIG_FILES([Makefile]) AC_CONFIG_FILES([run], [chmod +x run]) AC_OUTPUT rJava/jri/run.in0000644000176200001440000000132412256051760013241 0ustar liggesusers#!/bin/sh R_HOME=@R_HOME@ R_SHARE_DIR=@R_SHARE_DIR@ export R_SHARE_DIR R_INCLUDE_DIR=@R_INCLUDE_DIR@ export R_INCLUDE_DIR R_DOC_DIR=@R_DOC_DIR@ export R_DOC_DIR JRI_LD_PATH=${R_HOME}/lib:${R_HOME}/bin:@JAVA_LD_PATH@ if test -z "$LD_LIBRARY_PATH"; then LD_LIBRARY_PATH=$JRI_LD_PATH else LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$JRI_LD_PATH fi JAVA=@JAVA_PROG@ : ${CLASSPATH=.:examples} export R_HOME export LD_LIBRARY_PATH if [ -z "$1" ]; then echo "" echo " Usage: run [...]" echo "" echo " For example: ./run rtest" echo " Set CLASSPATH variable if other than .:examples is desired" echo "" else ${JAVA} -Djava.library.path=.:@JAVA_LD_PATH@ -cp ${CLASSPATH}:src/JRI.jar:JRI.jar $* fi rJava/jri/src/0000755000176200001440000000000012256051760012674 5ustar liggesusersrJava/jri/src/jri.h0000644000176200001440000000520612256051760013634 0ustar liggesusers#ifndef __JRI_H__ #define __JRI_H__ #include #include #include #include #include /* the viewpoint is from R, i.e. "get" means "Java->R" whereas "put" means "R->Java" */ #define JRI_VERSION 0x0505 /* JRI v0.5-5 */ #define JRI_API 0x010a /* API-version 1.10 */ #ifdef __cplusplus extern "C" { #endif /* jlong can always hold a pointer to avoid warnings we go ptr->ulong->jlong */ #define SEXP2L(s) ((jlong)(s)) #ifdef WIN64 #define L2SEXP(s) ((SEXP)((jlong)(s))) #else #define L2SEXP(s) ((SEXP)((jlong)((unsigned long)(s)))) #endif jstring jri_callToString(JNIEnv *env, jobject o); SEXP jri_getDoubleArray(JNIEnv *env, jarray o); SEXP jri_getIntArray(JNIEnv *env, jarray o); SEXP jri_getByteArray(JNIEnv *env, jarray o); SEXP jri_getBoolArrayI(JNIEnv *env, jarray o); SEXP jri_getBoolArray(JNIEnv *env, jarray o); SEXP jri_getObjectArray(JNIEnv *env, jarray o); SEXP jri_getString(JNIEnv *env, jstring s); SEXP jri_getStringArray(JNIEnv *env, jarray o); SEXP jri_getSEXPLArray(JNIEnv *env, jarray o); SEXP jri_installString(JNIEnv *env, jstring s); /* as Rf_install, just for Java strings */ jarray jri_putDoubleArray(JNIEnv *env, SEXP e); jarray jri_putIntArray(JNIEnv *env, SEXP e); jarray jri_putBoolArrayI(JNIEnv *env, SEXP e); jarray jri_putByteArray(JNIEnv *env, SEXP e); jstring jri_putString(JNIEnv *env, SEXP e, int ix); /* ix=index, 0=1st */ jarray jri_putStringArray(JNIEnv *env, SEXP e); jarray jri_putSEXPLArray(JNIEnv *env, SEXP e); /* SEXPs are strored as "long"s */ jstring jri_putSymbolName(JNIEnv *env, SEXP e); void jri_checkExceptions(JNIEnv *env, int describe); void jri_error(char *fmt, ...); /* define mkCharUTF8 in a compatible fashion */ #if R_VERSION < R_Version(2,7,0) #define mkCharUTF8(X) mkChar(X) #define CHAR_UTF8(X) CHAR(X) #else #define mkCharUTF8(X) mkCharCE(X, CE_UTF8) #define CHAR_UTF8(X) jri_char_utf8(X) const char *jri_char_utf8(SEXP); #endif #ifdef __cplusplus } #endif #endif /* API version changes: ----------------------- 1.3 (initial public API version) [ 1.4 never publicly released - added put/getenv but was abandoned ] 1.5 JRI 0.3-0 + rniGetTAG + rniInherits + rniGetSymbolName + rniInstallSymbol + rniJavaToXref, rniXrefToJava 1.6 JRI 0.3-2 + rniPutBoolArray, rniPutBoolArrayI, rniGetBoolArrayI 1.7 JRI 0.3-7 + rniCons(+2 args) 1.8 JRI 0.4-0 + rniPrint 1.9 JRI 0.4-3 + rniPreserve, rniRelease + rniParentEnv, rniFindVar, rniListEnv + rniSpecialObject(0-7) + rniPrintValue 1.10 JRI 0.5-1 * rniAssign returns jboolean instead of void */ rJava/jri/src/Rengine.c0000644000176200001440000004340712256051760014437 0ustar liggesusers/* Rengine - implements native rni methods called from the Rengine class */ #include #include "jri.h" #include "org_rosuda_JRI_Rengine.h" #include "rjava.h" #include #include #ifndef WIN32 /* this is for interrupt handing since GD uses R_interrupts_pending */ #include /* Before R 2.7.0 R_interrupts_pending was not included, though */ #if R_VERSION < R_Version(2,7,0) LibExtern int R_interrupts_pending; #endif #endif /* the # of arguments to R_ParseVector changed since R 2.5.0 */ #if R_VERSION < R_Version(2,5,0) #define RS_ParseVector R_ParseVector #else #define RS_ParseVector(A,B,C) R_ParseVector(A,B,C,R_NilValue) #endif #include "Rcallbacks.h" #include "Rinit.h" #include "globals.h" #include "Rdecl.h" #ifdef Win32 #include #ifdef _MSC_VER __declspec(dllimport) int UserBreak; #else #ifndef WIN64 #define UserBreak (*_imp__UserBreak) #endif extern int UserBreak; #endif #else /* for R_runHandlers */ #include #include #include #endif JNIEXPORT jlong JNICALL Java_org_rosuda_JRI_Rengine_rniGetVersion (JNIEnv *env, jclass this) { return (jlong) JRI_API; } JNIEXPORT jint JNICALL Java_org_rosuda_JRI_Rengine_rniSetupR (JNIEnv *env, jobject this, jobjectArray a) { int initRes; char *fallbackArgv[]={"Rengine",0}; char **argv=fallbackArgv; int argc=1; #ifdef JRI_DEBUG printf("rniSetupR\n"); #endif engineObj=(*env)->NewGlobalRef(env, this); engineClass=(*env)->NewGlobalRef(env, (*env)->GetObjectClass(env, engineObj)); eenv=env; if (a) { /* retrieve the content of the String[] and construct argv accordingly */ int len = (int)(*env)->GetArrayLength(env, a); if (len>0) { int i=0; argv=(char**) malloc(sizeof(char*)*(len+2)); argv[0]=fallbackArgv[0]; while (i < len) { jobject o=(*env)->GetObjectArrayElement(env, a, i); i++; if (o) { const char *c; c=(*env)->GetStringUTFChars(env, o, 0); if (!c) argv[i]=""; else { argv[i] = strdup(c); (*env)->ReleaseStringUTFChars(env, o, c); } } else argv[i]=""; } argc=len+1; argv[argc]=0; } } if (argc==2 && !strcmp(argv[1],"--zero-init")) {/* special case for direct embedding (exp!) */ initRinside(); return 0; } initRes=initR(argc, argv); /* we don't release the argv in case R still needs it later (even if it shouldn't), but it's not really a significant leak */ return initRes; } JNIEXPORT jlong JNICALL Java_org_rosuda_JRI_Rengine_rniParse (JNIEnv *env, jobject this, jstring str, jint parts) { ParseStatus ps; SEXP pstr, cv; PROTECT(cv=jri_getString(env, str)); #ifdef JRI_DEBUG printf("parsing \"%s\"\n", CHAR(STRING_ELT(cv,0))); #endif pstr=RS_ParseVector(cv, parts, &ps); #ifdef JRI_DEBUG printf("parse status=%d, result=%x, type=%d\n", ps, (int) pstr, (pstr!=0)?TYPEOF(pstr):0); #endif UNPROTECT(1); return SEXP2L(pstr); } /** * Evaluates one expression or a list of expressions * * @param exp long reflection of the expression to evaluate * @param rho long reflection of the environment where to evaluate * * @return 0 if an evaluation error ocurred or exp is 0 */ JNIEXPORT jlong JNICALL Java_org_rosuda_JRI_Rengine_rniEval (JNIEnv *env, jobject this, jlong exp, jlong rho) { SEXP es = R_NilValue, exps = L2SEXP(exp); SEXP eval_env = L2SEXP(rho); int er = 0; int i = 0, l; /* invalid (NULL) expression (parse error, ... ) */ if (!exp) return 0; if (TYPEOF(exps) == EXPRSXP) { /* if the object is a list of exps, eval them one by one */ l = LENGTH(exps); while (i < l) { es = R_tryEval(VECTOR_ELT(exps,i), eval_env, &er); /* an error occured, no need to continue */ if (er) return 0; i++; } } else es = R_tryEval(exps, eval_env, &er); /* er is just a flag - on error return 0 */ if (er) return 0; return SEXP2L(es); } struct safeAssign_s { SEXP sym, val, rho; }; static void safeAssign(void *data) { struct safeAssign_s *s = (struct safeAssign_s*) data; defineVar(s->sym, s->val, s->rho); } JNIEXPORT jboolean JNICALL Java_org_rosuda_JRI_Rengine_rniAssign (JNIEnv *env, jobject this, jstring symName, jlong valL, jlong rhoL) { struct safeAssign_s s; s.sym = jri_installString(env, symName); if (!s.sym || s.sym == R_NilValue) return JNI_FALSE; s.rho = rhoL ? L2SEXP(rhoL) : R_GlobalEnv; s.val = valL ? L2SEXP(valL) : R_NilValue; /* we have to use R_ToplevelExec because defineVar may fail on locked bindings */ return R_ToplevelExec(safeAssign, (void*) &s) ? JNI_TRUE : JNI_FALSE; } JNIEXPORT void JNICALL Java_org_rosuda_JRI_Rengine_rniProtect (JNIEnv *env, jobject this, jlong exp) { PROTECT(L2SEXP(exp)); } JNIEXPORT void JNICALL Java_org_rosuda_JRI_Rengine_rniUnprotect (JNIEnv *env, jobject this, jint count) { UNPROTECT(count); } JNIEXPORT void JNICALL Java_org_rosuda_JRI_Rengine_rniRelease (JNIEnv *env, jobject this, jlong exp) { if (exp) R_ReleaseObject(L2SEXP(exp)); } JNIEXPORT void JNICALL Java_org_rosuda_JRI_Rengine_rniPreserve (JNIEnv *env, jobject this, jlong exp) { if (exp) R_PreserveObject(L2SEXP(exp)); } JNIEXPORT void JNICALL Java_org_rosuda_JRI_Rengine_rniPrintValue (JNIEnv *env, jobject this, jlong exp) { Rf_PrintValue(exp ? L2SEXP(exp) : R_NilValue); } JNIEXPORT jlong JNICALL Java_org_rosuda_JRI_Rengine_rniParentEnv (JNIEnv *env, jobject this, jlong exp) { return SEXP2L(ENCLOS(exp ? L2SEXP(exp) : R_GlobalEnv)); } JNIEXPORT jlong JNICALL Java_org_rosuda_JRI_Rengine_rniFindVar (JNIEnv *env, jobject this, jstring symName, jlong rho) { SEXP sym = jri_installString(env, symName); if (!sym || sym == R_NilValue) return 0; return SEXP2L(Rf_findVar(sym, rho ? L2SEXP(rho) : R_GlobalEnv)); } JNIEXPORT jlong JNICALL Java_org_rosuda_JRI_Rengine_rniListEnv (JNIEnv *env, jobject this, jlong rho, jboolean all) { return SEXP2L(R_lsInternal(rho ? L2SEXP(rho) : R_GlobalEnv, all)); } JNIEXPORT jlong JNICALL Java_org_rosuda_JRI_Rengine_rniSpecialObject (JNIEnv *env, jobject this, jint which) { switch (which) { case 0: return SEXP2L(R_NilValue); case 1: return SEXP2L(R_GlobalEnv); case 2: return SEXP2L(R_EmptyEnv); case 3: return SEXP2L(R_BaseEnv); case 4: return SEXP2L(R_UnboundValue); case 5: return SEXP2L(R_MissingArg); case 6: return SEXP2L(R_NaString); case 7: return SEXP2L(R_BlankString); } return 0; } JNIEXPORT jobject JNICALL Java_org_rosuda_JRI_Rengine_rniXrefToJava (JNIEnv *env, jobject this, jlong exp) { SEXP xp = L2SEXP(exp); if (TYPEOF(xp) != EXTPTRSXP) return 0; return (jobject) EXTPTR_PTR(xp); } JNIEXPORT jlong JNICALL Java_org_rosuda_JRI_Rengine_rniJavaToXref (JNIEnv *env, jobject this, jobject o) { /* this is pretty much from Rglue.c of rJava */ jobject go = (*env)->NewGlobalRef(env, o); return SEXP2L(R_MakeExternalPtr(go, R_NilValue, R_NilValue)); } JNIEXPORT jstring JNICALL Java_org_rosuda_JRI_Rengine_rniGetString (JNIEnv *env, jobject this, jlong exp) { return jri_putString(env, L2SEXP(exp), 0); } JNIEXPORT jobjectArray JNICALL Java_org_rosuda_JRI_Rengine_rniGetStringArray (JNIEnv *env, jobject this, jlong exp) { return jri_putStringArray(env, L2SEXP(exp)); } JNIEXPORT jintArray JNICALL Java_org_rosuda_JRI_Rengine_rniGetIntArray (JNIEnv *env, jobject this, jlong exp) { return jri_putIntArray(env, L2SEXP(exp)); } JNIEXPORT jbyteArray JNICALL Java_org_rosuda_JRI_Rengine_rniGetRawArray (JNIEnv *env, jobject this, jlong exp) { return jri_putByteArray(env, L2SEXP(exp)); } JNIEXPORT jintArray JNICALL Java_org_rosuda_JRI_Rengine_rniGetBoolArrayI (JNIEnv *env, jobject this, jlong exp) { return jri_putBoolArrayI(env, L2SEXP(exp)); } JNIEXPORT jintArray JNICALL Java_org_rosuda_JRI_Rengine_rniGetDoubleArray (JNIEnv *env, jobject this, jlong exp) { return jri_putDoubleArray(env, L2SEXP(exp)); } JNIEXPORT jlongArray JNICALL Java_org_rosuda_JRI_Rengine_rniGetVector (JNIEnv *env, jobject this, jlong exp) { return jri_putSEXPLArray(env, L2SEXP(exp)); } JNIEXPORT jint JNICALL Java_org_rosuda_JRI_Rengine_rniExpType (JNIEnv *env, jobject this, jlong exp) { return exp ? TYPEOF(L2SEXP(exp)) : 0; } JNIEXPORT void JNICALL Java_org_rosuda_JRI_Rengine_rniIdle (JNIEnv *env, jobject this) { #ifndef Win32 R_runHandlers(R_InputHandlers, R_checkActivity(0, 1)); #endif } JNIEXPORT void JNICALL Java_org_rosuda_JRI_Rengine_rniRunMainLoop (JNIEnv *env, jobject this) { run_Rmainloop(); } JNIEXPORT jlong JNICALL Java_org_rosuda_JRI_Rengine_rniPutString (JNIEnv *env, jobject this, jstring s) { return SEXP2L(jri_getString(env, s)); } JNIEXPORT jlong JNICALL Java_org_rosuda_JRI_Rengine_rniPutStringArray (JNIEnv *env, jobject this, jobjectArray a) { return SEXP2L(jri_getStringArray(env, a)); } JNIEXPORT jlong JNICALL Java_org_rosuda_JRI_Rengine_rniPutIntArray (JNIEnv *env, jobject this, jintArray a) { return SEXP2L(jri_getIntArray(env, a)); } JNIEXPORT jlong JNICALL Java_org_rosuda_JRI_Rengine_rniPutRawArray (JNIEnv *env, jobject this, jbyteArray a) { return SEXP2L(jri_getByteArray(env, a)); } JNIEXPORT jlong JNICALL Java_org_rosuda_JRI_Rengine_rniPutBoolArrayI (JNIEnv *env, jobject this, jintArray a) { return SEXP2L(jri_getBoolArrayI(env, a)); } JNIEXPORT jlong JNICALL Java_org_rosuda_JRI_Rengine_rniPutBoolArray (JNIEnv *env, jobject this, jbooleanArray a) { return SEXP2L(jri_getBoolArray(env, a)); } JNIEXPORT jlong JNICALL Java_org_rosuda_JRI_Rengine_rniPutDoubleArray (JNIEnv *env, jobject this, jdoubleArray a) { return SEXP2L(jri_getDoubleArray(env, a)); } JNIEXPORT jlong JNICALL Java_org_rosuda_JRI_Rengine_rniPutVector (JNIEnv *env, jobject this, jlongArray a) { return SEXP2L(jri_getSEXPLArray(env, a)); } JNIEXPORT jlong JNICALL Java_org_rosuda_JRI_Rengine_rniGetAttr (JNIEnv *env, jobject this, jlong exp, jstring name) { SEXP an = jri_installString(env, name); if (!an || an==R_NilValue || exp==0 || L2SEXP(exp)==R_NilValue) return 0; { SEXP a = getAttrib(L2SEXP(exp), an); return (a==R_NilValue)?0:SEXP2L(a); } } JNIEXPORT jobjectArray JNICALL Java_org_rosuda_JRI_Rengine_rniGetAttrNames (JNIEnv *env, jobject this, jlong exp) { SEXP o = L2SEXP(exp); SEXP att = ATTRIB(o), ah = att; unsigned int ac = 0; jobjectArray sa; if (att == R_NilValue) return 0; /* count the number of attributes */ while (ah != R_NilValue) { ac++; ah = CDR(ah); } /* allocate Java array */ sa = (*env)->NewObjectArray(env, ac, (*env)->FindClass(env, "java/lang/String"), 0); if (!sa) return 0; ac = 0; ah = att; /* iterate again and set create the strings */ while (ah != R_NilValue) { SEXP t = TAG(ah); if (t != R_NilValue) { jobject s = (*env)->NewStringUTF(env, CHAR_UTF8(PRINTNAME(t))); (*env)->SetObjectArrayElement(env, sa, ac, s); } ac++; ah = CDR(ah); } return sa; } JNIEXPORT void JNICALL Java_org_rosuda_JRI_Rengine_rniSetAttr (JNIEnv *env, jobject this, jlong exp, jstring aName, jlong attr) { SEXP an = jri_installString(env, aName); if (!an || an==R_NilValue || exp==0 || L2SEXP(exp)==R_NilValue) return; setAttrib(L2SEXP(exp), an, (attr==0)?R_NilValue:L2SEXP(attr)); /* BTW: we don't need to adjust the object bit for "class", setAttrib does that already */ /* this is not official API, but whoever uses this should know what he's doing it's ok for directly constructing attr lists, and that's what it should be used for SET_ATTRIB(L2SEXP(exp), (attr==0)?R_NilValue:L2SEXP(attr)); */ } JNIEXPORT jlong JNICALL Java_org_rosuda_JRI_Rengine_rniInstallSymbol (JNIEnv *env, jobject this, jstring s) { return SEXP2L(jri_installString(env, s)); } JNIEXPORT jstring JNICALL Java_org_rosuda_JRI_Rengine_rniGetSymbolName (JNIEnv *env, jobject this, jlong exp) { return jri_putSymbolName(env, L2SEXP(exp)); } JNIEXPORT jboolean JNICALL Java_org_rosuda_JRI_Rengine_rniInherits (JNIEnv *env, jobject this, jlong exp, jstring s) { jboolean res = 0; const char *c; c=(*env)->GetStringUTFChars(env, s, 0); if (c) { if (inherits(L2SEXP(exp), (char*)c)) res = 1; (*env)->ReleaseStringUTFChars(env, s, c); } return res; } JNIEXPORT jlong JNICALL Java_org_rosuda_JRI_Rengine_rniCons (JNIEnv *env, jobject this, jlong head, jlong tail, jlong tag, jboolean lang) { SEXP l; if (lang) l = LCONS((head==0)?R_NilValue:L2SEXP(head), (tail==0)?R_NilValue:L2SEXP(tail)); else l = CONS((head==0)?R_NilValue:L2SEXP(head), (tail==0)?R_NilValue:L2SEXP(tail)); if (tag) SET_TAG(l, L2SEXP(tag)); return SEXP2L(l); } JNIEXPORT jlong JNICALL Java_org_rosuda_JRI_Rengine_rniCAR (JNIEnv *env, jobject this, jlong exp) { if (exp) { SEXP r = CAR(L2SEXP(exp)); return (r==R_NilValue)?0:SEXP2L(r); } return 0; } JNIEXPORT jlong JNICALL Java_org_rosuda_JRI_Rengine_rniCDR (JNIEnv *env, jobject this, jlong exp) { if (exp) { SEXP r = CDR(L2SEXP(exp)); return (r==R_NilValue)?0:SEXP2L(r); } return 0; } JNIEXPORT jlong JNICALL Java_org_rosuda_JRI_Rengine_rniTAG (JNIEnv *env, jobject this, jlong exp) { if (exp) { SEXP r = TAG(L2SEXP(exp)); return (r==R_NilValue)?0:SEXP2L(r); } return 0; } /* creates a list from SEXPs provided in long[] */ JNIEXPORT jlong JNICALL Java_org_rosuda_JRI_Rengine_rniPutList (JNIEnv *env, jobject this, jlongArray o) { SEXP t=R_NilValue; int l,i=0; jlong *ap; if (!o) return 0; l=(int)(*env)->GetArrayLength(env, o); if (l<1) return SEXP2L(CONS(R_NilValue, R_NilValue)); ap=(jlong*)(*env)->GetLongArrayElements(env, o, 0); if (!ap) return 0; while(iReleaseLongArrayElements(env, o, ap, 0); return SEXP2L(t); } /* retrieves a list (shallow copy) and returns the SEXPs in long[] */ JNIEXPORT jlongArray JNICALL Java_org_rosuda_JRI_Rengine_rniGetList (JNIEnv *env, jobject this, jlong exp) { SEXP e=L2SEXP(exp); if (exp==0 || e==R_NilValue) return 0; { unsigned len=0; SEXP t=e; while (t!=R_NilValue) { t=CDR(t); len++; }; { jlongArray da=(*env)->NewLongArray(env,len); jlong *dae; if (!da) return 0; if (len>0) { int i=0; dae=(*env)->GetLongArrayElements(env, da, 0); if (!dae) { (*env)->DeleteLocalRef(env,da); jri_error("rniGetList: newLongArray.GetLongArrayElements failed"); return 0; } t=e; while (t!=R_NilValue && iReleaseLongArrayElements(env, da, dae, 0); } return da; } } } /* by default those are disabled as it's a problem on Win32 ... */ #ifdef JRI_ENV_CALLS JNIEXPORT void JNICALL Java_org_rosuda_JRI_Rengine_rniSetEnv (JNIEnv *env, jclass this, jstring key, jstring val) { const char *cKey, *cVal; if (!key || !val) return; cKey=(*env)->GetStringUTFChars(env, key, 0); cVal=(*env)->GetStringUTFChars(env, val, 0); if (!cKey || !cVal) { jri_error("rniSetEnv: can't retrieve key/value content"); return; } #ifdef Win32 SetEnvironmentVariable(cKey, cVal); #else setenv(cKey, cVal, 1); #endif (*env)->ReleaseStringUTFChars(env, key, cKey); (*env)->ReleaseStringUTFChars(env, val, cVal); } JNIEXPORT jstring JNICALL Java_org_rosuda_JRI_Rengine_rniGetEnv (JNIEnv *env, jclass this, jstring key) { const char *cKey, *cVal; if (!key) return; cKey=(*env)->GetStringUTFChars(env, key, 0); if (!cKey) { jri_error("rniSetEnv: can't retrieve key/value content"); return; } cVal=getenv(cKey); (*env)->ReleaseStringUTFChars(env, key, cKey); if (!cVal) return 0; return (*env)->NewStringUTF(env, cVal); } #endif JNIEXPORT jint JNICALL Java_org_rosuda_JRI_Rengine_rniSetupRJava (JNIEnv *env, jobject this, jint _in, jint _out) { RJava_setup(_in, _out); return 0; } JNIEXPORT jint JNICALL Java_org_rosuda_JRI_Rengine_rniRJavaLock (JNIEnv *env, jobject this) { return RJava_request_lock(); } JNIEXPORT jint JNICALL Java_org_rosuda_JRI_Rengine_rniRJavaUnlock (JNIEnv *env, jobject this) { return RJava_clear_lock(); } JNIEXPORT void JNICALL Java_org_rosuda_JRI_Rengine_rniPrint (JNIEnv *env, jobject this, jstring s, jint oType) { if (s) { const char *c = (*env)->GetStringUTFChars(env, s, 0); if (c) { if (oType) REprintf("%s", c); else Rprintf("%s", c); } (*env)->ReleaseStringUTFChars(env, s, c); } } JNIEXPORT jint JNICALL Java_org_rosuda_JRI_Rengine_rniStop (JNIEnv *env, jobject this, jint flag) { #ifdef Win32 UserBreak=1; #else /* there are three choices now: 0 = cooperative (requires external interrupt of ReadConsole!) 1 = SIGINT for compatibility with old rniStop() 2 = R's onintr but that one works *only* if used on the R thread (which renders is essentially useless unless used in some synchronous interrupt handler). */ if (flag == 0) R_interrupts_pending = 1; else if (flag == 1) kill(getpid(), SIGINT); else Rf_onintr(); #endif return 0; } rJava/jri/src/win32/0000755000176200001440000000000012256051760013636 5ustar liggesusersrJava/jri/src/win32/Makefile0000644000176200001440000000142312256051760015276 0ustar liggesusers# helper tools and libs for building and running rJava for Windows # Author: Simon Urbanek include $(R_HOME)/etc$(R_ARCH)/Makeconf TARGETS=libjvm.dll.a findjava.exe # libjvm.dll.a - wrapper lib for jvm.dll from Java # findjava.exe - helper tool to find the current JDK from the registry all: $(TARGETS) ifeq ($(strip $(shell $(R_HOME)/bin/R --slave -e 'cat(.Machine$$sizeof.pointer)')),8) JVMDEF=jvm64.def else JVMDEF=jvm.def endif libjvm.dll.a: $(JVMDEF) $(DLLTOOL) --input-def $^ --kill-at --dllname jvm.dll --output-lib $@ # compile findjava.exe from source - no magic here, no special libs necessary findjava.o: findjava.c $(CC) -O2 -c -o $@ $^ findjava.exe: findjava.o $(CC) -s -o $@ $^ # just cleanup everything clean: rm -f *.o *~ $(TARGETS) .PHONY: all clean rJava/jri/src/win32/jvm.def0000644000176200001440000000016512256051760015114 0ustar liggesusersLIBRARY JVM.DLL EXPORTS JNI_CreateJavaVM@12 JNI_GetCreatedJavaVMs@12 JNI_GetDefaultJavaVMInitArgs@4 rJava/jri/src/win32/findjava.c0000644000176200001440000000623112256051760015566 0ustar liggesusers#include #include #include static char RegStrBuf[32768], dbuf[32768]; int main(int argc, char **argv) { int i=0, doit=0; DWORD t,s=32767; HKEY k; HKEY root=HKEY_LOCAL_MACHINE; char *javakey="Software\\JavaSoft\\Java Runtime Environment"; if (argc>1 && argv[1][0]=='-' && argv[1][1]=='R') { if (getenv("R_HOME")) { strcpy(RegStrBuf,getenv("R_HOME")); } else { javakey="Software\\R-core\\R"; s=32767; if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,javakey,0,KEY_QUERY_VALUE,&k)!=ERROR_SUCCESS || RegQueryValueEx(k,"InstallPAth",0,&t,RegStrBuf,&s)!=ERROR_SUCCESS) { if (RegOpenKeyEx(HKEY_CURRENT_USER,javakey,0,KEY_QUERY_VALUE,&k)!=ERROR_SUCCESS || RegQueryValueEx(k,"InstallPath",0,&t,RegStrBuf,&s)!=ERROR_SUCCESS) { fprintf(stderr, "ERROR*> R - can't open registry keys.\n"); return -1; } } } } else /* JAVA_HOME can override our detection - but we still post-process it */ if (getenv("JAVA_HOME")) { strcpy(RegStrBuf,getenv("JAVA_HOME")); } else { #ifdef FINDJRE if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,javakey,0,KEY_QUERY_VALUE,&k)!=ERROR_SUCCESS || RegQueryValueEx(k,"CurrentVersion",0,&t,RegStrBuf,&s)!=ERROR_SUCCESS) { #endif javakey="Software\\JavaSoft\\Java Development Kit"; s=32767; if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,javakey,0,KEY_QUERY_VALUE,&k)!=ERROR_SUCCESS || RegQueryValueEx(k,"CurrentVersion",0,&t,RegStrBuf,&s)!=ERROR_SUCCESS) { fprintf(stderr, "ERROR*> JavaSoft\\{JRE|JDK} can't open registry keys.\n"); /* MessageBox(wh, "Can't find Sun's Java runtime.\nPlease install Sun's J2SE JRE or JDK 1.4.2 or later (see http://java.sun.com/).","Can't find Sun's Java",MB_OK|MB_ICONERROR); */ return -1; } #ifdef FINDJRE } #endif RegCloseKey(k); s=32767; strcpy(dbuf,javakey); strcat(dbuf,"\\"); strcat(dbuf,RegStrBuf); javakey=(char*) malloc(strlen(dbuf)+1); strcpy(javakey, dbuf); if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,javakey,0,KEY_QUERY_VALUE,&k)!=ERROR_SUCCESS || RegQueryValueEx(k,"JavaHome",0,&t,RegStrBuf,&s)!=ERROR_SUCCESS) { fprintf(stderr, "There's no JavaHome value in the JDK/JRE registry key.\n"); /* MessageBox(wh, "Can't find Java home path. Maybe your JRE is too old.\nPlease install Sun's J2SE JRE or SDK 1.4.2 (see http://java.sun.com/).","Can't find Sun's Java",MB_OK|MB_ICONERROR); */ return -1; } RegCloseKey(k); } /*--- post-processing according to supplied flags --*/ /* -a = automagic, i.e. use short name only if the name contains spaces */ i=1; while (i\n\n"; open IN, $fn; $fn=~s/\..*?$//; $fn=$1 if ($fn=~/\/([^\/]+)$/); $pre=$fn; while () { if (/^JNIEXPORT ([a-z]+) JNICALL ([a-zA-Z0-9_]+)/) { $ret=$1; $fn=$2; $a=; if ($a=~/\((JNIEnv.*)\)/) { $par=$1; @p=split /,/,$par; $i=0; undef @pc; foreach (@p) { $_.=" par$i"; push @pc, "par$i"; $i++; } $parn=join ',',@p; $parc=join ', ',@pc; $rc = ($ret eq 'void')?'':'return '; print "typedef $ret(*c_${fn}_t)($par);\nc_${fn}_t Call_$fn;\n"; print "JNIEXPORT $ret JNICALL $fn\n ($parn) {\n $rc Call_$fn($parc);\n }\n\n"; push @fnl, $fn; } } } print "void Setup_$pre(void **ptrs) {\n"; $i=0; foreach (@fnl) { print "Call_$_ = (c_${_}_t) ptrs[$i];\n"; $i++; } print "}\n\n"; $i=0; print "void **GetRef_$pre() { void **ptrs = (void**) malloc(sizeof(void*) * ( $#fnl + 2 ) ); "; foreach (@fnl) { print "ptrs[$i] = (void*) Call_$_;\n"; $i++; } print "ptrs[$i] = (void*) 0;\nreturn ptrs;\n}\n"; rJava/jri/src/config.h.in0000644000176200001440000000104712256051760014721 0ustar liggesusers/* src/config.h.in. Generated from configure.ac by autoheader. */ /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT /* Define to the full name of this package. */ #undef PACKAGE_NAME /* Define to the full name and version of this package. */ #undef PACKAGE_STRING /* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME /* Define to the version of this package. */ #undef PACKAGE_VERSION /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS rJava/jri/src/Rcallbacks.h0000644000176200001440000000164412256051760015113 0ustar liggesusers#ifndef __R_CALLBACKS__H__ #define __R_CALLBACKS__H__ #include #include #include /* functions provided as R callbacks */ #if R_VERSION < R_Version(2,7,0) #define RCCONST #else #define RCCONST const #endif int Re_ReadConsole(RCCONST char *prompt, unsigned char *buf, int len, int addtohistory); void Re_Busy(int which); void Re_WriteConsole(RCCONST char *buf, int len); void Re_WriteConsoleEx(RCCONST char *buf, int len, int oType); void Re_ResetConsole(); void Re_FlushConsole(); void Re_ClearerrConsole(); int Re_ChooseFile(int new, char *buf, int len); void Re_ShowMessage(RCCONST char *buf); void Re_read_history(char *buf); void Re_loadhistory(SEXP call, SEXP op, SEXP args, SEXP env); void Re_savehistory(SEXP call, SEXP op, SEXP args, SEXP env); int Re_ShowFiles(int nfile, RCCONST char **file, RCCONST char **headers, RCCONST char *wtitle, Rboolean del, RCCONST char *pager); #endif rJava/jri/src/Makefile.in0000644000176200001440000000073112256051760014742 0ustar liggesusers# JRI - Java/R Interface experimental! #-------------------------------------------------------------------------- #--- comment out the following for non-debug version CFLAGS+=-g CC=@CC@ CFLAGS+=-Iinclude @DEFFLAGS@ @CFLAGS@ @JAVA_CFLAGS@ LDFLAGS+=@LDFLAGS@ CC=@CC@ RHOME=@R_HOME@ JAVAC=@JAVAC@ JAVAH=@JAVAH@ JAVAINC=@JAVA_INC@ JAR=@JAR@ RINC=@RINC@ -I@R_INCLUDE_DIR@ RLD=@RLD@ JNILD=@JNILD@ JNISO=@JNISO@ JNIPREFIX=@JNIPREFIX@ CPICF=@CPICF@ include Makefile.all rJava/jri/src/Makefile.all0000644000176200001440000000273012256051760015105 0ustar liggesusers# JRI - Java/R Interface experimental! #-------------------------------------------------------------------------- JRI_JSRC=$(wildcard ../*.java) TARGETS=$(JNIPREFIX)jri$(JNISO) JRI.jar # we need to force JDK 1.4 for compatibility JFLAGS+=-target 1.4 -source 1.4 all: $(TARGETS) JRI.jar: $(JRI_JSRC) $(JNIPREFIX)jri$(JNISO) $(JAVAC) $(JFLAGS) -d . $(JRI_JSRC) $(JAR) fc $@ org $(JNIPREFIX)jri$(JNISO) org_rosuda_JRI_Rengine.h: org/rosuda/JRI/Rengine.class $(JAVAH) -d . -classpath . org.rosuda.JRI.Rengine Rcallbacks.o: Rcallbacks.c Rcallbacks.h globals.h $(CC) -c -o $@ $< $(CFLAGS) $(CPICF) $(JAVAINC) $(RINC) Rinit.o: Rinit.c Rinit.h Rcallbacks.h $(CC) -c -o $@ $< $(CFLAGS) $(CPICF) $(RINC) globals.o: globals.c globals.h $(CC) -c -o $@ $< $(CFLAGS) $(CPICF) $(JAVAINC) rjava.o: rjava.c rjava.h $(CC) -c -o $@ $< $(CFLAGS) $(CPICF) $(JAVAINC) Rengine.o: Rengine.c org_rosuda_JRI_Rengine.h globals.h Rcallbacks.h Rinit.h $(CC) -c -o $@ Rengine.c $(CFLAGS) $(CPICF) $(JAVAINC) $(RINC) jri.o: jri.c $(CC) -c -o $@ jri.c $(CFLAGS) $(CPICF) $(JAVAINC) $(RINC) $(JNIPREFIX)jri$(JNISO): Rengine.o jri.o Rcallbacks.o Rinit.o globals.o rjava.o $(JRIDEPS) $(CC) -o $@ $^ $(LDFLAGS) $(JNILD) $(RLD) win32/libjvm.dll.a: make -C win32 libjvm.dll.a org/rosuda/JRI/Rengine.class org/rosuda/JRI/REXP.class org/rosuda/JRI/Mutex.class: $(JRI_JSRC) $(JAVAC) $(JFLAGS) -d . $^ clean: rm -rf $(TARGETS) org *.o *~ org_rosuda_JRI_Rengine.h *$(JNISO) *.class *~ .PHONY: clean all rJava/jri/src/Makefile.win0000644000176200001440000000022512256051760015127 0ustar liggesusers# Windows-specific part of the Makefile include $(R_HOME)/etc$(R_ARCH)/Makeconf include Makefile.wconf include ../Makevars.win include Makefile.all rJava/jri/src/Rdecl.h0000644000176200001440000000056612256051760014105 0ustar liggesusers#ifndef __RDECL_H__ #define __RDECL_H__ /* declarations from R internals or other include files */ /* last update: R 2.4.0 */ void run_Rmainloop(void); /* main/main.c */ int R_ReadConsole(char*, unsigned char*, int, int); /* include/Defn.h */ void Rf_checkArity(SEXP, SEXP); /* include/Defn.h */ int Rf_initialize_R(int ac, char **av); /* include/Rembedded.h */ #endif rJava/jri/src/globals.c0000644000176200001440000000010712256051760014461 0ustar liggesusers#include jobject engineObj; jclass engineClass; JNIEnv *eenv; rJava/jri/src/Rinit.h0000644000176200001440000000015312256051760014131 0ustar liggesusers#ifndef __R_INIT__H__ #define __R_INIT__H__ int initR(int argc, char **argv); void initRinside(); #endif rJava/jri/src/Rcallbacks.c0000644000176200001440000002540312256051760015105 0ustar liggesusers#include #include #include "jri.h" #include "globals.h" #include "Rdecl.h" #include "Rcallbacks.h" #include "org_rosuda_JRI_Rengine.h" #include #ifndef Win32 #include #endif #ifdef Win32 #include #else /* from Defn.h (do we still need it? Re_CleanUp is commented out ...) extern Rboolean R_Interactive; */ #endif #if R_VERSION < R_Version(2,6,0) #ifndef checkArity #define checkArity Rf_checkArity #endif #else #define checkArity(X,Y) #endif #ifndef errorcall #define errorcall Rf_errorcall #endif /* this method is used rather for debugging purposes - it finds the correct JNIEnv for the current thread. we still have some threading issues to solve, becuase eenv!=env should never happen (uncontrolled), because concurrency issues arise */ static JavaVM *jvm=0; JNIEnv *checkEnvironment() { JNIEnv *env; jsize l; jint res; if (!jvm) { /* we're hoping that the JVM pointer won't change :P we fetch it just once */ res= JNI_GetCreatedJavaVMs(&jvm, 1, &l); if (res!=0) { fprintf(stderr, "JNI_GetCreatedJavaVMs failed! (%d)\n",(int)res); return 0; } if (l<1) { fprintf(stderr, "JNI_GetCreatedJavaVMs said there's no JVM running!\n"); return 0; } } res = (*jvm)->AttachCurrentThread(jvm, (void*) &env, 0); if (res!=0) { fprintf(stderr, "AttachCurrentThread failed! (%d)\n",(int)res); return 0; } #ifdef JRI_DEBUG if (eenv!=env) fprintf(stderr, "Warning! eenv=%x, but env=%x - different environments encountered!\n", eenv, env); #endif return env; } int Re_ReadConsole(RCCONST char *prompt, unsigned char *buf, int len, int addtohistory) { jstring r,s; jmethodID mid; JNIEnv *lenv=checkEnvironment(); if (!lenv || !engineObj) return -1; jri_checkExceptions(lenv, 1); mid=(*lenv)->GetMethodID(eenv, engineClass, "jriReadConsole", "(Ljava/lang/String;I)Ljava/lang/String;"); #ifdef JRI_DEBUG printf("jriReadconsole mid=%x\n", mid); #endif jri_checkExceptions(lenv, 0); if (!mid) return -1; s=(*lenv)->NewStringUTF(eenv, prompt); r=(jstring) (*lenv)->CallObjectMethod(lenv, engineObj, mid, s, addtohistory); jri_checkExceptions(lenv, 1); (*lenv)->DeleteLocalRef(lenv, s); jri_checkExceptions(lenv, 0); if (r) { const char *c=(*lenv)->GetStringUTFChars(lenv, r, 0); if (!c) return -1; { int l=strlen(c); strncpy((char*)buf, c, (l>len-1)?len-1:l); buf[(l>len-1)?len-1:l]=0; #ifdef JRI_DEBUG printf("Re_ReadConsole succeeded: \"%s\"\n",buf); #endif } (*lenv)->ReleaseStringUTFChars(lenv, r, c); (*lenv)->DeleteLocalRef(lenv, r); return 1; } return -1; } void Re_Busy(int which) { jmethodID mid; JNIEnv *lenv=checkEnvironment(); jri_checkExceptions(lenv, 1); mid=(*lenv)->GetMethodID(lenv, engineClass, "jriBusy", "(I)V"); jri_checkExceptions(lenv, 0); #ifdef JRI_DEBUG printf("jriBusy mid=%x\n", mid); #endif if (!mid) return; (*lenv)->CallVoidMethod(lenv, engineObj, mid, which); jri_checkExceptions(lenv, 1); } void Re_WriteConsoleEx(RCCONST char *buf, int len, int oType) { JNIEnv *lenv=checkEnvironment(); jri_checkExceptions(lenv, 1); { jstring s=(*lenv)->NewStringUTF(lenv, buf); jmethodID mid=(*lenv)->GetMethodID(lenv, engineClass, "jriWriteConsole", "(Ljava/lang/String;I)V"); jri_checkExceptions(lenv, 0); #ifdef JRI_DEBUG printf("jriWriteConsole mid=%x\n", mid); #endif if (!mid) return; (*lenv)->CallVoidMethod(lenv, engineObj, mid, s, oType); jri_checkExceptions(lenv, 1); (*lenv)->DeleteLocalRef(lenv, s); } } /* old-style WriteConsole (for old R versions only) */ void Re_WriteConsole(RCCONST char *buf, int len) { Re_WriteConsoleEx(buf, len, 0); } /* Indicate that input is coming from the console */ void Re_ResetConsole() { } /* Stdio support to ensure the console file buffer is flushed */ void Re_FlushConsole() { JNIEnv *lenv=checkEnvironment(); jri_checkExceptions(lenv, 1); { jmethodID mid=(*lenv)->GetMethodID(lenv, engineClass, "jriFlushConsole", "()V"); jri_checkExceptions(lenv, 0); #ifdef JRI_DEBUG printf("jriFlushConsole mid=%x\n", mid); #endif if (!mid) return; (*lenv)->CallVoidMethod(lenv, engineObj, mid); jri_checkExceptions(lenv, 1); } } /* Reset stdin if the user types EOF on the console. */ void Re_ClearerrConsole() { } int Re_ChooseFile(int new, char *buf, int len) { JNIEnv *lenv=checkEnvironment(); if (lenv && engineObj) { jmethodID mid; jri_checkExceptions(lenv, 1); mid=(*lenv)->GetMethodID(eenv, engineClass, "jriChooseFile", "(I)Ljava/lang/String;"); #ifdef JRI_DEBUG printf("jriChooseFile mid=%x\n", mid); #endif jri_checkExceptions(lenv, 0); if (mid) { jstring r=(jstring) (*lenv)->CallObjectMethod(lenv, engineObj, mid, new); jri_checkExceptions(lenv, 1); if (r) { int slen=0; const char *c=(*lenv)->GetStringUTFChars(lenv, r, 0); if (c) { slen=strlen(c); strncpy(buf, c, (slen>len-1)?len-1:slen); buf[(slen>len-1)?len-1:slen]=0; #ifdef JRI_DEBUG printf("Re_ChooseFile succeeded: \"%s\"\n",buf); #endif } (*lenv)->ReleaseStringUTFChars(lenv, r, c); (*lenv)->DeleteLocalRef(lenv, r); jri_checkExceptions(lenv, 0); return slen; } else return 0; } } /* "native" fallback if there's no such method */ { int namelen; char *bufp; R_ReadConsole("Enter file name: ", (unsigned char *)buf, len, 0); namelen = strlen(buf); bufp = &buf[namelen - 1]; while (bufp >= buf && isspace((int)*bufp)) *bufp-- = '\0'; return strlen(buf); } } void Re_ShowMessage(RCCONST char *buf) { jstring s; jmethodID mid; JNIEnv *lenv=checkEnvironment(); jri_checkExceptions(lenv, 1); s=(*lenv)->NewStringUTF(lenv, buf); mid=(*lenv)->GetMethodID(lenv, engineClass, "jriShowMessage", "(Ljava/lang/String;)V"); jri_checkExceptions(lenv, 0); #ifdef JGR_DEBUG printf("jriShowMessage mid=%x\n", mid); #endif if (mid) (*lenv)->CallVoidMethod(eenv, engineObj, mid, s); jri_checkExceptions(lenv, 0); if (s) (*lenv)->DeleteLocalRef(eenv, s); } void Re_read_history(char *buf) { } void Re_loadhistory(SEXP call, SEXP op, SEXP args, SEXP env) { jmethodID mid; jstring s; JNIEnv *lenv=checkEnvironment(); jri_checkExceptions(lenv, 1); mid=(*lenv)->GetMethodID(lenv, engineClass, "jriLoadHistory", "(Ljava/lang/String;)V"); jri_checkExceptions(lenv, 0); #ifdef JRI_DEBUG printf("jriLoadHistory mid=%x\n", mid); #endif if (!mid) { #ifdef JRI_DEBUG printf("can't find jriLoadHistory method\n"); #endif return; } { SEXP sfile; const char *p; checkArity(op, args); sfile = CAR(args); if (!isString(sfile) || LENGTH(sfile) < 1) errorcall(call, "invalid file argument"); p = R_ExpandFileName((char*)CHAR(STRING_ELT(sfile, 0))); if(strlen(p) > PATH_MAX - 1) errorcall(call, "file argument is too long"); s=(*lenv)->NewStringUTF(lenv, p); } (*lenv)->CallVoidMethod(lenv, engineObj, mid, s); jri_checkExceptions(lenv, 1); if (s) (*lenv)->DeleteLocalRef(lenv, s); } void Re_savehistory(SEXP call, SEXP op, SEXP args, SEXP env) { jmethodID mid; jstring s; JNIEnv *lenv=checkEnvironment(); jri_checkExceptions(lenv, 1); mid=(*lenv)->GetMethodID(lenv, engineClass, "jriSaveHistory", "(Ljava/lang/String;)V"); jri_checkExceptions(lenv, 0); #ifdef JRI_DEBUG printf("jriSaveHistory mid=%x\n", mid); #endif if (!mid) errorcall(call, "can't find jriSaveHistory method"); { SEXP sfile; const char *p; checkArity(op, args); sfile = CAR(args); if (!isString(sfile) || LENGTH(sfile) < 1) errorcall(call, "invalid file argument"); p = R_ExpandFileName(CHAR(STRING_ELT(sfile, 0))); if(strlen(p) > PATH_MAX - 1) errorcall(call, "file argument is too long"); s=(*lenv)->NewStringUTF(lenv, p); } (*lenv)->CallVoidMethod(lenv, engineObj, mid, s); jri_checkExceptions(lenv, 1); if (s) (*lenv)->DeleteLocalRef(lenv, s); /* strcpy(file, p); write_history(file); history_truncate_file(file, R_HistorySize); */ } /* R_CleanUp is invoked at the end of the session to give the user the option of saving their data. If ask == SA_SAVEASK the user should be asked if possible (and this option should not occur in non-interactive use). If ask = SA_SAVE or SA_NOSAVE the decision is known. If ask = SA_DEFAULT use the SaveAction set at startup. In all these cases run .Last() unless quitting is cancelled. If ask = SA_SUICIDE, no save, no .Last, possibly other things. */ /* void Re_CleanUp(SA_TYPE saveact, int status, int runLast) { unsigned char buf[1024]; char * tmpdir; if(saveact == SA_DEFAULT) saveact = SaveAction; if(saveact == SA_SAVEASK) { if(R_Interactive) { qask: R_ClearerrConsole(); R_FlushConsole(); R_ReadConsole("Save workspace image? [y/n/c]: ", buf, 128, 0); switch (buf[0]) { case 'y': case 'Y': saveact = SA_SAVE; break; case 'n': case 'N': saveact = SA_NOSAVE; break; case 'c': case 'C': jump_to_toplevel(); break; default: goto qask; } } else saveact = SaveAction; } switch (saveact) { case SA_SAVE: if(runLast) R_dot_Last(); if(R_DirtyImage) R_SaveGlobalEnv(); stifle_history(R_HistorySize); write_history(R_HistoryFile); break; case SA_NOSAVE: if(runLast) R_dot_Last(); break; case SA_SUICIDE: default: break; } R_RunExitFinalizers(); CleanEd(); if(saveact != SA_SUICIDE) KillAllDevices(); if((tmpdir = getenv("R_SESSION_TMPDIR"))) { snprintf((char *)buf, 1024, "rm -rf %s", tmpdir); R_system((char *)buf); } if(saveact != SA_SUICIDE && R_CollectWarnings) PrintWarnings(); fpu_setup(FALSE); exit(status); } void Rstd_Suicide(char *s) { REprintf("Fatal error: %s\n", s); R_CleanUp(SA_SUICIDE, 2, 0); } */ int Re_ShowFiles(int nfile, /* number of files */ RCCONST char **file, /* array of filenames */ RCCONST char **headers,/* the `headers' args of file.show. Printed before each file. */ RCCONST char *wtitle, /* title for window = `title' arg of file.show */ Rboolean del, /* should files be deleted after use? */ RCCONST char *pager) /* pager to be used */ { return 1; } rJava/jri/src/rjava.h0000644000176200001440000000103512256051760014147 0ustar liggesusers#ifndef __CALLBACK_H__ #define __CALLBACK_H__ #define RJavaActivity 16 /* all IPC messages are long-alligned */ #define IPCC_LOCK_REQUEST 1 #define IPCC_LOCK_GRANTED 2 /* reponse on IPCC_LOCK_REQUEST */ #define IPCC_CLEAR_LOCK 3 #define IPCC_CALL_REQUEST 4 /* pars: */ #define IPCC_CONTROL_ADDR 5 /* ipc: request, res: */ int RJava_request_lock(); int RJava_clear_lock(); /* void RJava_request_callback(callbackfn *fn, void *data); */ void RJava_setup(int _in, int _out); void RJava_init_ctrl(); #endif rJava/jri/src/jri.c0000644000176200001440000003423712256051760013635 0ustar liggesusers#define USE_RINTERNALS 1 /* for efficiency */ #include "jri.h" #include #include #include #include #include #include /* debugging output (enable with -DRJ_DEBUG) */ #ifdef RJ_DEBUG static void rjprintf(char *fmt, ...) { va_list v; va_start(v,fmt); vprintf(fmt,v); va_end(v); } #define _dbg(X) X #else #define _dbg(X) #endif void jri_error(char *fmt, ...) { va_list v; va_start(v,fmt); vprintf(fmt,v); va_end(v); } /* profiling code (enable with -DRJ_PROFILE) */ #ifdef RJ_PROFILE #include static long time_ms() { #ifdef Win32 return 0; /* in Win32 we have no gettimeofday :( */ #else struct timeval tv; gettimeofday(&tv,0); return (tv.tv_usec/1000)+(tv.tv_sec*1000); #endif } long profilerTime; #define profStart() profilerTime=time_ms() static void profReport(char *fmt, ...) { long npt=time_ms(); va_list v; va_start(v,fmt); vprintf(fmt,v); va_end(v); printf(" %ld ms\n",npt-profilerTime); profilerTime=npt; } #define _prof(X) X #else #define profStart() #define _prof(X) #endif jstring jri_putString(JNIEnv *env, SEXP e, int ix) { return (TYPEOF(e) != STRSXP || LENGTH(e) <= ix || STRING_ELT(e, ix) == R_NaString) ? 0 : (*env)->NewStringUTF(env, CHAR_UTF8(STRING_ELT(e, ix))); } jarray jri_putStringArray(JNIEnv *env, SEXP e) { if (TYPEOF(e) != STRSXP) return 0; { int j = 0; jobjectArray sa = (*env)->NewObjectArray(env, LENGTH(e), (*env)->FindClass(env, "java/lang/String"), 0); if (!sa) { jri_error("Unable to create string array."); return 0; } while (j < LENGTH(e)) { SEXP elt = STRING_ELT(e, j); jobject s = (elt == R_NaString) ? 0 : (*env)->NewStringUTF(env, CHAR_UTF8(STRING_ELT(e,j))); _dbg(if (s) rjprintf (" [%d] \"%s\"\n",j,CHAR_UTF8(STRING_ELT(e,j))); else rjprintf(" [%d] NA\n", j)); (*env)->SetObjectArrayElement(env, sa, j, s); j++; } return sa; } } jarray jri_putIntArray(JNIEnv *env, SEXP e) { if (TYPEOF(e)!=INTSXP) return 0; _dbg(rjprintf(" integer vector of length %d\n",LENGTH(e))); { unsigned len=LENGTH(e); jintArray da=(*env)->NewIntArray(env,len); jint *dae; if (!da) { jri_error("newIntArray.new(%d) failed",len); return 0; } if (len>0) { dae=(*env)->GetIntArrayElements(env, da, 0); if (!dae) { (*env)->DeleteLocalRef(env,da); jri_error("newIntArray.GetIntArrayElements failed"); return 0; } memcpy(dae,INTEGER(e),sizeof(jint)*len); (*env)->ReleaseIntArrayElements(env, da, dae, 0); } return da; } } jarray jri_putByteArray(JNIEnv *env, SEXP e) { if (TYPEOF(e) != RAWSXP) return 0; _dbg(rjprintf(" raw vector of length %d\n", LENGTH(e))); { unsigned len = LENGTH(e); jbyteArray da = (*env)->NewByteArray(env,len); jbyte *dae; if (!da) { jri_error("newByteArray.new(%d) failed",len); return 0; } if (len > 0) { dae = (*env)->GetByteArrayElements(env, da, 0); if (!dae) { (*env)->DeleteLocalRef(env, da); jri_error("newByteArray.GetByteArrayElements failed"); return 0; } memcpy(dae, RAW(e), len); (*env)->ReleaseByteArrayElements(env, da, dae, 0); } return da; } } jarray jri_putBoolArrayI(JNIEnv *env, SEXP e) { if (TYPEOF(e)!=LGLSXP) return 0; _dbg(rjprintf(" integer vector of length %d\n",LENGTH(e))); { unsigned len=LENGTH(e); jintArray da=(*env)->NewIntArray(env,len); jint *dae; if (!da) { jri_error("newIntArray.new(%d) failed",len); return 0; } if (len>0) { dae=(*env)->GetIntArrayElements(env, da, 0); if (!dae) { (*env)->DeleteLocalRef(env,da); jri_error("newIntArray.GetIntArrayElements failed"); return 0; } memcpy(dae,INTEGER(e),sizeof(jint)*len); (*env)->ReleaseIntArrayElements(env, da, dae, 0); } return da; } } jarray jri_putSEXPLArray(JNIEnv *env, SEXP e) { _dbg(rjprintf(" general vector of length %d\n",LENGTH(e))); { unsigned len=LENGTH(e); jlongArray da=(*env)->NewLongArray(env,len); jlong *dae; if (!da) { jri_error("newLongArray.new(%d) failed",len); return 0; } if (len>0) { int i=0; dae=(*env)->GetLongArrayElements(env, da, 0); if (!dae) { (*env)->DeleteLocalRef(env,da); jri_error("newLongArray.GetLongArrayElements failed"); return 0; } while (iReleaseLongArrayElements(env, da, dae, 0); } return da; } } jarray jri_putDoubleArray(JNIEnv *env, SEXP e) { if (TYPEOF(e)!=REALSXP) return 0; _dbg(rjprintf(" real vector of length %d\n",LENGTH(e))); { unsigned len=LENGTH(e); jdoubleArray da=(*env)->NewDoubleArray(env,len); jdouble *dae; if (!da) { jri_error("newDoubleArray.new(%d) failed",len); return 0; } if (len>0) { dae=(*env)->GetDoubleArrayElements(env, da, 0); if (!dae) { (*env)->DeleteLocalRef(env,da); jri_error("newDoubleArray.GetDoubleArrayElements failed"); return 0; } memcpy(dae,REAL(e),sizeof(jdouble)*len); (*env)->ReleaseDoubleArrayElements(env, da, dae, 0); } return da; } } /** jobjRefInt object : string */ SEXP jri_getString(JNIEnv *env, jstring s) { SEXP r; const char *c; if (!s) return ScalarString(R_NaString); profStart(); c = (*env)->GetStringUTFChars(env, s, 0); if (!c) { jri_error("jri_getString: can't retrieve string content"); return R_NilValue; } PROTECT(r = allocVector(STRSXP,1)); SET_STRING_ELT(r, 0, mkCharUTF8(c)); UNPROTECT(1); (*env)->ReleaseStringUTFChars(env, s, c); _prof(profReport("jri_getString:")); return r; } SEXP jri_installString(JNIEnv *env, jstring s) { SEXP r; const char *c; if (!s) return R_NilValue; profStart(); c=(*env)->GetStringUTFChars(env, s, 0); if (!c) { jri_error("jri_getString: can't retrieve string content"); return R_NilValue; } r = install(c); (*env)->ReleaseStringUTFChars(env, s, c); _prof(profReport("jri_getString:")); return r; } jstring jri_putSymbolName(JNIEnv *env, SEXP e) { SEXP pn; if (TYPEOF(e)!=SYMSXP) return 0; pn=PRINTNAME(e); return (TYPEOF(pn)!=CHARSXP)?0:(*env)->NewStringUTF(env, CHAR_UTF8(pn)); } /** calls .toString() of the object and returns the corresponding string java object */ jstring jri_callToString(JNIEnv *env, jobject o) { jclass cls; jmethodID mid; cls=(*env)->GetObjectClass(env,o); if (!cls) { jri_error("RtoString: can't determine class of the object"); return 0; } mid=(*env)->GetMethodID(env, cls, "toString", "()Ljava/lang/String;"); if (!mid) { jri_error("RtoString: toString not found for the object"); return 0; } return (jstring)(*env)->CallObjectMethod(env, o, mid); } /* FIXME: this should never be used as 64-bit platforms can't stuff a pointer in any R type (save for raw which must be interpreted accordingly) */ SEXP jri_getObjectArray(JNIEnv *env, jarray o) { SEXP ar; int l,i; profStart(); _dbg(rjprintf(" jarray %d\n",o)); if (!o) return R_NilValue; l=(int)(*env)->GetArrayLength(env, o); _dbg(rjprintf("convert object array of length %d\n",l)); if (l<1) return R_NilValue; PROTECT(ar=allocVector(INTSXP,l)); i=0; while (i < l) { /* to avoid warnings we cast ptr -> ljong -> int with loss of precision */ INTEGER(ar)[i] = (int)(jlong)(*env)->GetObjectArrayElement(env, o, i); i++; } UNPROTECT(1); _prof(profReport("RgetObjectArrayCont[%d]:",o)); return ar; } /** get contents of the object array in the form of int* */ SEXP jri_getStringArray(JNIEnv *env, jarray o) { SEXP ar; int l, i; const char *c; profStart(); _dbg(rjprintf(" jarray %d\n",o)); if (!o) return R_NilValue; l = (int)(*env)->GetArrayLength(env, o); _dbg(rjprintf("convert string array of length %d\n",l)); PROTECT(ar = allocVector(STRSXP,l)); for (i = 0; i < l; i++) { jobject sobj = (*env)->GetObjectArrayElement(env, o, i); c = 0; if (sobj) { /* we could (should?) check the type here ... if (!(*env)->IsInstanceOf(env, sobj, javaStringClass)) { printf(" not a String\n"); } else */ c = (*env)->GetStringUTFChars(env, sobj, 0); } if (!c) SET_STRING_ELT(ar, i, R_NaString); /* this is probably redundant since the vector is pre-filled with NAs, but just in case ... */ else { SET_STRING_ELT(ar, i, mkCharUTF8(c)); (*env)->ReleaseStringUTFChars(env, sobj, c); } } UNPROTECT(1); _prof(profReport("RgetStringArrayCont[%d]:",o)); return ar; } /** get contents of the integer array object (int) */ SEXP jri_getIntArray(JNIEnv *env, jarray o) { SEXP ar; int l; jint *ap; profStart(); _dbg(rjprintf(" jarray %d\n",o)); if (!o) return R_NilValue; l=(int)(*env)->GetArrayLength(env, o); _dbg(rjprintf("convert int array of length %d\n",l)); if (l<1) return R_NilValue; ap=(jint*)(*env)->GetIntArrayElements(env, o, 0); if (!ap) { jri_error("RgetIntArrayCont: can't fetch array contents"); return 0; } PROTECT(ar=allocVector(INTSXP,l)); memcpy(INTEGER(ar),ap,sizeof(jint)*l); UNPROTECT(1); (*env)->ReleaseIntArrayElements(env, o, ap, 0); _prof(profReport("RgetIntArrayCont[%d]:",o)); return ar; } /** get contents of the integer array object (int) */ SEXP jri_getByteArray(JNIEnv *env, jarray o) { SEXP ar; int l; jbyte *ap; profStart(); _dbg(rjprintf(" jarray %d\n",o)); if (!o) return R_NilValue; l = (int)(*env)->GetArrayLength(env, o); _dbg(rjprintf("convert byte array of length %d\n",l)); if (l < 1) return R_NilValue; ap = (jbyte*)(*env)->GetByteArrayElements(env, o, 0); if (!ap) { jri_error("jri_getByteArray: can't fetch array contents"); return 0; } ar = allocVector(RAWSXP, l); memcpy(RAW(ar), ap, l); (*env)->ReleaseByteArrayElements(env, o, ap, 0); _prof(profReport("RgetByteArrayCont[%d]:",o)); return ar; } /** get contents of the integer array object (int) into a logical R vector */ SEXP jri_getBoolArrayI(JNIEnv *env, jarray o) { SEXP ar; int l; jint *ap; profStart(); _dbg(rjprintf(" jarray %d\n",o)); if (!o) return R_NilValue; l=(int)(*env)->GetArrayLength(env, o); _dbg(rjprintf("convert int array of length %d into R bool\n",l)); if (l<1) return R_NilValue; ap=(jint*)(*env)->GetIntArrayElements(env, o, 0); if (!ap) { jri_error("RgetBoolArrayICont: can't fetch array contents"); return 0; } PROTECT(ar=allocVector(LGLSXP,l)); memcpy(LOGICAL(ar),ap,sizeof(jint)*l); UNPROTECT(1); (*env)->ReleaseIntArrayElements(env, o, ap, 0); _prof(profReport("RgetBoolArrayICont[%d]:",o)); return ar; } /** get contents of the boolean array object into a logical R vector */ SEXP jri_getBoolArray(JNIEnv *env, jarray o) { SEXP ar; int l; jboolean *ap; profStart(); _dbg(rjprintf(" jarray %d\n",o)); if (!o) return R_NilValue; l=(int)(*env)->GetArrayLength(env, o); _dbg(rjprintf("convert boolean array of length %d into R bool\n",l)); if (l<1) return R_NilValue; ap=(jboolean*)(*env)->GetBooleanArrayElements(env, o, 0); if (!ap) { jri_error("RgetBoolArrayCont: can't fetch array contents"); return 0; } PROTECT(ar=allocVector(LGLSXP,l)); { int i=0; int *lgl = LOGICAL(ar); while (iReleaseBooleanArrayElements(env, o, ap, 0); _prof(profReport("RgetBoolArrayCont[%d]:",o)); return ar; } SEXP jri_getSEXPLArray(JNIEnv *env, jarray o) { SEXP ar; int l,i=0; jlong *ap; profStart(); _dbg(rjprintf(" jarray %d\n",o)); if (!o) return R_NilValue; l=(int)(*env)->GetArrayLength(env, o); _dbg(rjprintf("convert SEXPL array of length %d\n",l)); if (l<1) return R_NilValue; ap=(jlong*)(*env)->GetLongArrayElements(env, o, 0); if (!ap) { jri_error("getSEXPLArray: can't fetch array contents"); return 0; } PROTECT(ar=allocVector(VECSXP,l)); while (iReleaseLongArrayElements(env, o, ap, 0); _prof(profReport("jri_getSEXPLArray[%d]:",o)); return ar; } /** get contents of the double array object (int) */ SEXP jri_getDoubleArray(JNIEnv *env, jarray o) { SEXP ar; int l; jdouble *ap; profStart(); _dbg(rjprintf(" jarray %d\n",o)); if (!o) return R_NilValue; l=(int)(*env)->GetArrayLength(env, o); _dbg(rjprintf("convert double array of length %d\n",l)); if (l<1) return R_NilValue; ap=(jdouble*)(*env)->GetDoubleArrayElements(env, o, 0); if (!ap) { jri_error("RgetDoubleArrayCont: can't fetch array contents"); return 0; } PROTECT(ar=allocVector(REALSXP,l)); memcpy(REAL(ar),ap,sizeof(jdouble)*l); UNPROTECT(1); (*env)->ReleaseDoubleArrayElements(env, o, ap, 0); _prof(profReport("RgetDoubleArrayCont[%d]:",o)); return ar; } #if R_VERSION >= R_Version(2,7,0) /* returns string from a CHARSXP making sure that the result is in UTF-8 */ const char *jri_char_utf8(SEXP s) { if (Rf_getCharCE(s) == CE_UTF8) return CHAR(s); return Rf_reEnc(CHAR(s), getCharCE(s), CE_UTF8, 1); /* subst. invalid chars: 1=hex, 2=., 3=?, other=skip */ } #endif void jri_checkExceptions(JNIEnv *env, int describe) { jthrowable t=(*env)->ExceptionOccurred(env); if (t) { #ifndef JRI_DEBUG if (describe) #endif (*env)->ExceptionDescribe(env); (*env)->ExceptionClear(env); } } rJava/jri/src/globals.h0000644000176200001440000000022312256051760014465 0ustar liggesusers#ifndef __GLOBALS__H__ #define __GLOBALS__H__ #include extern jobject engineObj; extern jclass engineClass; extern JNIEnv *eenv; #endif rJava/jri/src/Rinit.c0000644000176200001440000002015212256051760014125 0ustar liggesusers#include #include #include "Rinit.h" #include "Rcallbacks.h" #include "Rdecl.h" /*-------------------------------------------------------------------* * UNIX initialization (includes Darwin/Mac OS X) * *-------------------------------------------------------------------*/ #ifndef Win32 #define R_INTERFACE_PTRS 1 #define CSTACK_DEFNS 1 #include /* and SaveAction is not officially exported */ extern SA_TYPE SaveAction; int initR(int argc, char **argv) { structRstart rp; Rstart Rp = &rp; /* getenv("R_HOME","/Library/Frameworks/R.framework/Resources",1); */ if (!getenv("R_HOME")) { fprintf(stderr, "R_HOME is not set. Please set all required environment variables before running this program.\n"); return -1; } /* this is probably unnecessary, but we could set any other parameters here */ R_DefParams(Rp); Rp->NoRenviron = 0; R_SetParams(Rp); #ifdef RIF_HAS_RSIGHAND R_SignalHandlers=0; #endif { int stat=Rf_initialize_R(argc, argv); if (stat<0) { printf("Failed to initialize embedded R! (stat=%d)\n",stat); return -1; } } #ifdef RIF_HAS_RSIGHAND R_SignalHandlers=0; #endif /* disable stack checking, because threads will thow it off */ R_CStackLimit = (uintptr_t) -1; #ifdef JGR_DEBUG printf("R primary initialization done. Setting up parameters.\n"); #endif R_Outputfile = NULL; R_Consolefile = NULL; R_Interactive = 1; SaveAction = SA_SAVEASK; /* ptr_R_Suicide = Re_Suicide; */ /* ptr_R_CleanUp = Re_CleanUp; */ ptr_R_ShowMessage = Re_ShowMessage; ptr_R_ReadConsole = Re_ReadConsole; ptr_R_WriteConsole = NULL; ptr_R_WriteConsoleEx = Re_WriteConsoleEx; ptr_R_ResetConsole = Re_ResetConsole; ptr_R_FlushConsole = Re_FlushConsole; ptr_R_ClearerrConsole = Re_ClearerrConsole; ptr_R_Busy = Re_Busy; ptr_R_ShowFiles = Re_ShowFiles; ptr_R_ChooseFile = Re_ChooseFile; ptr_R_loadhistory = Re_loadhistory; ptr_R_savehistory = Re_savehistory; #ifdef JGR_DEBUG printf("Setting up R event loop\n"); #endif setup_Rmainloop(); #ifdef JGR_DEBUG printf("R initialized.\n"); #endif return 0; } void initRinside() { /* disable stack checking, because threads will thow it off */ R_CStackLimit = (uintptr_t) -1; } #else /*-------------------------------------------------------------------* * Windows initialization is different and uses Startup.h * *-------------------------------------------------------------------*/ #define NONAMELESSUNION #include #include #include #include /* before we include RStatup.h we need to work around a bug in it for Win64: it defines wrong R_size_t if R_SIZE_T_DEFINED is not set */ #if defined(WIN64) && ! defined(R_SIZE_T_DEFINED) #include #define R_size_t uintptr_t #define R_SIZE_T_DEFINED 1 #endif #include "R_ext/RStartup.h" #ifndef WIN64 /* according to fixed/config.h Windows has uintptr_t, my windows hasn't */ #if !defined(HAVE_UINTPTR_T) && !defined(uintptr_t) && !defined(_STDINT_H) typedef unsigned uintptr_t; #endif #endif extern __declspec(dllimport) uintptr_t R_CStackLimit; /* C stack limit */ extern __declspec(dllimport) uintptr_t R_CStackStart; /* Initial stack address */ /* for signal-handling code */ /* #include "psignal.h" - it's not included, so just get SIGBREAK */ #define SIGBREAK 21 /* to readers pgrp upon background tty read */ /* one way to allow user interrupts: called in ProcessEvents */ #ifdef _MSC_VER __declspec(dllimport) int UserBreak; #else #ifndef WIN64 #define UserBreak (*_imp__UserBreak) #endif extern int UserBreak; #endif /* calls into the R DLL */ extern char *getDLLVersion(); extern void R_DefParams(Rstart); extern void R_SetParams(Rstart); extern void setup_term_ui(void); extern void ProcessEvents(void); extern void end_Rmainloop(void), R_ReplDLLinit(void); extern int R_ReplDLLdo1(); extern void run_Rmainloop(void); void myCallBack() { /* called during i/o, eval, graphics in ProcessEvents */ } #ifndef YES #define YES 1 #endif #ifndef NO #define NO -1 #endif #ifndef CANCEL #define CANCEL 0 #endif int myYesNoCancel(char *s) { char ss[128]; unsigned char a[3]; sprintf(ss, "%s [y/n/c]: ", s); Re_ReadConsole(ss, a, 3, 0); switch (a[0]) { case 'y': case 'Y': return YES; case 'n': case 'N': return NO; default: return CANCEL; } } static void my_onintr(int sig) { UserBreak = 1; } static char Rversion[25], RUser[MAX_PATH], RHome[MAX_PATH]; int initR(int argc, char **argv) { structRstart rp; Rstart Rp = &rp; char *p; char rhb[MAX_PATH+10]; DWORD t, s = MAX_PATH; HKEY k; int cvl; sprintf(Rversion, "%s.%s", R_MAJOR, R_MINOR); cvl=strlen(R_MAJOR)+2; if(strncmp(getDLLVersion(), Rversion, cvl) != 0) { char msg[512]; sprintf(msg, "Error: R.DLL version does not match (DLL: %s, expecting: %s)\n", getDLLVersion(), Rversion); fprintf(stderr, msg); MessageBox(0, msg, "Version mismatch", MB_OK|MB_ICONERROR); return -1; } R_DefParams(Rp); if(getenv("R_HOME")) { strcpy(RHome, getenv("R_HOME")); } else { /* fetch R_HOME from the registry - try preferred architecture first */ #ifdef WIN64 const char *pref_path = "SOFTWARE\\R-core\\R64"; #else const char *pref_path = "SOFTWARE\\R-core\\R32"; #endif if ((RegOpenKeyEx(HKEY_LOCAL_MACHINE, pref_path, 0, KEY_QUERY_VALUE, &k) != ERROR_SUCCESS || RegQueryValueEx(k, "InstallPath", 0, &t, (LPBYTE) RHome, &s) != ERROR_SUCCESS) && (RegOpenKeyEx(HKEY_CURRENT_USER, pref_path, 0, KEY_QUERY_VALUE, &k) != ERROR_SUCCESS || RegQueryValueEx(k, "InstallPath", 0, &t, (LPBYTE) RHome, &s) != ERROR_SUCCESS) && (RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\R-core\\R", 0, KEY_QUERY_VALUE, &k) != ERROR_SUCCESS || RegQueryValueEx(k, "InstallPath", 0, &t, (LPBYTE) RHome, &s) != ERROR_SUCCESS) && (RegOpenKeyEx(HKEY_CURRENT_USER, "SOFTWARE\\R-core\\R", 0, KEY_QUERY_VALUE, &k) != ERROR_SUCCESS || RegQueryValueEx(k, "InstallPath", 0, &t, (LPBYTE) RHome, &s) != ERROR_SUCCESS)) { fprintf(stderr, "R_HOME must be set or R properly installed (\\Software\\R-core\\R\\InstallPath registry entry must exist).\n"); MessageBox(0, "R_HOME must be set or R properly installed (\\Software\\R-core\\R\\InstallPath registry entry must exist).\n", "Can't find R home", MB_OK|MB_ICONERROR); return -2; } sprintf(rhb,"R_HOME=%s",RHome); putenv(rhb); } /* on Win32 this should set R_Home (in R_SetParams) as well */ Rp->rhome = RHome; /* * try R_USER then HOME then working directory */ if (getenv("R_USER")) { strcpy(RUser, getenv("R_USER")); } else if (getenv("HOME")) { strcpy(RUser, getenv("HOME")); } else if (getenv("HOMEDIR")) { strcpy(RUser, getenv("HOMEDIR")); strcat(RUser, getenv("HOMEPATH")); } else GetCurrentDirectory(MAX_PATH, RUser); p = RUser + (strlen(RUser) - 1); if (*p == '/' || *p == '\\') *p = '\0'; Rp->home = RUser; Rp->ReadConsole = Re_ReadConsole; Rp->WriteConsole = NULL; Rp->WriteConsoleEx = Re_WriteConsoleEx; Rp->Busy = Re_Busy; Rp->ShowMessage = Re_ShowMessage; Rp->YesNoCancel = myYesNoCancel; Rp->CallBack = myCallBack; Rp->CharacterMode = LinkDLL; Rp->R_Quiet = FALSE; Rp->R_Interactive = TRUE; Rp->RestoreAction = SA_RESTORE; Rp->SaveAction = SA_SAVEASK; /* process common command line options */ R_common_command_line(&argc, argv, Rp); /* what is left should be assigned to args */ R_set_command_line_arguments(argc, argv); R_SetParams(Rp); /* so R_ShowMessage is set */ R_SizeFromEnv(Rp); R_SetParams(Rp); /* R_SetParams implicitly calls R_SetWin32 which sets the stack start/limit which we need to override */ R_CStackLimit = (uintptr_t) -1; FlushConsoleInputBuffer(GetStdHandle(STD_INPUT_HANDLE)); signal(SIGBREAK, my_onintr); setup_term_ui(); setup_Rmainloop(); return 0; } void initRinside() { /* disable stack checking, because threads will thow it off */ R_CStackLimit = (uintptr_t) -1; } #endif rJava/jri/src/rjava.c0000644000176200001440000000211612256051760014143 0ustar liggesusers#include "rjava.h" #include #ifdef _WIN64 typedef long long ptrlong; #else typedef long ptrlong; #endif int ipcout; int resin; int *rjctrl = 0; typedef void(callbackfn)(void *); int RJava_request_lock() { ptrlong buf[4]; int n; if (rjctrl && *rjctrl) return 2; buf[0] = IPCC_LOCK_REQUEST; write(ipcout, buf, sizeof(ptrlong)); n = read(resin, buf, sizeof(ptrlong)); return (n > 0 && buf[0] == IPCC_LOCK_GRANTED) ? 1 : 0; } int RJava_clear_lock() { ptrlong buf[4]; buf[0] = IPCC_CLEAR_LOCK; write(ipcout, buf, sizeof(ptrlong)); return 1; } void RJava_request_callback(callbackfn *fn, void *data) { ptrlong buf[4]; buf[0] = IPCC_CALL_REQUEST; buf[1] = (ptrlong) fn; buf[2] = (ptrlong) data; write(ipcout, buf, sizeof(ptrlong) * 3); } void RJava_setup(int _in, int _out) { /* ptrlong buf[4]; */ ipcout = _out; resin = _in; } void RJava_init_ctrl() { ptrlong buf[4]; buf[0] = IPCC_CONTROL_ADDR; write(ipcout, buf, sizeof(ptrlong)); read(resin, buf, sizeof(ptrlong) * 2); if (buf[0] == IPCC_CONTROL_ADDR) { rjctrl= (int*) buf[1]; } } rJava/jri/RConsoleOutputStream.java0000644000176200001440000000324712256051760017077 0ustar liggesusers// RConsoleOutputStream, part of Java/R Interface // // (C)Copyright 2007 Simon Urbanek // // For licensing terms see LICENSE in the root if the JRI distribution package org.rosuda.JRI; import java.io.OutputStream; import java.io.IOException; /** RConsoleOutputStream provides an OutputStream which causes its output to be written to the R console. It is a pseudo-stream as there is no real descriptor connected to the R console and thusly it is legal to have multiple console streams open. The synchonization happens at the RNI level.

Note that stdout/stderr are not connected to the R console by default, so one way of using this stream is to re-route Java output to R console:

System.setOut(new PrintStream(new RConsoleOutputStream(engine, 0)));
System.setErr(new PrintStream(new RConsoleOutputStream(engine, 1)));
@since JRI 0.4-0 */ public class RConsoleOutputStream extends OutputStream { Rengine eng; int oType; boolean isOpen; /** opens a new output stream to R console @param eng R engine @param oType output type (0=regular, 1=error/warning) */ public RConsoleOutputStream(Rengine eng, int oType) { this.eng = eng; this.oType = oType; isOpen = true; } public void write(byte[] b, int off, int len) throws IOException { if (!isOpen) throw new IOException("cannot write to a closed stream"); if (eng == null) throw new IOException("missing R engine"); String s = new String(b, off, len); eng.rniPrint(s, oType); } public void write(byte[] b) throws IOException { write(b, 0, b.length); } public void write(int b) throws IOException { write(new byte[] { (byte)(b&255) }); } public void close() throws IOException { isOpen=false; eng=null; } } rJava/jri/Rengine.java0000644000176200001440000011110112256051760014332 0ustar liggesuserspackage org.rosuda.JRI; import java.lang.*; /** Rengine class is the interface between an instance of R and the Java VM. Due to the fact that R has no threading support, you can run only one instance of R withing a multi-threaded application. There are two ways to use R from Java: individual call and full event loop. See the Rengine {@link #Rengine constructor} for details.

Important note: All methods starting with rni (R Native Interface) are low-level native methods that should be avoided if a high-level methods exists. They do NOT attempt any synchronization, so it is the duty of the calling program to ensure that the invocation is safe (see {@link #getRsync()} for details). At some point in the future when the high-level API is complete they should become private. However, currently this high-level layer is not complete, so they are available for now.

All rni methods use long type to reference SEXPs on R side. Those reference should never be modified or used in arithmetics - the only reason for not using an extra interface class to wrap those references is that rni methods are all native methods and therefore it would be too expensive to handle the unwrapping on the C side.

jri methods are called internally by R and invoke the corresponding method from the even loop handler. Those methods should usualy not be called directly.

Since 0.5 a failure to load the JRI naitve library will not be fatal if jri.ignore.ule=yes system preference is set. Rengine will still not work, but that gives a chance to GUI programs to report the error in a more meaningful way (use {@link #jriLoaded} to check the availability of JRI). */ public class Rengine extends Thread { /** this flags is set to true if the native code was successfully loaded. If this flag is false then none of the rni methods are available. Previous @since API 1.9, JRI 0.5 */ public static boolean jriLoaded; boolean loopHasLock = false; static { try { System.loadLibrary("jri"); jriLoaded = true; } catch (UnsatisfiedLinkError e) { jriLoaded = false; // should be implicit, but well ... String iu = System.getProperty("jri.ignore.ule"); if (iu == null || !iu.equals("yes")) { System.err.println("Cannot find JRI native library!\nPlease make sure that the JRI native library is in a directory listed in java.library.path.\n"); e.printStackTrace(); System.exit(1); } } } static Thread mainRThread = null; // constrants to be used with rniSpecialObject /** constant to be used in {@link #rniSpecialObject} to return R_NilValue reference */ public static final int SO_NilValue = 0; /** constant to be used in {@link #rniSpecialObject} to return R_GlobalEnv reference */ public static final int SO_GlobalEnv = 1; /** constant to be used in {@link #rniSpecialObject} to return R_EmptyEnv reference */ public static final int SO_EmptyEnv = 2; /** constant to be used in {@link #rniSpecialObject} to return R_baseEnv reference */ public static final int SO_BaseEnv = 3; /** constant to be used in {@link #rniSpecialObject} to return R_UnboundValue reference */ public static final int SO_UnboundValue = 4; /** constant to be used in {@link #rniSpecialObject} to return R_MissingArg reference */ public static final int SO_MissingArg = 5; /** constant to be used in {@link #rniSpecialObject} to return R_NaString reference */ public static final int SO_NaString = 6; /** constant to be used in {@link #rniSpecialObject} to return R_BlankString reference */ public static final int SO_BlankString = 7; /** API version of the Rengine itself; see also rniGetVersion() for binary version. It's a good idea for the calling program to check the versions of both and abort if they don't match. This should be done using {@link #versionCheck} @return version number as long in the form 0xMMmm */ public static long getVersion() { return 0x010a; } /** check API version of this class and the native binary. This is usually a good idea to ensure consistency. @return true if the API version of the Java code and the native library matches, false otherwise */ public static boolean versionCheck() { return (getVersion()==rniGetVersion()); } /** debug flag. Set to value >0 to enable debugging messages. The verbosity increases with increasing number */ public static int DEBUG = 0; /** this value specifies the time (in ms) to spend sleeping between checks for R shutdown requests if R event loop is not used. The default is 200ms. Higher values lower the CPU usage but may make R less responsive to shutdown attempts (in theory it should not matter because {@link #stop()} uses interrupt to awake from the idle sleep immediately, but some implementation may not honor that). @since JRI 0.3 */ public int idleDelay = 200; /** main engine. Since there can be only one instance of R, this is also the only instance. */ static Rengine mainEngine=null; /** return the current main R engine instance. Since there can be only one true R instance at a time, this is also the only instance. This may not be true for future versions, though. @return current instance of the R engine or null if no R engine was started yet. */ public static Rengine getMainEngine() { return mainEngine; } /* public static Thread getMainRThread() { return mainRThread; } */ /** returns true if the current thread is the main R thread, false otherwise @since JRI 0.4 */ public static boolean inMainRThread() { return (mainRThread != null && mainRThread.equals(Thread.currentThread())); } boolean standAlone = true; /** returns true if this engine was started as a stand-alone Java application or false if this engine was hooked into an existing R instance @since JRI 0.4 */ public boolean isStandAlone() { return standAlone; } boolean died, alive, runLoop, loopRunning; /** arguments used to initialize R, set by the constructor */ String[] args; /** synchronization mutex */ Mutex Rsync; /** callback handler */ RMainLoopCallbacks callback; /** create and start a new instance of R. @param args arguments to be passed to R. Please note that R requires the presence of certain arguments (e.g. --save or --no-save or equivalents), so passing an empty list usually doesn't work. @param runMainLoop if set to true the the event loop will be started as soon as possible, otherwise no event loop is started. Running loop requires initialCallbacks to be set correspondingly as well. @param initialCallbacks an instance implementing the {@link org.rosuda.JRI.RMainLoopCallbacks RMainLoopCallbacks} interface that provides methods to be called by R */ public Rengine(String[] args, boolean runMainLoop, RMainLoopCallbacks initialCallbacks) { super(); Rsync=new Mutex(); died=false; alive=false; runLoop=runMainLoop; loopRunning=false; this.args=args; callback=initialCallbacks; mainEngine=this; mainRThread=this; start(); while (!alive && !died) yield(); } /** create a new engine by hooking into an existing, initialized R instance which is calling this constructor. Currently JRI won't influence this R instance other than disabling stack checks (i.e. no callbacks can be registered etc.). It is *not* the designated constructor and it should be used *only* from withing rJava. @since JRI 0.4 */ public Rengine() { super(); Rsync=new Mutex(); died=false; alive=true; runLoop=false; loopRunning=true; standAlone=false; args=new String[] { "--zero-init"}; callback=null; mainEngine=this; mainRThread=Thread.currentThread(); rniSetupR(args); } /** RNI: setup R with supplied parameters (should not be used directly!). @param args arguments @return result code */ native int rniSetupR(String[] args); /** RNI: setup IPC with RJava. This method is used by rJava to pass the IPC information to the JRI engine for synchronization @since experimental, not in the public API! */ public native int rniSetupRJava(int _in, int _out); /** RNI: lock rJava to allow callbacks - this interrupts R event loop until @link{rniRJavaUnlock} is called. @return 0 = lock failed, 1 = locked via IPC (you must use rniRJavaUnlock subsequently), 2 = rJava is already locked */ public native int rniRJavaLock(); /** RNI: unlock rJava - resumes R event loop. Please note that unlocking without a previously successful lock may cause fatal errors, because it may release a lock issued by another thread which may not have finished yet. */ public native int rniRJavaUnlock(); synchronized int setupR() { return setupR(null); } synchronized int setupR(String[] args) { int r=rniSetupR(args); if (r==0) { alive=true; died=false; } else { alive=false; died=true; } return r; } /** RNI: parses a string into R expressions (do NOT use directly unless you know exactly what you're doing, where possible use {@link #eval} instead). Note that no synchronization is performed! @param s string to parse @param parts number of expressions contained in the string @return reference to the resulting list of expressions */ public synchronized native long rniParse(String s, int parts); /** RNI: evaluate R expression (do NOT use directly unless you know exactly what you're doing, where possible use {@link #eval} instead). Note that no synchronization is performed! @param exp reference to the expression to evaluate @param rho environment to use for evaluation (or 0 for global environemnt) @return result of the evaluation or 0 if an error occurred */ public synchronized native long rniEval(long exp, long rho); /** RNI: protect an R object (c.f. PROTECT macro in C) @since API 1.5, JRI 0.3 @param exp reference to protect */ public synchronized native void rniProtect(long exp); /** RNI: unprotect last count references (c.f. UNPROTECT in C) @since API 1.5, JRI 0.3 @param count number of references to unprotect */ public synchronized native void rniUnprotect(int count); /** RNI: get the contents of the first entry of a character vector @param exp reference to STRSXP @return contents or null if the reference is not STRSXP */ public synchronized native String rniGetString(long exp); /** RNI: get the contents of a character vector @param exp reference to STRSXP @return contents or null if the reference is not STRSXP */ public synchronized native String[] rniGetStringArray(long exp); /** RNI: get the contents of an integer vector @param exp reference to INTSXP @return contents or null if the reference is not INTSXP */ public synchronized native int[] rniGetIntArray(long exp); /** RNI: get the contents of a logical vector in its integer array form @since API 1.6, JRI 0.3-2 @param exp reference to LGLSXP @return contents or null if the reference is not LGLSXP */ public synchronized native int[] rniGetBoolArrayI(long exp); /** RNI: get the contents of a numeric vector @param exp reference to REALSXP @return contents or null if the reference is not REALSXP */ public synchronized native double[] rniGetDoubleArray(long exp); /** RNI: get the contents of a raw vector @since API 1.9, JRI 0.5 @param exp reference to RAWSXP @return contents or null if the reference is not RAWSXP */ public synchronized native byte[] rniGetRawArray(long exp); /** RNI: get the contents of a generic vector (aka list) @param exp reference to VECSXP @return contents as an array of references or null if the reference is not VECSXP */ public synchronized native long[] rniGetVector(long exp); /** RNI: create a character vector of the length 1 @param s initial contents of the first entry @return reference to the resulting STRSXP */ public synchronized native long rniPutString(String s); /** RNI: create a character vector @param a initial contents of the vector @return reference to the resulting STRSXP */ public synchronized native long rniPutStringArray(String[] a); /** RNI: create an integer vector @param a initial contents of the vector @return reference to the resulting INTSXP */ public synchronized native long rniPutIntArray(int [] a); /** RNI: create a boolean vector from an integer vector @since API 1.6, JRI 0.3-2 @param a initial contents of the vector @return reference to the resulting LGLSXP */ public synchronized native long rniPutBoolArrayI(int [] a); /** RNI: create a boolean vector @since API 1.6, JRI 0.3-2 @param a initial contents of the vector @return reference to the resulting LGLSXP */ public synchronized native long rniPutBoolArray(boolean [] a); /** RNI: create a numeric vector @param a initial contents of the vector @return reference to the resulting REALSXP */ public synchronized native long rniPutDoubleArray(double[] a); /** RNI: create a raw vector @since API 1.9, JRI 0.5 @param a initial contents of the vector @return reference to the resulting RAWSXP */ public synchronized native long rniPutRawArray(byte[] a); /** RNI: create a generic vector (aka a list) @param exps initial contents of the vector consisiting of an array of references @return reference to the resulting VECSXP */ public synchronized native long rniPutVector(long[] exps); /** RNI: get an attribute @param exp reference to the object whose attribute is requested @param name name of the attribute @return reference to the attribute or 0 if there is none */ public synchronized native long rniGetAttr(long exp, String name); /** RNI: get attribute names @param exp reference to the object whose attributes are requested @return a list of strings naming all attributes or null if there are none @since API 1.9, JRI 0.5 */ public synchronized native String[] rniGetAttrNames(long exp); /** RNI: set an attribute @param exp reference to the object whose attribute is to be modified @param name attribute name @param attr reference to the object to be used as the contents of the attribute */ public synchronized native void rniSetAttr(long exp, String name, long attr); /** RNI: determines whether an R object instance inherits from a specific class (S3 for now) @since API 1.5, JRI 0.3 @param exp reference to an object @param cName name of the class to check @return true if cName inherits from class cName (see inherits in R) */ public synchronized native boolean rniInherits(long exp, String cName); /** RNI: create a dotted-pair list (LISTSXP or LANGSXP) @param head CAR @param tail CDR (must be a reference to LISTSXP or 0) @param tag TAG @param lang if true then LANGSXP is created, otherwise LISTSXP. @return reference to the newly created LISTSXP/LANGSXP @since API 1.7, JRI 0.3-7 */ public synchronized native long rniCons(long head, long tail, long tag, boolean lang); /** RNI: create a dotted-pair list (LISTSXP) @param head CAR @param tail CDR (must be a reference to LISTSXP or 0) @return reference to the newly created LISTSXP */ public long rniCons(long head, long tail) { return rniCons(head, tail, 0, false); } /** RNI: create a dotted-pair language list (LANGSXP) @param head CAR @param tail CDR (must be a reference to LANGSXP or 0) @return reference to the newly created LANGSXP @since API 1.7, JRI 0.3-7 */ public long rniLCons(long head, long tail) { return rniCons(head, tail, 0, true); } /** RNI: get CAR of a dotted-pair list (LISTSXP) @param exp reference to the list @return reference to CAR of the list (head) */ public synchronized native long rniCAR(long exp); /** RNI: get CDR of a dotted-pair list (LISTSXP) @param exp reference to the list @return reference to CDR of the list (tail) */ public synchronized native long rniCDR(long exp); /** RNI: get TAG of a dotted-pair list (LISTSXP) @param exp reference to the list @return reference to TAG of the list (tail) */ public synchronized native long rniTAG(long exp); /** RNI: create a dotted-pair list (LISTSXP) @since API 1.5, JRI 0.3 @param cont contents as an array of references @return reference to the newly created LISTSXP */ public synchronized native long rniPutList(long[] cont); /** RNI: retrieve CAR part of a dotted-part list recursively as an array of references @param exp reference to a dotted-pair list (LISTSXP) @return contents of the list as an array of references */ public synchronized native long[] rniGetList(long exp); /** RNI: retrieve name of a symbol (c.f. PRINTNAME) @since API 1.5, JRI 0.3 @param sym reference to a symbol @return name of the symbol or null on error or if exp is no symbol */ public synchronized native String rniGetSymbolName(long sym); /** RNI: install a symbol name @since API 1.5, JRI 0.3 @param sym symbol name @return reference to SYMSXP referencing the symbol */ public synchronized native long rniInstallSymbol(String sym); /** RNI: print.

Note: May NOT be called inside any WriteConsole callback as it would cause an infinite loop. @since API 1.8, JRI 0.4 @param s string to print (as-is) @param oType output type (see R for exact references, but 0 should be regular output and 1 error/warning) */ public synchronized native void rniPrint(String s, int oType); /** RNI: print the value of a given R object (via print or show method) to the console @since API 1.9, JRI 0.5 @param exp reference to an R object */ public synchronized native void rniPrintValue(long exp); /** RNI: preserve object (prevent grabage collection in R) until rniRelease is called. @since API 1.9, JRI 0.5 @param exp reference to an R object */ public synchronized native void rniPreserve(long exp); /** RNI: release object previously preserved via rniPreserve.

Note: releasing an obejct that was not preserved is an error and results in an undefined behavior. @since API 1.9, JRI 0.5 @param exp reference to an R object */ public synchronized native void rniRelease(long exp); /** RNI: return the parent environment @since API 1.9, JRI 0.5 @param exp reference to environment @return parent environment */ public synchronized native long rniParentEnv(long exp); /** RNI: find variable in an environment @since API 1.9, JRI 0.5 @param sym symbol name @param rho reference to environment @return reference to the value or UnboundValue if not found */ public synchronized native long rniFindVar(String sym, long rho); /** RNI: return the list of variable names of an environment @since API 1.9, JRI 0.5 @param exp reference to the environment @param all if set to true then all objects will be shown, otherwise hidden objects will be omitted @return reference to a string vector of names in the environment */ public synchronized native long rniListEnv(long exp, boolean all); /** RNI: return a special object reference. Note that all such references are constants valid for the entire session and cannot be protected/preserved (they are persistent already). @since API 1.9, JRI 0.5 @param which constant referring to a particular special object (see SO_xxx constants) @return reference to a special object or 0 if the kind of object it unknown/unsupported */ public synchronized native long rniSpecialObject(int which); //--- was API 1.4 but it only caused portability problems, so we got rid of it //public static native void rniSetEnv(String key, String val); //public static native String rniGetEnv(String key); //--- end API 1.4 /** RNI: convert Java object to EXTPTRSEXP @param o arbitrary Java object @return new EXTPTRSEXP pointing to the Java object @since API 1.5, JRI 0.3 */ public synchronized native long rniJavaToXref(Object o); /** RNI: convert EXTPTRSEXP to Java object - make sure the pointer is really what you expect, otherwise you'll crash the JVM! @param exp reference to EXTPTRSEXP pointing to a Java object @return resulting Java object @since API 1.5, JRI 0.3 */ public synchronized native Object rniXrefToJava(long exp); /** RNI: return the API version of the native library @return API version of the native library */ public static native long rniGetVersion(); /** RNI: interrupt the R process (if possible). Note that R handles interrupt requests in (R-thread-)synchronous, co-operative fashion as it wants to make sure that the interrupted state is recoverable. If interrupting from another thread while using blocking ReadConsole REPL make sure you also interrupt your ReadConsole call after rniStop such that R can act on the signalled interrupt. @param flag determines how to attempt to inform R about the interrput. For normal (safe) operation using flag signalling must be 0. Other options are 1 (SIGINT for compatibility with older JRI API) and 2 (Rf_onintr call - use only on the R thread and only if you know what it means). Values other than 0 are only supported since JRI 0.5-4. @return result code (currently 0) */ public native int rniStop(int flag); /** RNI: assign a value to an environment @param name name @param exp value @param rho environment (use 0 for the global environment) @return true if successful, false on failure (usually this means that the binding is locked) @since API 1.10, JRI 0.5-1 (existed before but returned void) */ public synchronized native boolean rniAssign(String name, long exp, long rho); /** RNI: get the SEXP type @param exp reference to a SEXP @return type of the expression (see xxxSEXP constants) */ public synchronized native int rniExpType(long exp); /** RNI: run the main loop.
Note: this is an internal method and it doesn't return until the loop exits. Don't use directly! */ public native void rniRunMainLoop(); /** RNI: run other event handlers in R */ public synchronized native void rniIdle(); /** Add a handler for R callbacks. The current implementation supports only one handler at a time, so call to this function implicitly removes any previous handlers */ public void addMainLoopCallbacks(RMainLoopCallbacks c) { // we don't really "add", we just replace ... (so far) callback = c; } /** if Rengine was initialized with runMainLoop=false then this method can be used to start the main loop at a later point. It has no effect if the loop is running already. This method returns immediately but the loop will be started once the engine is ready. Please note that there is currently no way of stopping the R thread if the R event loop is running other than using quit command in R which closes the entire application. */ public void startMainLoop() { runLoop=true; } //============ R callback methods ========= /** JRI: R_WriteConsole call-back from R @param text text to disply */ public void jriWriteConsole(String text, int oType) { if (callback!=null) callback.rWriteConsole(this, text, oType); } /** JRI: R_Busy call-back from R @param which state */ public void jriBusy(int which) { if (callback!=null) callback.rBusy(this, which); } /** JRI: R_ReadConsole call-back from R. @param prompt prompt to display before waiting for the input.
Note: implementations should block for input. Returning immediately is usually a bad idea, because the loop will be cycling. @param addToHistory flag specifying whether the entered contents should be added to history @return content entered by the user. Returning null corresponds to an EOF and usually causes R to exit (as in q()). */ public String jriReadConsole(String prompt, int addToHistory) { if (DEBUG>1) System.out.println("Rengine.jreReadConsole BEGIN "+Thread.currentThread()); if (loopHasLock) { Rsync.unlock(); loopHasLock = false; } String s = (callback == null) ? null : callback.rReadConsole(this, prompt, addToHistory); loopHasLock = Rsync.safeLock(); if (!loopHasLock) { String es = "\n>>JRI Warning: jriReadConsole detected a possible deadlock ["+Rsync+"]["+Thread.currentThread()+"]. Proceeding without lock, but this is inherently unsafe.\n"; jriWriteConsole(es, 1); System.err.print(es); } if (DEBUG>1) System.out.println("Rengine.jreReadConsole END "+Thread.currentThread()); return s; } /** JRI: R_ShowMessage call-back from R @param message message */ public void jriShowMessage(String message) { if (callback!=null) callback.rShowMessage(this, message); } /** JRI: R_loadhistory call-back from R @param filename name of the history file */ public void jriLoadHistory(String filename) { if (callback!=null) callback.rLoadHistory(this, filename); } /** JRI: R_savehistory call-back from R @param filename name of the history file */ public void jriSaveHistory(String filename) { if (callback!=null) callback.rSaveHistory(this, filename); } /** JRI: R_ChooseFile call-back from R @param newFile flag specifying whether an existing or new file is requested @return name of the selected file or null if cancelled */ public String jriChooseFile(int newFile) { if (callback!=null) return callback.rChooseFile(this, newFile); return null; } /** JRI: R_FlushConsole call-back from R */ public void jriFlushConsole() { if (callback!=null) callback.rFlushConsole(this); } //============ "official" API ============= /** Parses and evaluates an R expression and returns the result. Has the same effect as calling eval(s, true). @param s expression (as string) to parse and evaluate @return resulting expression or null if something wnet wrong */ public synchronized REXP eval(String s) { return eval(s, true); } /** Parses and evaluates an R expression and returns the result. @since JRI 0.3 @param s expression (as string) to parse and evaluate @param convert if set to true the resulting REXP will contain native representation of the contents, otherwise an empty REXP will be returned. Depending on the back-end an empty REXP may or may not be used to convert the result at a later point. @return resulting expression or null if something wnet wrong */ public synchronized REXP eval(String s, boolean convert) { if (DEBUG>0) System.out.println("Rengine.eval("+s+"): BEGIN "+Thread.currentThread()); boolean obtainedLock=Rsync.safeLock(); try { /* --- so far, we ignore this, because it can happen when a callback needs an eval which is ok ... if (!obtainedLock) { String es="\n>>JRI Warning: eval(\""+s+"\") detected a possible deadlock ["+Rsync+"]["+Thread.currentThread()+"]. Proceeding without lock, but this is inherently unsafe.\n"; jriWriteConsole(es); System.err.print(es); } */ long pr = rniParse(s, 1); if (pr != 0) { long er = rniEval(pr, 0); if (er != 0) { REXP x = new REXP(this, er, convert); if (DEBUG>0) System.out.println("Rengine.eval("+s+"): END (OK)"+Thread.currentThread()); return x; } } } finally { if (obtainedLock) Rsync.unlock(); } if (DEBUG>0) System.out.println("Rengine.eval("+s+"): END (ERR)"+Thread.currentThread()); return null; } /** This method is very much like {@link #eval(String)}, except that it is non-blocking and returns null if the engine is busy. @param s string to evaluate @return result of the evaluation or null if the engine is busy */ public synchronized REXP idleEval(String s) { return idleEval(s, true); } /** This method is very much like {@link #eval(String,boolean)}, except that it is non-blocking and returns null if the engine is busy. @since JRI 0.3 @param s string to evaluate @param convert flag denoting whether an empty or fully-converted REXP should be returned (see {@link #eval(String,boolean)} for details) @return result of the evaluation or null if the engine is busy */ public synchronized REXP idleEval(String s, boolean convert) { int lockStatus=Rsync.tryLock(); if (lockStatus==1) return null; // 1=locked by someone else boolean obtainedLock=(lockStatus==0); try { long pr = rniParse(s, 1); if (pr != 0) { long er = rniEval(pr, 0); if (er != 0) { REXP x = new REXP(this, er, convert); return x; } } } finally { if (obtainedLock) Rsync.unlock(); } return null; } /** returns the synchronization mutex for this engine. If an external code needs to use RNI calls, it should do so only in properly protected environment secured by this mutex. Usually the procedure should be as follows:

	boolean obtainedLock = e.getRsync().safeLock();
	try {
		// use RNI here ...
	} finally {
		if (obtainedLock) e.getRsync().unlock();
	}
	
@return synchronization mutex @since JRI 0.3 */ public Mutex getRsync() { return Rsync; } /** check the state of R @return true if R is alive and false if R died or exitted */ public synchronized boolean waitForR() { return alive; } /** attempt to shut down R. This method is asynchronous. */ public void end() { alive = false; interrupt(); } /** The implementation of the R thread. This method should not be called directly. */ public void run() { if (DEBUG > 0) System.out.println("Starting R..."); loopHasLock = Rsync.safeLock(); // force all code to wait until R is ready try { if (setupR(args) == 0) { if (!runLoop && loopHasLock) { // without event loop we can unlock now since we woin't do anything Rsync.unlock(); loopHasLock = false; } while (alive) { try { if (runLoop) { if (DEBUG > 0) System.out.println("***> launching main loop:"); loopRunning = true; rniRunMainLoop(); // actually R never returns from runMainLoop ... loopRunning = false; if (DEBUG > 0) System.out.println("***> main loop finished:"); runLoop = false; died = true; return; } sleep(idleDelay); if (runLoop) rniIdle(); } catch (InterruptedException ie) { interrupted(); } } died=true; if (DEBUG>0) System.out.println("Terminating R thread."); } else { System.err.println("Unable to start R"); } } finally { if (loopHasLock) Rsync.unlock(); } } /** assign a string value to a symbol in R. The symbol is created if it doesn't exist already. * @param sym symbol name. The symbol name is used as-is, i.e. as if it was quoted in R code (for example assigning to "foo$bar" has the same effect as `foo$bar`<- and NOT foo$bar<-). * @param ct contents * @return true if successful, false otherwise * @since JRI 0.3 (return value changed to boolean in JRI 0.5-1) */ public boolean assign(String sym, String ct) { boolean obtainedLock = Rsync.safeLock(); try { long x1 = rniPutString(ct); return rniAssign(sym,x1,0); } finally { if (obtainedLock) Rsync.unlock(); } } /** assign a content of a REXP to a symbol in R. The symbol is created if it doesn't exist already. @param sym symbol name. The symbol name is used as-is, i.e. as if it was quoted in R code (for example assigning to "foo$bar" has the same effect as `foo$bar`<- and NOT foo$bar<-). @param r contents as REXP. currently only raw references and basic types (int, double, int[], double[], boolean[]) are supported. @return true if successful, false otherwise (usually locked binding or unsupported REXP) @since JRI 0.3 (return value changed to boolean in JRI 0.5-1) */ public boolean assign(String sym, REXP r) { boolean obtainedLock = Rsync.safeLock(); try { if (r.Xt == REXP.XT_NONE) { return rniAssign(sym, r.xp, 0); } if (r.Xt == REXP.XT_INT || r.Xt == REXP.XT_ARRAY_INT) { int[] cont = r.rtype == REXP.XT_INT?new int[]{((Integer)r.cont).intValue()}:(int[])r.cont; long x1 = rniPutIntArray(cont); return rniAssign(sym,x1,0); } if (r.Xt == REXP.XT_DOUBLE || r.Xt == REXP.XT_ARRAY_DOUBLE) { double[] cont = r.rtype == REXP.XT_DOUBLE?new double[]{((Double)r.cont).intValue()}:(double[])r.cont; long x1 = rniPutDoubleArray(cont); return rniAssign(sym,x1,0); } if (r.Xt == REXP.XT_ARRAY_BOOL_INT) { long x1 = rniPutBoolArrayI((int[])r.cont); return rniAssign(sym,x1,0); } if (r.Xt == REXP.XT_STR || r.Xt == REXP.XT_ARRAY_STR) { String[] cont = r.rtype == REXP.XT_STR?new String[]{(String)r.cont}:(String[])r.cont; long x1 = rniPutStringArray(cont); return rniAssign(sym,x1,0); } } finally { if (obtainedLock) Rsync.unlock(); } return false; } /** assign values of an array of doubles to a symbol in R (creating an integer vector).
equals to calling {@link #assign(String, REXP)}. @param sym symbol name @param val double array to assign @return true if successful, false otherwise @since JRI 0.3 (return value changed to boolean in JRI 0.5-1) */ public boolean assign(String sym, double[] val) { return assign(sym,new REXP(val)); } /** assign values of an array of integers to a symbol in R (creating a numeric vector).
equals to calling {@link #assign(String, REXP)}. @param sym symbol name @param val integer array to assign @return true if successful, false otherwise @since JRI 0.3 (return value changed to boolean in JRI 0.5-1) */ public boolean assign(String sym, int[] val) { return assign(sym,new REXP(val)); } /** assign values of an array of booleans to a symbol in R (creating a logical vector).
equals to calling {@link #assign(String, REXP)}. @param sym symbol name @param val boolean array to assign @return true if successful, false otherwise @since JRI 0.3-2 (return value changed to boolean in JRI 0.5-1) */ public boolean assign(String sym, boolean[] val) { return assign(sym,new REXP(val)); } /** assign values of an array of strings to a symbol in R (creating a character vector).
equals to calling {@link #assign(String, REXP)}. @param sym symbol name @param val string array to assign @return true if successful, false otherwise @since JRI 0.3 (return value changed to boolean in JRI 0.5-1) */ public boolean assign(String sym, String[] val) { return assign(sym,new REXP(val)); } /** creates a jobjRef reference in R via rJava.
Important: rJava must be loaded and intialized in R (e.g. via eval("{library(rJava);.jinit()}",false), otherwise this will fail. Requires rJava 0.4-13 or higher! @param o object to push @return Pure REXP reference of the newly created jobjRef object or null upon failure. It will have the type XT_NONE such that it can be used in @link{assign(String, REXP)}. @since JRI 0.3-7 */ public REXP createRJavaRef(Object o) { if (o == null) return null; String klass = o.getClass().getName(); boolean obtainedLock = Rsync.safeLock(); try { long l = rniEval( rniLCons( rniInstallSymbol(".jmkref"), rniLCons( rniJavaToXref(o), rniLCons( rniPutString(klass), 0 ) ) ) , 0); if (l <= 0 && l > -4) return null; /* for safety failure codes are only -3 .. 0 to not clash with 64-bit pointers */ return new REXP(this, l, false); } finally { if (obtainedLock) Rsync.unlock(); } } } rJava/jri/version0000755000176200001440000000023312256051760013516 0ustar liggesusers#!/bin/sh VER=`awk -v ORS= '/JRI v/ { print substr($6,2) }' src/jri.h` if test "$1" == "-f"; then echo "JRI_${VER}.tar.gz" else echo "${VER}" fi rJava/jri/Makefile.in0000644000176200001440000000050112256051760014146 0ustar liggesusers# JRI - Java/R Interface experimental! #-------------------------------------------------------------------------- # See Makefile.all for the actual building process # The values are all auto-configured RHOME=@R_HOME@ JAVAC=@JAVAC@ JAVAH=@JAVAH@ JAVA=@JAVA_PROG@ JRILIB=@JNIPREFIX@jri@JNISO@ include Makefile.all rJava/jri/NEWS0000644000176200001440000001102012256051760012576 0ustar liggesusers NEWS/ChangeLog for JRI -------------------------- 0.5-5 (under development) o some more Win64 fixes 0.5-4 2010-09-17 o added more options to rniStop() on unix and changed the default to use interrupt flags instead of signals since signals cause problems in some JVM implmentations. The previous behavior can be achieved by rniStop(1). 0.5-3 2010-09-02 o fixed changed by the Win64 support which broke some other OSes by using sign extension when converting to long storage. o avoid the use of the sign of pointers for signaling. Note that rniEval() now returns 0 on error and not -1 or -2. The old behavior was undocumented (and dangerous) and thus should not be relied upon. (fixes #172) 0.5-2 2010-04-28 o fixed handling of NAs in strings - they are now correctly converted to s on the Java side. IMPORTANT: previously NAs would come as the string "NA" from R which is incorrect since it is not distinguishable from a literal "NA" string. Code that deals with NAs must be prepared to receive nulls in string arrays (note that nulls where correctly converted to NA string, it's just that incoming string were not converted). (Thanks to Stephan Wahlbrink for pointing out the inconsistency) o multiple fixes to Windows support: common command line arguments are now correctly processed, sub-architectures are supported, Win64 is now also supported 0.5-1 2010-03-16 o API 1.10: rniAssign now returns boolean to denote success/failure o numerous bug fixes and additions 0.5-0 2009-08-22 o API 1.9: added rniPreserve, rniRelease, rniParentEnv, rniFindVar, rniListEnv, rniSpecialObject, rniPrintValue, rniGetRawArray, rniPutRawArray, rniGetAttrNames methods added jriLoaded field (boolean) o new REngine-based API (org.rosuda.REngine.JRI.JRIEngine) has been created - this allows the same code to interface JRI or Rserve without re-compilation Note: the JAR files are currently shipped separately from the JRI installation and can be obtained from http://rforge.net/JRI/files/ o proxy references are now preserved until finalized o if jri.ignore.ule=yes property is set, JRI will not abort on failing to load the JRI library (UnsatisfiedLinkException). This can be used by GUIs to display a more meaningful message instead of abort. The jriLoaded flag is false in that case. 0.4-2 o declare string encoding as UTF-8 and convert incoming strings to UTF-8 if possible (R >= 2.7.0 required). 0.4-1 (part of rJava 0.5-1 and later) o fixed configuration to work with multi-arch builds 0.4-0 2007-08-22 (part of rJava 0.5-0) o adapt to changes in R-devel o add -I. to CFLAGS for compatibility (thanks to BDR) o added RConsoleOuputStream class o API 1.8: added rniPrint, added int oType parameter to the rWriteConsole callback o work around broken MinGW runtimes o allow JRI to hook into a running R process (and thusly provide rJava with callbacks) o added: inMainRThread(), isStandAlone() o include configure in SVN and don't rebuild it on mkdist 0.3-7 2006-01-14 o make sure rniJavaToXref creates a global reference o API 1.7: rniCons can accept two new arguments: tag and lang rniLCons was added o assign now supports raw REXPs (XT_NONE) o createRJavaRef was added to create jobjRef R objects from Java objects 0.3-6 2006-11-29 o adapted to API change in R-devel o fixed double-inclusion of JFLAGS which throws off GIJ 0.3-5 2006-10-06 o remove variadic macros to be compatible with compilers that don't support C99 0.3-4 2006-09-14 o updated Makefiles to force 1.4 target and sources 0.3-3 2006-09-12 o fixed API version in Java sources and added version check to examples 0.3-2 2006-09-11 o New API (1.6): add handling of boolean type 0.3-1 2006-08-31 0.3-0 2006-05-31 o New API (1.5) entries: rniGetTAG, rniInherits, rniGetSymbolName, rniInstallName allows handling of symbols, named lists and inheritance o fixed/improved REXP, RList and RFactor 0.2-5 2006-05-08 o Use configure to detect CStackXXX and R_SignalHandlers set the latter to 0 if present (solves threading issues) 0.2-4 2006-05-03 o added support for pre-configuration passed from rJava 0.2-3 2006-04-20 o fix warnings and issues with R 2.3.0 0.2-2 2006-04-11 o licensed under LGPL 0.2-1 2006-03-07 o fixed Java detection, fixed eval double-unlock, use R shlib flags, added FreeBSD support 0.2-0 2005-12-19 o switched to autoconf process for configuration/installation 0.1-0 o First JRI release rJava/jri/Makefile.all0000644000176200001440000000215612256051760014320 0ustar liggesusers# JRI 0.2 (C) Simon Urbanek # This is the actual Makefile - all autconf'ed values should # be passed as vars, because we also want to use this for # the Windows build that has no autoconf # # Note: the dependencies are often across directories mainly # for historical reasons. The Java sources are actually compiled # by the Makefile in the src directory, although they are here, # because they originally belonged to src. EX_JAVA=$(wildcard examples/*.java) EX_CLASS=$(EX_JAVA:%.java=%.class) JFLAGS+=-target 1.4 -source 1.4 TARGETS=src/JRI.jar $(JRILIB) $(EX_CLASS) all: $(TARGETS) src/JRI.jar: $(MAKE) -C src JRI.jar src/${JRILIB}: $(MAKE) -C src $(JRILIB) $(JRILIB): src/$(JRILIB) rm -f $@ cp $< $@ examples/%.class: examples/%.java src/JRI.jar $(JAVAC) $(JFLAGS) -classpath src/JRI.jar -d examples $< clean: $(MAKE) -C src clean rm -rf $(TARGETS) *~ examples/*.class examples: $(EX_CLASS) JRI_JDOCSRC=$(wildcard *.java) doc: $(JRI_JDOCSRC) rm -rf JavaDoc mkdir JavaDoc $(JAVA)doc -d JavaDoc -author -version -breakiterator -link http://java.sun.com/j2se/1.4.2/docs/api $^ .PHONY: clean all examples doc rJava/jri/LGPL.txt0000644000176200001440000005750612256051760013421 0ustar liggesusers GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS rJava/jri/Makefile.win0000644000176200001440000000055412256051760014345 0ustar liggesusers# Windows-specific part of the Makefile include src/Makefile.wconf include Makevars.win windows.all: all run.bat $(RHOME)/src/gnuwin32/libR.a: make -C $(RHOME)/src/gnuwin32 libR.a run.bat: jri.dll echo "set PATH=%PATH%;$(RHOME)\\bin;$(RHOME)\\lib" > run.bat echo "$(JAVA_PROG) -cp .;examples;JRI.jar;src/JRI.jar rtest \$$*" >> run.bat include Makefile.all rJava/jri/README0000644000176200001440000000420112256051760012762 0ustar liggesusers JRI - Java/R Interface ------------------------ Copyright (C) 2006 Simon Urbanek This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; version 2.1 of the License. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details (LGPL.txt). This package contains code that is necessary to run R as a single thread of a Java application. It provides callback that make it possible to run R in REPL mode thus giving the Java application full access to the console. Currently the API is very, very low-level, comparable to the C level interface to R. Convenience methods for mid to high-level are planned, but not implemented yet. For R-to-Java interface, use rJava package which integrates fine with JRI. rJava hooks into the same JVM, so both are opertaing in the same environment. Java to R: JRI R to Java: rJava How to compile ---------------- As of JRI 0.2 everything is 'autoconf'igured. 1) Make sure JDK 1.4 or higher is installed (on Linux 1.5 or later must be installed) and all java commands are ont the PATH. Alternatively you can set JAVA_HOME instead. 2) ./configure 3) make On Windows run "sh configure.win" instead of configure Note for Windows users: you will need the same tools that are necessary to build R, i.e. the /bin tools and MinGW. See R for details. How to use JRI ---------------- There are two Java examples in the JRI directory: rtest.java - demonstrates the use of the low-level interface to construct and retrieve complex R objects. It also demonstrates how to setup callbacks for handling of the console. rtest2.java - a very simple console using stdin as input and a TextField for output. The examples can be run with ./run rtest ./run rtest2 On Windows use run.bat instead --- 04/2006 Simon Urbanek rJava/jri/REXP.java0000644000176200001440000005074512256051760013541 0ustar liggesuserspackage org.rosuda.JRI; import java.util.Vector; /** * This class encapsulates and caches R objects as returned from R. Currently it * only converts certain SEXPs references from R into Java obejcts, but * eventually bi-directional support should be added. The currently supported * objects are string, integer and numeric vectors. All other types can be * accessed only using {@link #xp} reference and RNI methods. */ public class REXP { /** xpression type: NULL */ public static final int XT_NULL = 0; /** xpression type: integer */ public static final int XT_INT = 1; /** xpression type: double */ public static final int XT_DOUBLE = 2; /** xpression type: String */ public static final int XT_STR = 3; /** xpression type: language construct (currently content is same as list) */ public static final int XT_LANG = 4; /** xpression type: symbol (content is symbol name: String) */ public static final int XT_SYM = 5; /** xpression type: RBool */ public static final int XT_BOOL = 6; /** xpression type: Vector */ public static final int XT_VECTOR = 16; /** xpression type: RList */ public static final int XT_LIST = 17; /** * xpression type: closure (there is no java class for that type (yet?). * currently the body of the closure is stored in the content part of the * REXP. Please note that this may change in the future!) */ public static final int XT_CLOS = 18; /** xpression type: int[] */ public static final int XT_ARRAY_INT = 32; /** xpression type: double[] */ public static final int XT_ARRAY_DOUBLE = 33; /** xpression type: String[] (currently not used, Vector is used instead) */ public static final int XT_ARRAY_STR = 34; /** internal use only! this constant should never appear in a REXP */ public static final int XT_ARRAY_BOOL_UA = 35; /** xpression type: RBool[] */ public static final int XT_ARRAY_BOOL = 36; /** xpression type: int[] to be interpreted as boolean */ public static final int XT_ARRAY_BOOL_INT = 37; /** xpression type: unknown; no assumptions can be made about the content */ public static final int XT_UNKNOWN = 48; /** xpression type: pure reference, no internal type conversion performed */ public static final int XT_NONE = -1; /** * xpression type: RFactor; this XT is internally generated (ergo is does * not come from Rsrv.h) to support RFactor class which is built from * XT_ARRAY_INT */ public static final int XT_FACTOR = 127; /* internal SEXP types in R - taken directly from Rinternals.h */ public static final int NILSXP = 0; /* nil = NULL */ public static final int SYMSXP = 1; /* symbols */ public static final int LISTSXP = 2; /* lists of dotted pairs */ public static final int CLOSXP = 3; /* closures */ public static final int ENVSXP = 4; /* environments */ public static final int PROMSXP = 5; /* * promises: [un]evaluated closure * arguments */ public static final int LANGSXP = 6; /* * language constructs (special * lists) */ public static final int SPECIALSXP = 7; /* special forms */ public static final int BUILTINSXP = 8; /* builtin non-special forms */ public static final int CHARSXP = 9; /* * "scalar" string type (internal * only) */ public static final int LGLSXP = 10; /* logical vectors */ public static final int INTSXP = 13; /* integer vectors */ public static final int REALSXP = 14; /* real variables */ public static final int CPLXSXP = 15; /* complex variables */ public static final int STRSXP = 16; /* string vectors */ public static final int DOTSXP = 17; /* dot-dot-dot object */ public static final int ANYSXP = 18; /* make "any" args work */ public static final int VECSXP = 19; /* generic vectors */ public static final int EXPRSXP = 20; /* expressions vectors */ public static final int BCODESXP = 21; /* byte code */ public static final int EXTPTRSXP = 22; /* external pointer */ public static final int WEAKREFSXP = 23; /* weak reference */ public static final int RAWSXP = 24; /* raw bytes */ public static final int S4SXP = 25; /* S4 object */ public static final int FUNSXP = 99; /* Closure or Builtin */ /** * Engine which this EXP was obtained from. EXPs are valid only for the * engine they were obtained from - it's illegal to mix EXP between engines. * There is a speacial case when the engine may be null - if a REXP creating * was requested but deferred until an engine is available. */ Rengine eng; /** * native reference to the SEXP represented in R. It's usually a pointer, * but can be any handle obtained from the engine. This reference can be * used when calling RNI commands directly. */ public long xp; /** * native type of the represented expression (see ...SXP constants in R). * Please note that this type is cached and may have changed in the * meantime. If the possibility of changing type exists (mainly list/lang) * then use rniExpType to make sure */ public int rtype; /** * create a REXP directly from a R SEXP reference. SEXP types STRSXP, INTSXP * and REALSXP are automatically converted. All others are represented as * SEXP references only. */ public REXP(Rengine re, long exp) { this(re, exp, true); } protected void finalize() throws Throwable { try { if (Xt == XT_NONE && xp != 0 && eng != null) // release underlying R obejct if it was preserved eng.rniRelease(xp); } finally { super.finalize(); } } public REXP(Rengine re, long exp, boolean convert) { eng = re; xp = exp; rtype = re.rniExpType(xp); //System.out.println("["+rtype+"@"+exp+","+convert+"]"); if (!convert) { Xt = XT_NONE; if (re != null && xp != 0) re.rniPreserve(xp); // preserve the object so it doesn't get garbage-collected while we are referencing it return; } if (rtype == STRSXP) { String[] s = re.rniGetStringArray(xp); if (s != null && s.length == 1) { cont = s[0]; Xt = XT_STR; } else { cont = s; Xt = XT_ARRAY_STR; } } else if (rtype == INTSXP) { cont = null; if (re.rniInherits(xp, "factor")) { long levx = re.rniGetAttr(xp, "levels"); if (levx != 0) { String[] levels = null; // we're using low-lever calls here (FIXME?) int rlt = re.rniExpType(levx); if (rlt == STRSXP) { levels = re.rniGetStringArray(levx); int[] ids = re.rniGetIntArray(xp); cont = new RFactor(ids, levels, 1); Xt = XT_FACTOR; } } } // if it's not a factor, then we use int[] instead if (cont == null ) { cont = re.rniGetIntArray(xp); Xt = XT_ARRAY_INT; } } else if (rtype == REALSXP) { cont = re.rniGetDoubleArray(xp); Xt = XT_ARRAY_DOUBLE; } else if (rtype == LGLSXP) { cont = re.rniGetBoolArrayI(xp); Xt = XT_ARRAY_BOOL_INT; } else if (rtype == VECSXP) { long[] l = re.rniGetVector(xp); cont = new RVector(); int i = 0; //System.out.println("VECSXP, length="+l.length); Xt = XT_VECTOR; while (i < l.length) ((RVector)cont).addElement(new REXP(re, l[i++])); long na = re.rniGetAttr(xp, "names"); if (na!=0 && re.rniExpType(na)==STRSXP) ((RVector)cont).setNames(re.rniGetStringArray(na)); } else if (rtype == LISTSXP) { long car = re.rniCAR(xp); long cdr = re.rniCDR(xp); long tag = re.rniTAG(xp); REXP cdrx = (cdr==0 || re.rniExpType(cdr)!=LISTSXP)?null:new REXP(re,re.rniCDR(xp)); cont = new RList(new REXP(re,car), (tag==0)?null:new REXP(re,tag), cdrx); Xt = XT_LIST; } else if (rtype == SYMSXP) { cont = re.rniGetSymbolName(xp); Xt = XT_SYM; } else Xt = XT_NULL; //System.out.println("new REXP: "+toString()); } /** xpression type */ int Xt; /** attribute xpression or null if none */ REXP attr; /** content of the xpression - its object type is dependent of {@link #Xt} */ Object cont; /** cached binary length; valid only if positive */ long cachedBinaryLength = -1; /** construct a new, empty (NULL) expression w/o attribute */ public REXP() { Xt = XT_NULL; attr = null; cont = null; } /** * construct a new xpression of type t and content o, but no attribute * * @param t * xpression type (XT_...) * @param o * content */ public REXP(int t, Object o) { Xt = t; cont = o; attr = null; } /** * construct a new xpression of type t, content o and attribute at * * @param t * xpression type * @param o * content * @param at * attribute */ public REXP(int t, Object o, REXP at) { Xt = t; cont = o; attr = at; } /** * construct a new xpression of type XT_ARRAY_DOUBLE and content val * * @param val * array of doubles to store in the REXP */ public REXP(double[] val) { this(XT_ARRAY_DOUBLE, val); } /** * construct a new xpression of type XT_ARRAY_INT and content val * * @param val * array of integers to store in the REXP */ public REXP(int[] val) { this(XT_ARRAY_INT, val); } /** * construct a new xpression of type XT_ARRAY_INT and content val * * @param val * array of integers to store in the REXP */ public REXP(String[] val) { this(XT_ARRAY_STR, val); } /** construct new expression with the contents of a boolean vector @since JRI 0.3-2 @param val contents */ public REXP(boolean[] val) { Xt = XT_ARRAY_BOOL_INT; if (val==null) { cont = new int[0]; } else { int [] ic = new int[val.length]; int i=0; while (inull
if there is none associated @since JRI 0.3, replaces getAttribute() but should be avoided if possible - use {@link #getAttribute(String)} instead. */ public REXP getAttributes() { return attr; } /** retrieve a specific attribute.
Note: the current representation fetches the attribute ad-hoc, so it breaks the assumption that the expression is no longer accessed after the constructor was called. This should change in the future. @param name name of the attribute @return REXP containing the attribute or null if the attribute doesn't exist. The conversion flag is inherited from this REXP. @since JRI 0.3 */ public REXP getAttribute(String name) { // FIXME: we could do some caching if attr is not null ... long aref = eng.rniGetAttr(xp, name); if (aref==0) return null; return new REXP(eng, aref, (Xt != XT_NONE)); } /** * get raw content. Use as... methods to retrieve contents of known type. * * @return content of the REXP */ public Object getContent() { return cont; } /** * get xpression type (see XT_.. constants) of the content. It defines the * type of the content object. * * @return xpression type */ public int getType() { return Xt; } /** * Obtains R engine object which supplied this REXP. * * @returns {@link Rengine} object */ Rengine getEngine() { return eng; }; /** return the first element of a character vector if this REXP is a character vector of length 1 or more, return null otherwise */ public String asString() { if (cont == null) return null; if (Xt == XT_STR) return (String) cont; if (Xt == XT_ARRAY_STR) { String[] sa = (String[]) cont; return (sa.length > 0) ? sa[0] : null; } return null; } /** return the name of the symbol represented by this REXP if is it a symbol or null otherwise */ public String asSymbolName() { return (Xt == XT_SYM)?((String) cont):null; } /** return the contents of this REXP as an array of strings if this REXP is a character vector, return null otherwise */ public String[] asStringArray() { if (cont == null) return null; if (Xt == XT_STR) { String[] sa = new String[1]; sa[0] = (String) cont; return sa; } if (Xt == XT_ARRAY_STR) return (String[]) cont; return null; } /** * get content of the REXP as int (if it is one) * * @return int content or 0 if the REXP is no integer */ public int asInt() { if (Xt == XT_ARRAY_INT) { int i[] = (int[]) cont; if (i != null && i.length > 0) return i[0]; } return (Xt == XT_INT) ? ((Integer) cont).intValue() : 0; } /** * get content of the REXP as double (if it is one) * * @return double content or 0.0 if the REXP is no double */ public double asDouble() { if (Xt == XT_ARRAY_DOUBLE) { double d[] = (double[]) cont; if (d != null && d.length > 0) return d[0]; } return (Xt == XT_DOUBLE) ? ((Double) cont).doubleValue() : 0.0; } /** * get content of the REXP as {@link Vector} (if it is one) * * @return Vector content or null if the REXP is no Vector */ public RVector asVector() { return (Xt == XT_VECTOR) ? (RVector) cont : null; } /** * get content of the REXP as {@link RFactor} (if it is one) * * @return {@link RFactor} content or null if the REXP is no * factor */ public RFactor asFactor() { return (Xt == XT_FACTOR) ? (RFactor) cont : null; } /** * get content of the REXP as {@link RList} if the contents is a list or a generic vector * * @return {@link RList} content or null if the REXP is neither a list nor a generic vector */ public RList asList() { return (Xt == XT_LIST) ? (RList) cont : ( // for compatibility with Rserve we convert vectors to lists (Xt == XT_VECTOR) ? new RList((RVector)cont) : null ); } /** * get content of the REXP as {@link RBool} (if it is one) * * @return {@link RBool} content or null if the REXP is no * logical value */ public RBool asBool() { if (Xt == XT_ARRAY_BOOL_INT) { int [] ba = (int[]) cont; return (ba!=null && ba.length>0)?new RBool(ba[0]):null; } return (Xt == XT_BOOL) ? (RBool) cont : null; } /** * get content of the REXP as an array of doubles. Array of integers, single * double and single integer are automatically converted into such an array * if necessary. * * @return double[] content or null if the REXP is not a * array of doubles or integers */ public double[] asDoubleArray() { if (Xt == XT_ARRAY_DOUBLE) return (double[]) cont; if (Xt == XT_DOUBLE) { double[] d = new double[1]; d[0] = asDouble(); return d; } if (Xt == XT_INT) { double[] d = new double[1]; d[0] = ((Integer) cont).doubleValue(); return d; } if (Xt == XT_ARRAY_INT) { int[] i = asIntArray(); if (i == null) return null; double[] d = new double[i.length]; int j = 0; while (j < i.length) { d[j] = (double) i[j]; j++; } return d; } return null; } /** * get content of the REXP as an array of integers. Unlike * {@link #asDoubleArray} NO automatic conversion is done if the * content is not an array of the correct type, because there is no * canonical representation of doubles as integers. A single integer is * returned as an array of the length 1. This method can be also used * to access a logical array in its integer form (0=FALSE, 1=TRUE, 2=NA). * * @return int[] content or null if the REXP is not a * array of integers */ public int[] asIntArray() { if (Xt == XT_ARRAY_INT || Xt == XT_ARRAY_BOOL_INT) return (int[]) cont; if (Xt == XT_INT) { int[] i = new int[1]; i[0] = asInt(); return i; } return null; } /** * returns the content of the REXP as a matrix of doubles (2D-array: * m[rows][cols]). This is the same form as used by popular math packages * for Java, such as JAMA. This means that following leads to desired * results:
* Matrix m=new Matrix(c.eval("matrix(c(1,2,3,4,5,6),2,3)").asDoubleMatrix()); * * @return 2D array of doubles in the form double[rows][cols] or * null if the contents is no 2-dimensional matrix of * doubles */ public double[][] asDoubleMatrix() { double[] ct = asDoubleArray(); if (ct==null) return null; REXP dim = getAttribute("dim"); if (dim == null || dim.Xt != XT_ARRAY_INT) return null; // we need dimension attr int[] ds = dim.asIntArray(); if (ds == null || ds.length != 2) return null; // matrix must be 2-dimensional int m = ds[0], n = ds[1]; double[][] r = new double[m][n]; if (ct == null) return null; // R stores matrices as matrix(c(1,2,3,4),2,2) = col1:(1,2), col2:(3,4) // we need to copy everything, since we create 2d array from 1d array int i = 0, k = 0; while (i < n) { int j = 0; while (j < m) { r[j++][i] = ct[k++]; } i++; } return r; } /** this is just an alias for {@link #asDoubleMatrix()}. */ public double[][] asMatrix() { return asDoubleMatrix(); } /** * displayable contents of the expression. The expression is traversed * recursively if aggregation types are used (Vector, List, etc.) * * @return String descriptive representation of the xpression */ public String toString() { StringBuffer sb = new StringBuffer("[" + xtName(Xt) + " "); if (attr != null) sb.append("\nattr=" + attr + "\n "); if (Xt == XT_DOUBLE) sb.append((Double) cont); if (Xt == XT_INT) sb.append((Integer) cont); if (Xt == XT_BOOL) sb.append((RBool) cont); if (Xt == XT_FACTOR) sb.append((RFactor) cont); if (Xt == XT_ARRAY_DOUBLE) { double[] d = (double[]) cont; sb.append("("); for (int i = 0; i < d.length; i++) { sb.append(d[i]); if (i < d.length - 1) sb.append(", "); if (i == 99) { sb.append("... (" + (d.length - 100) + " more values follow)"); break; } } sb.append(")"); } if (Xt == XT_ARRAY_INT) { int[] d = (int[]) cont; sb.append("("); for (int i = 0; i < d.length; i++) { sb.append(d[i]); if (i < d.length - 1) sb.append(", "); if (i == 99) { sb.append("... (" + (d.length - 100) + " more values follow)"); break; } } sb.append(")"); } if (Xt == XT_ARRAY_BOOL) { RBool[] d = (RBool[]) cont; sb.append("("); for (int i = 0; i < d.length; i++) { sb.append(d[i]); if (i < d.length - 1) sb.append(", "); } sb.append(")"); } if (Xt == XT_ARRAY_STR) { String[] d = (String[]) cont; sb.append("("); for (int i = 0; i < d.length; i++) { sb.append((d[i] == null) ? "NA" : ("\"" + d[i] + "\"")); if (i < d.length - 1) sb.append(", "); if (i == 10 && d.length > 14) { sb.append("... (" + (d.length - 10) + " more values follow)"); break; } } sb.append(")"); } if (Xt == XT_VECTOR) { Vector v = (Vector) cont; sb.append("("); for (int i = 0; i < v.size(); i++) { sb.append(((REXP) v.elementAt(i)).toString()); if (i < v.size() - 1) sb.append(", "); } sb.append(")"); } if (Xt == XT_STR) { if (cont == null) sb.append("NA"); else { sb.append("\""); sb.append((String) cont); sb.append("\""); } } if (Xt == XT_SYM) { sb.append((String) cont); } if (Xt == XT_LIST || Xt == XT_LANG) { RList l = (RList) cont; sb.append(l.head); sb.append(":"); sb.append(l.tag); sb.append(",("); sb.append(l.body); sb.append(")"); } if (Xt == XT_NONE) { sb.append("{"+rtype+"}"); } if (Xt == XT_UNKNOWN) sb.append((Integer) cont); sb.append("]"); return sb.toString(); } public static String quoteString(String s) { // this code uses API introdiced in 1.4 so it needs to be re-written for // earlier JDKs if (s.indexOf('\\') >= 0) s.replaceAll("\\", "\\\\"); if (s.indexOf('"') >= 0) s.replaceAll("\"", "\\\""); return "\"" + s + "\""; } /** returns human-readable name of the xpression type as string. Arrays are denoted by a trailing asterisk (*). @param xt xpression type @return name of the xpression type */ public static String xtName(int xt) { if (xt==XT_NULL) return "NULL"; if (xt==XT_INT) return "INT"; if (xt==XT_STR) return "STRING"; if (xt==XT_DOUBLE) return "REAL"; if (xt==XT_BOOL) return "BOOL"; if (xt==XT_ARRAY_INT) return "INT*"; if (xt==XT_ARRAY_STR) return "STRING*"; if (xt==XT_ARRAY_DOUBLE) return "REAL*"; if (xt==XT_ARRAY_BOOL) return "BOOL*"; if (xt==XT_ARRAY_BOOL_INT) return "BOOLi*"; if (xt==XT_SYM) return "SYMBOL"; if (xt==XT_LANG) return "LANG"; if (xt==XT_LIST) return "LIST"; if (xt==XT_CLOS) return "CLOS"; if (xt==XT_VECTOR) return "VECTOR"; if (xt==XT_FACTOR) return "FACTOR"; if (xt==XT_UNKNOWN) return "UNKNOWN"; if (xt==XT_NONE) return "(SEXP)"; return ""; } } rJava/jri/RVector.java0000644000176200001440000000253212256051760014336 0ustar liggesuserspackage org.rosuda.JRI; import java.util.Vector; import java.util.Enumeration; /** class encapsulating named generic vectors in R - do NOT use add/remove directly as names are not synchronized with the contents. The reason for this implementation is for historical compatibility and it may change in the future.

It is now used in REXP where Vector type was used previously for contents storage. @since JRI 0.3 */ public class RVector extends java.util.Vector { Vector names = null; public RVector() { super(); } /** replace the names vector - do NOT use directly! @param nam list of names */ public void setNames(String[] nam) { names=new Vector(nam.length); int i=0; while (inull if not found @param name key (name) @return contents or null if not found */ public REXP at(String name) { if (names==null) return null; int i=0; for (Enumeration e = names.elements() ; e.hasMoreElements() ;) { String n = (String)e.nextElement(); if (n.equals(name)) return (REXP) elementAt(i); i++; } return null; } public REXP at(int i) { return (REXP)elementAt(i); } } rJava/jri/bootstrap/0000755000176200001440000000000012256051760014122 5ustar liggesusersrJava/jri/bootstrap/Makefile0000644000176200001440000000306612256051760015567 0ustar liggesusers# Makefile for JRI bootstrap # Win/OSX should be ok, Linux will need some tweaking all: boot.jar OSKIND=$(shell if echo "${OS}"|grep -i windows >/dev/null 2>&1; then echo win32; else uname -s; fi) ifeq ($(OSKIND),win32) ifeq ($(JAVA_HOME),) JAVA_HOME=N:/java/jdk1.5.0 endif JSO_PREFIX= JSO_SUFFIX=.dll JCPPFLAGS=-DWIN32 -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/win32 JLDFLAGS=-shared -Wl,--add-stdcall-alias -mno-cygwin JLIBS=-L$(JAVA_HOME)/jre/bin/client -L$(JAVA_HOME)/jre/bin -ljvm PATHSEP=\; KNOWNOS=yes OSNAME=Windows JAVA=$(JAVA_HOME)/bin/java JAVAC=$(JAVA_HOME)/bin/javac JAR=$(JAVA_HOME)/bin/jar endif ifeq ($(OSKIND),Darwin) JSO_PREFIX=lib JSO_SUFFIX=.jnilib JLDFLAGS=-dynamiclib JLIBS=-framework JavaVM JCPPFLAGS=-I/System/Library/Frameworks/JavaVM.framework/Headers PATHSEP=: KNOWNOS=yes OSNAME=MacOSX JAVA=java JAVAC=javac JAR=jar endif ifneq ($(KNOWNOS),yes) ifeq ($(JAVA_HOME),) JAVA_HOME=/usr/lib/java endif JSO_PREFIX=lib JSO_SUFFIX=.so JCPPFLAGS=-I$(JAVA_HOME)/include -I$(shell dirname `find $(JAVA_HOME)/include -name jni_md.h|sed -n -e 1p`) JLDFLAGS=-shared JLIBS=-L$(JAVA_HOME)/lib -ljvm PATHSEP=: OSNAME="generic unix" JAVA=java JAVAC=javac JAR=jar endif $(JSO_PREFIX)boot$(JSO_SUFFIX): JRIBootstrap.o $(CC) $(JLDFLAGS) -o $@ $^ #$(JLIBS) JRIBootstrap.o: JRIBootstrap.c JRIBootstrap.h $(CC) -c -o $@ $< $(JCPPFLAGS) run: boot.jar $(JAVA) -jar $< clean: rm -f JRIBootstrap.o $(JSO_PREFIX)boot$(JSO_SUFFIX) *.class *~ boot.jar: $(JSO_PREFIX)boot$(JSO_SUFFIX) $(JAVAC) -source 1.2 -target 1.2 *.java $(JAR) fcm $@ mft *.class $^ .PHONY: clean run all rJava/jri/bootstrap/JRIBootstrap.h0000644000176200001440000000260712256051760016622 0ustar liggesusers/* DO NOT EDIT THIS FILE - it is machine generated */ #include /* Header for class JRIBootstrap */ #ifndef _Included_JRIBootstrap #define _Included_JRIBootstrap #ifdef __cplusplus extern "C" { #endif #undef JRIBootstrap_HKLM #define JRIBootstrap_HKLM 0L #undef JRIBootstrap_HKCU #define JRIBootstrap_HKCU 1L /* * Class: JRIBootstrap * Method: getenv * Signature: (Ljava/lang/String;)Ljava/lang/String; */ JNIEXPORT jstring JNICALL Java_JRIBootstrap_getenv (JNIEnv *, jclass, jstring); /* * Class: JRIBootstrap * Method: setenv * Signature: (Ljava/lang/String;Ljava/lang/String;)V */ JNIEXPORT void JNICALL Java_JRIBootstrap_setenv (JNIEnv *, jclass, jstring, jstring); /* * Class: JRIBootstrap * Method: regvalue * Signature: (ILjava/lang/String;Ljava/lang/String;)Ljava/lang/String; */ JNIEXPORT jstring JNICALL Java_JRIBootstrap_regvalue (JNIEnv *, jclass, jint, jstring, jstring); /* * Class: JRIBootstrap * Method: regsubkeys * Signature: (ILjava/lang/String;)[Ljava/lang/String; */ JNIEXPORT jobjectArray JNICALL Java_JRIBootstrap_regsubkeys (JNIEnv *, jclass, jint, jstring); /* * Class: JRIBootstrap * Method: expand * Signature: (Ljava/lang/String;)Ljava/lang/String; */ JNIEXPORT jstring JNICALL Java_JRIBootstrap_expand (JNIEnv *, jclass, jstring); #ifdef __cplusplus } #endif #endif rJava/jri/bootstrap/JRIBootstrap.c0000644000176200001440000001151512256051760016613 0ustar liggesusers#include "JRIBootstrap.h" #if defined WIN32 || defined Win32 #include #include static const HKEY keyDB[2] = { HKEY_LOCAL_MACHINE, HKEY_CURRENT_USER }; JNIEXPORT jstring JNICALL Java_JRIBootstrap_getenv (JNIEnv *env, jclass cl, jstring sVar) { char cVal[1024]; int res; const char *cVar = (*env)->GetStringUTFChars(env, sVar, 0); if (!cVar) return 0; *cVal=0; cVal[1023]=0; res = GetEnvironmentVariable(cVar, cVal, 1023); (*env)->ReleaseStringUTFChars(env, sVar, cVar); return res?((*env)->NewStringUTF(env, cVal)):0; } JNIEXPORT void JNICALL Java_JRIBootstrap_setenv (JNIEnv *env, jclass cl, jstring sVar, jstring sVal) { const char *cVar = sVar?(*env)->GetStringUTFChars(env, sVar, 0):0; const char *cVal = sVal?(*env)->GetStringUTFChars(env, sVal, 0):0; if (cVar) SetEnvironmentVariable(cVar, cVal?cVal:""); if (cVar) (*env)->ReleaseStringUTFChars(env, sVar, cVar); if (cVal) (*env)->ReleaseStringUTFChars(env, sVal, cVal); return; } JNIEXPORT jstring JNICALL Java_JRIBootstrap_regvalue (JNIEnv *env, jclass cl, jint iRoot, jstring sKey, jstring sVal) { const char *cKey = sKey?(*env)->GetStringUTFChars(env, sKey, 0):0; const char *cVal = sVal?(*env)->GetStringUTFChars(env, sVal, 0):0; jstring res = 0; if (cKey && cVal) { HKEY key; if (RegOpenKeyEx(keyDB[iRoot], cKey, 0, KEY_QUERY_VALUE, &key) == ERROR_SUCCESS) { char buf[1024]; DWORD t, s = 1023; *buf=0; buf[1023]=0; if (RegQueryValueEx(key, cVal, 0, &t, buf, &s) == ERROR_SUCCESS) { res = (*env)->NewStringUTF(env, buf); } RegCloseKey(key); } } if (cVal) (*env)->ReleaseStringUTFChars(env, sVal, cVal); if (cKey) (*env)->ReleaseStringUTFChars(env, sKey, cKey); return res; } JNIEXPORT jobjectArray JNICALL Java_JRIBootstrap_regsubkeys (JNIEnv *env, jclass cl, jint iRoot, jstring sKey) { const char *cKey = sKey?(*env)->GetStringUTFChars(env, sKey, 0):0; jobjectArray res = 0; if (cKey) { HKEY key; if (RegOpenKeyEx(keyDB[iRoot], cKey, 0, KEY_ENUMERATE_SUB_KEYS|KEY_QUERY_VALUE, &key) == ERROR_SUCCESS) { int n = 0, i = 0; char buf[256]; jclass cStr; *buf=0; buf[255]=0; /* pass 1: count the entries */ while (RegEnumKey(key, n, buf, 254) == ERROR_SUCCESS) n++; /* pass 2: get the values */ cStr = (*env)->FindClass(env, "java/lang/String"); res = (*env)->NewObjectArray(env, n, cStr, 0); (*env)->DeleteLocalRef(env, cStr); while (iSetObjectArrayElement(env, res, i++, (*env)->NewStringUTF(env, buf)); RegCloseKey(key); } (*env)->ReleaseStringUTFChars(env, sKey, cKey); } return res; } JNIEXPORT jstring JNICALL Java_JRIBootstrap_expand (JNIEnv *env, jclass cl, jstring sVal) { jstring res = sVal; const char *cVal = sVal?(*env)->GetStringUTFChars(env, sVal, 0):0; char buf[1024]; *buf=0; buf[1023]=0; if (cVal) { if (ExpandEnvironmentStrings(cVal, buf, 1023)) res = (*env)->NewStringUTF(env, buf); } if (cVal) (*env)->ReleaseStringUTFChars(env, sVal, cVal); return res; } JNIEXPORT jboolean JNICALL Java_JRIBootstrap_hasreg (JNIEnv *env, jclass cl) { return JNI_TRUE; } #else #include JNIEXPORT jstring JNICALL Java_JRIBootstrap_getenv (JNIEnv *env, jclass cl, jstring sVar) { char *cVal; const char *cVar = sVar?(*env)->GetStringUTFChars(env, sVar, 0):0; if (!cVar) return 0; cVal=getenv(cVar); (*env)->ReleaseStringUTFChars(env, sVar, cVar); return cVal?((*env)->NewStringUTF(env, cVal)):0; } JNIEXPORT void JNICALL Java_JRIBootstrap_setenv (JNIEnv *env, jclass cl, jstring sVar, jstring sVal) { const char *cVar = sVar?(*env)->GetStringUTFChars(env, sVar, 0):0; const char *cVal = sVal?(*env)->GetStringUTFChars(env, sVal, 0):0; if (cVar) setenv(cVar, cVal?cVal:"", 1); if (cVar) (*env)->ReleaseStringUTFChars(env, sVar, cVar); if (cVal) (*env)->ReleaseStringUTFChars(env, sVal, cVal); return; } /* no registry on unix, so always return null */ JNIEXPORT jstring JNICALL Java_JRIBootstrap_regvalue (JNIEnv *env, jclass cl, jint iRoot, jstring sKey, jstring sVal) { return 0; } JNIEXPORT jobjectArray JNICALL Java_JRIBootstrap_regsubkeys (JNIEnv *env, jclass cl, jint iRoot, jstring sKey) { return 0; } JNIEXPORT jstring JNICALL Java_JRIBootstrap_expand (JNIEnv *env, jclass cl, jstring sVal) { return sVal; } JNIEXPORT jboolean JNICALL Java_JRIBootstrap_hasreg (JNIEnv *env, jclass cl) { return JNI_FALSE; } #endif JNIEXPORT jstring JNICALL Java_JRIBootstrap_arch (JNIEnv *env, jclass cl) { const char *ca = "unknown"; /* this is mainly for Macs so we can determine the correct arch ... */ #ifdef __ppc__ ca = "ppc"; #endif #ifdef __i386__ ca = "i386"; #endif #ifdef __x86_64__ ca = "x86_64"; #endif #ifdef __ppc64__ ca = "ppc64"; #endif return (*env)->NewStringUTF(env, ca); } rJava/jri/bootstrap/mft0000644000176200001440000000002112256051760014624 0ustar liggesusersMain-Class: Boot rJava/jri/bootstrap/JRIBootstrap.java0000644000176200001440000003345012256051760017314 0ustar liggesusersimport java.io.File; import java.io.PrintStream; import java.io.FileOutputStream; import java.io.BufferedReader; import java.io.FileReader; import java.lang.reflect.Constructor; import java.lang.reflect.Method; import java.util.StringTokenizer; public class JRIBootstrap { //--- global constants --- public static final int HKLM = 0; // HKEY_LOCAL_MACHINE public static final int HKCU = 1; // HKEY_CURRENT_USER //--- native methods --- public static native String getenv(String var); public static native void setenv(String var, String val); public static native String regvalue(int root, String key, String value); public static native String[] regsubkeys(int root, String key); public static native String expand(String val); public static native boolean hasreg(); public static native String arch(); //--- helper methods --- static void fail(String msg) { System.err.println("ERROR: "+msg); System.exit(1); } public static String findInPath(String path, String fn, boolean mustBeFile) { StringTokenizer st = new StringTokenizer(path, File.pathSeparator); while (st.hasMoreTokens()) { String dirname=st.nextToken(); try { File f = new File(dirname+File.separator+fn); System.out.println(" * "+f+" ("+f.exists()+", "+f.isFile()+")"); if (f.exists() && (!mustBeFile || f.isFile())) return f.getPath(); } catch (Exception fex) {} } return null; } // set ONLY after findR was run public static boolean isWin32 = false; public static boolean isMac = false; static String findR(boolean findAllSettings) { String ip = null; try { if (hasreg()) { isWin32 = true; int rroot = HKLM; System.out.println("has registry, trying to find R"); ip = regvalue(HKLM, "SOFTWARE\\R-core\\R","InstallPath"); if (ip == null) ip = regvalue(rroot=HKCU, "SOFTWARE\\R-core\\R","InstallPath"); if (ip == null) { System.out.println(" - InstallPath not present (possibly uninstalled R)"); String[] vers = regsubkeys(rroot=HKLM, "SOFTWARE\\R-core\\R"); if (vers == null) vers = regsubkeys(rroot=HKCU, "SOFTWARE\\R-core\\R"); if (vers!=null) { String lvn = ""; // FIXME: we compare versions lexicographically which may fail if we really reach R 2.10 int i = 0; while (i6) ip = s.substring(0, s.length()-6); } } if (findAllSettings) { if (f==null && ip!=null) f=new File(u2w(ip+"/bin/R")); if (f!=null) ip = getRSettings(f.getAbsolutePath()); } } catch (Exception e) { } return ip; } public static String rs_home = ""; public static String rs_arch = ""; public static String rs_docdir = ""; public static String rs_incdir = ""; public static String rs_sharedir = ""; public static String rs_ldp = ""; public static String rs_dyldp = ""; public static String rs_unzip = ""; public static String rs_latex = ""; public static String rs_paper = ""; public static String rs_print = ""; public static String rs_libs = ""; public static void setREnv() { if (rs_home!=null && rs_home.length()>0) setenv("R_HOME", rs_home); if (rs_arch!=null && rs_arch.length()>0) setenv("R_ARCH", rs_arch); if (rs_docdir!=null && rs_docdir.length()>0) setenv("R_DOC_DIR", rs_docdir); if (rs_incdir!=null && rs_incdir.length()>0) setenv("R_INCLUDE_DIR", rs_incdir); if (rs_sharedir!=null && rs_sharedir.length()>0) setenv("R_SHARE_DIR", rs_sharedir); if (rs_ldp!=null && rs_ldp.length()>0) setenv("LD_LIBRARY_PATH", rs_ldp); if (rs_dyldp!=null && rs_dyldp.length()>0) setenv("DYLD_LIBRARY_PATH", rs_dyldp); if (rs_libs!=null && rs_libs.length()>0) setenv("R_LIBS", rs_libs); } public static int execR(String cmd) { try { String binR = u2w(rs_home+"/bin/R"); if (isWin32) { binR+=".exe"; File fin = File.createTempFile("rboot",".R"); File fout = File.createTempFile("rboot",".tmp"); PrintStream p = new PrintStream(new FileOutputStream(fin)); p.println(cmd); p.close(); Process rp = Runtime.getRuntime().exec(new String[] { binR,"CMD","BATCH","--no-restore","--no-save","--slave",fin.getAbsolutePath(), fout.getAbsolutePath()}); int i = rp.waitFor(); if (!fin.delete()) fin.deleteOnExit(); if (!fout.delete()) fout.deleteOnExit(); return i; } else { Process rp = Runtime.getRuntime().exec(new String[] { "/bin/sh","-c","echo \""+cmd+"\" |"+binR+" --no-restore --no-save --slave >/dev/null 2>&1" }); return rp.waitFor(); } } catch (Exception e) { lastError = e.toString(); return -1; } } public static String getRSettings(String binR) { try { File fin = File.createTempFile("rboot",".R"); File fout = File.createTempFile("rboot",".tmp"); PrintStream p = new PrintStream(new FileOutputStream(fin)); p.println("cat(unlist(lapply(c('R_HOME','R_ARCH','R_DOC_DIR','R_INCLUDE_DIR','R_SHARE_DIR','LD_LIBRARY_PATH','DYLD_LIBRARY_PATH','R_UNZIPCMD','R_LATEXCMD','R_PAPERSIZE','R_PRINTCMD'),Sys.getenv)),sep='\n')"); p.println("cat(paste(.libPaths(),collapse=.Platform$path.sep),'\n',sep='')"); p.close(); Process rp = Runtime.getRuntime().exec(new String[] { "/bin/sh","-c",binR+" --no-restore --no-save --slave < \""+fin.getAbsolutePath()+"\" > \""+fout.getAbsolutePath()+"\"" }); int i = rp.waitFor(); System.out.println("getRSettings, i="+i); BufferedReader r = new BufferedReader(new FileReader(fout)); rs_home = r.readLine(); rs_arch = r.readLine(); rs_docdir = r.readLine(); rs_incdir = r.readLine(); rs_sharedir = r.readLine(); rs_ldp = r.readLine(); rs_dyldp = r.readLine(); rs_unzip = r.readLine(); rs_latex = r.readLine(); rs_paper = r.readLine(); rs_print = r.readLine(); rs_libs = r.readLine(); r.close(); if (!fin.delete()) fin.deleteOnExit(); //if (!fout.delete()) fout.deleteOnExit(); System.out.println(" - retrieved R settings, home: "+rs_home+" (arch="+rs_arch+", libs="+rs_libs+")"); } catch (Exception e) { System.err.println("Failed to get R settings: "+e); } return rs_home; } public static String u2w(String fn) { return (java.io.File.separatorChar != '/')?fn.replace('/',java.io.File.separatorChar):fn; } public static Object bootRJavaLoader = null; public static Object getBootRJavaLoader() { System.out.println("JRIBootstrap.bootRJavaLoader="+bootRJavaLoader); return bootRJavaLoader; } static void addClassPath(String s) { if (bootRJavaLoader==null) return; try { Method m = bootRJavaLoader.getClass().getMethod("addClassPath", new Class[] { String.class }); m.invoke(bootRJavaLoader, new Object[] { s }); } catch (Exception e) { System.err.println("FAILED: JRIBootstrap.addClassPath"); } } static String lastError = ""; static String findPackage(String name) { String pd = null; if (rs_libs!=null && rs_libs.length()>0) pd = findInPath(rs_libs, name, false); if (pd == null) { pd = u2w(rs_home+"/library/"+name); if (!(new File(pd)).exists()) pd = null; } return pd; } static Object createRJavaLoader(String rhome, String[] cp, boolean addJRI) { String rJavaRoot = null; if (rs_libs!=null && rs_libs.length()>0) rJavaRoot = findInPath(rs_libs, "rJava", false); if (rJavaRoot == null) rJavaRoot = u2w(rhome+"/library/rJava"); if (!(new File(rJavaRoot)).exists()) { lastError="Unable to find rJava"; return null; } File f = new File(u2w(rJavaRoot+"/java/boot")); if (!f.exists()) { // try harder ... lastError = "rJava too old"; return null; } String rJavaHome = u2w(rJavaRoot); File lf = null; if (rs_arch!=null && rs_arch.length()>0) lf = new File(u2w(rJavaRoot+"/libs"+rs_arch)); if (lf == null || !lf.exists()) lf = new File(u2w(rJavaRoot+"/libs/"+arch())); if (!lf.exists()) lf = new File(u2w(rJavaRoot+"/libs")); String rJavaLibs = lf.toString(); JRIClassLoader mcl = JRIClassLoader.getMainLoader(); mcl.addClassPath(f.toString()); // add rJava boot to primary CP try { // force the use of the MCL even if the system loader could find it Class rjlclass = mcl.findAndLinkClass("RJavaClassLoader"); Constructor c = rjlclass.getConstructor(new Class[] { String.class, String.class }); Object rjcl = c.newInstance(new Object[] { rJavaHome, rJavaLibs }); System.out.println("RJavaClassLoader: "+rjcl); if (addJRI) { if (cp==null || cp.length==0) cp = new String[] { u2w(rJavaRoot+"/jri/JRI.jar") }; else { String[] ncp = new String[cp.length+1]; System.arraycopy(cp, 0, ncp, 1, cp.length); ncp[0] = u2w(rJavaRoot+"/jri/JRI.jar"); cp = ncp; } } if (cp==null || cp.length==0) cp = new String[] { u2w(rJavaRoot+"/java/boot") }; else { String[] ncp = new String[cp.length+1]; System.arraycopy(cp, 0, ncp, 1, cp.length); ncp[0] = u2w(rJavaRoot+"/java/boot"); cp = ncp; } if (cp != null) { System.out.println(" - adding class paths"); Method m = rjlclass.getMethod("addClassPath", new Class[] { String[].class }); m.invoke(rjcl, new Object[] { cp }); } return rjcl; } catch (Exception rtx) { System.err.println("ERROR: Unable to create new RJavaClassLoader in JRIBootstrap! ("+rtx+")"); rtx.printStackTrace(); System.exit(2); } return null; } //--- main bootstrap method --- public static void bootstrap(String[] args) { System.out.println("JRIBootstrap("+args+")"); try { System.loadLibrary("boot"); } catch (Exception e) { fail("Unable to load boot library!"); } // just testing from now on String rhome = findR(true); if (rhome == null) fail("Unable to find R!"); if (isWin32) { String path = getenv("PATH"); if (path==null || path.length()<1) path=rhome+"\\bin"; else path=rhome+"\\bin;"+path; setenv("PATH",path); } setREnv(); System.out.println("PATH="+getenv("PATH")+"\nR_LIBS="+getenv("R_LIBS")); if (!isMac && !isWin32) { String stage = System.getProperty("stage"); if (stage==null || stage.length()<1) { File jl = new File(u2w(System.getProperty("java.home")+"/bin/java")); if (jl.exists()) { try { System.out.println(jl.toString()+" -cp "+System.getProperty("java.class.path")+" -Xmx512m -Dstage=2 Boot"); Process p = Runtime.getRuntime().exec(new String[] { jl.toString(), "-cp", System.getProperty("java.class.path"), "-Xmx512m", "-Dstage=2", "Boot" }); System.out.println("Started stage 2 ("+p+"), waiting for it to finish..."); System.exit(p.waitFor()); } catch (Exception re) { } } } } String needPkg = null; String rj = findPackage("rJava"); if (rj == null) { System.err.println("**ERROR: rJava is not installed"); if (needPkg==null) needPkg="'rJava'"; else needPkg+=",'rJava'"; } String ipl = findPackage("iplots"); if (ipl == null) { System.err.println("**ERROR: iplots is not installed"); if (needPkg==null) needPkg="'iplots'"; else needPkg+=",'iplots'"; } String jgr = findPackage("JGR"); if (jgr == null) { System.err.println("**ERROR: JGR is not installed"); if (needPkg==null) needPkg="'JGR'"; else needPkg+=",'JGR'"; } if (needPkg != null) { if (!isWin32 && !isMac) { System.err.println("*** Please run the following in R as root to install missing packages:\n install.packages(c("+needPkg+"),,'http://www.rforge.net/')"); System.exit(4); } if (execR("install.packages(c("+needPkg+"),,c('http://www.rforge.net/','http://cran.r-project.org'))")!=0) { System.err.println("*** ERROR: failed to install necessary packages"); System.exit(4); } rj = findPackage("rJava"); ipl = findPackage("iplots"); jgr = findPackage("JGR"); if (rj==null || ipl==null || jgr==null) { System.err.println("*** ERROR: failed to find installed packages"); System.exit(5); } } Object o = bootRJavaLoader = createRJavaLoader(rhome, new String[] { "main" }, true); addClassPath(u2w(jgr+"/cont/JGR.jar")); addClassPath(u2w(ipl+"/cont/iplots.jar")); String mainClass = "org.rosuda.JGR.JGR"; try { Method m = o.getClass().getMethod("bootClass", new Class[] { String.class, String.class, String[].class }); m.invoke(o, new Object[] { mainClass, "main", args }); } catch(Exception ie) { System.out.println("cannot boot the final class: "+ie); ie.printStackTrace(); } } public static void main(String[] args) { System.err.println("*** WARNING: JRIBootstrap.main should NOT be called directly, it is intended for debugging use ONLY. Use Boot wrapper instead."); // just for testing bootstrap(args); } } rJava/jri/bootstrap/DelegatedClassLoader.java0000644000176200001440000000037012256051760020760 0ustar liggesusersimport java.net.URL; public interface DelegatedClassLoader { public String delegatedFindLibrary(String name); public Class delegatedFindClass(String name) throws ClassNotFoundException; public URL delegatedFindResource(String name); } rJava/jri/bootstrap/DelegatedURLClassLoader.java0000644000176200001440000000122712256051760021345 0ustar liggesusers/* An extension of URLClassLoader that implements DelegatedClassLoader */ import java.net.URL; import java.net.URLClassLoader; public class DelegatedURLClassLoader extends URLClassLoader implements DelegatedClassLoader { public DelegatedURLClassLoader() { super(new URL[]{}); } public DelegatedURLClassLoader(URL[] urls) { super(urls); } public String delegatedFindLibrary(String name) { return super.findLibrary(name); } public Class delegatedFindClass(String name) throws ClassNotFoundException { return super.findClass(name); } public URL delegatedFindResource(String name) { return super.findResource(name); } } rJava/jri/bootstrap/Boot.java0000644000176200001440000001010212256051760015662 0ustar liggesusersimport java.io.File; import java.io.InputStream; import java.io.FileOutputStream; import java.util.StringTokenizer; import java.util.zip.ZipFile; import java.util.zip.ZipEntry; import java.lang.reflect.Method; public class Boot { public static String bootFile = null; public static String findInPath(String path, String fn) { StringTokenizer st = new StringTokenizer(path, File.pathSeparator); while (st.hasMoreTokens()) { String dirname=st.nextToken(); try { File f = new File(dirname+File.separator+fn); if (f.isFile()) return f.getPath(); } catch (Exception fex) {} } return null; } public static String findNativeLibrary(String basename, boolean internalFirst) { String libName = "lib"+basename; String ext = ".so"; String os = System.getProperty("os.name"); if (os.startsWith("Win")) { os = "Win"; ext= ".dll"; libName=basename; } if (os.startsWith("Mac")) { os = "Mac"; ext= ".jnilib"; } String fullName = libName+ext; // first, try the system path unless instructed otherwise if (!internalFirst) { try { String r = findInPath("."+File.pathSeparator+System.getProperty("java.library.path"), fullName); if (r != null) return r; } catch (Exception ex1) {} } // second, try to locate in on the class path (in the JAR file or in one of the directories) String cp = System.getProperty("java.class.path"); StringTokenizer st = new StringTokenizer(cp, File.pathSeparator); while (st.hasMoreTokens()) { String dirname=st.nextToken(); try { File f = new File(dirname); if (f.isFile()) { // look in a JAR file and extract it if necessary ZipFile jf = new ZipFile(f); ZipEntry ze = jf.getEntry(fullName); if (ze != null) { // found it inside a JAR file try { bootFile = f.toString(); File tf = File.createTempFile(basename,ext); System.out.println("Boot.findNativeLibrary: found in a JAR ("+jf+"), extracting into "+tf); InputStream zis = jf.getInputStream(ze); FileOutputStream fos = new FileOutputStream(tf); byte b[] = new byte[65536]; while (zis.available()>0) { int n = zis.read(b); if (n>0) fos.write(b, 0, n); } zis.close(); fos.close(); tf.deleteOnExit(); return tf.getPath(); } catch (Exception foo) { } } } else if (f.isDirectory()) { File ff = new File(dirname+File.separator+fullName); if (ff.isFile()) return ff.getPath(); } } catch(Exception ex2) {} } // third, try the system path if we didn't look there before if (internalFirst) { try { String r = findInPath("."+File.pathSeparator+System.getProperty("java.library.path"), fullName); if (r != null) return r; } catch (Exception ex3) {} } return null; } public static void main(String[] args) { // 1) instantiate master class loader JRIClassLoader mcl = JRIClassLoader.getMainLoader(); // 2) locate boot JNI library String nl = findNativeLibrary("boot", false); if (nl == null) { System.err.println("ERROR: Unable to locate native bootstrap library."); System.exit(1); } // register boot library with MCL mcl.registerLibrary("boot", new File(nl)); // add path necessary for loading JRIBootstrap to MCL String cp = System.getProperty("java.class.path"); StringTokenizer st = new StringTokenizer(cp, File.pathSeparator); while (st.hasMoreTokens()) { String p = st.nextToken(); mcl.addClassPath(p); // we assume that the first file on the CP is us (FIXME: verify this!) if (bootFile==null && (new File(p)).isFile()) bootFile=p; } // call static bootstrap method try { // force the use of the MCL even if the system loader could find it Class stage2class = mcl.findAndLinkClass("JRIBootstrap"); Method m = stage2class.getMethod("bootstrap", new Class[] { String[].class }); m.invoke(null, new Object[] { args }); } catch (Exception rtx) { System.err.println("ERROR: Unable to invoke bootstrap method in JRIBootstrap! ("+rtx+")"); rtx.printStackTrace(); System.exit(2); } } } rJava/jri/bootstrap/JRIClassLoader.java0000644000176200001440000000614412256051760017533 0ustar liggesusersimport java.net.URLClassLoader; import java.net.URL; import java.util.HashMap; import java.util.Vector; import java.util.Enumeration; import java.io.File; public class JRIClassLoader extends URLClassLoader { HashMap libMap; Vector children; static JRIClassLoader mainLoader; public static JRIClassLoader getMainLoader() { if (mainLoader == null) mainLoader = new JRIClassLoader(); return mainLoader; } public JRIClassLoader() { super(new URL[]{}); children = new Vector(); libMap = new HashMap(); System.out.println("JRIClassLoader: new loader "+this); } public void registerLoader(DelegatedClassLoader cl) { if (!children.contains(cl)) children.add(cl); } public void unregisterLoader(DelegatedClassLoader cl) { children.removeElement(cl); } public void registerLibrary(String name, File f) { libMap.put(name, f); } /** add path to the class path list @param path string denoting the path to the file or directory */ public void addClassPath(String path) { try { File f = new File(path); if (f.exists()) addURL(f.toURL()); } catch (Exception x) {} } /** add path to the class path list @param f file/directory to add to the list */ public void addClassPath(File f) { try { if (f.exists()) addURL(f.toURL()); } catch (Exception x) {} } protected String findLibrary(String name) { String s = null; System.out.println("boot findLibrary(\""+name+"\")"); try { for (Enumeration e = children.elements() ; e.hasMoreElements() ;) { DelegatedClassLoader cl = (DelegatedClassLoader)e.nextElement(); if (cl != null) { s = cl.delegatedFindLibrary(name); if (s != null) { System.out.println(" - found delegated answer "+s+" from "+cl); return s; } } } } catch (Exception ex) {} File u = (File) libMap.get(name); if (u!=null && u.exists()) s=u.getAbsolutePath(); System.out.println(" - mapping to "+((s==null)?"":s)); return s; } public Class findAndLinkClass(String name) throws ClassNotFoundException { Class c = findClass(name); resolveClass(c); return c; } protected Class findClass(String name) throws ClassNotFoundException { Class cl = null; System.out.println("boot findClass(\""+name+"\")"); for (Enumeration e = children.elements() ; e.hasMoreElements() ;) { DelegatedClassLoader ldr = (DelegatedClassLoader)e.nextElement(); if (ldr != null) { try { cl = ldr.delegatedFindClass(name); if (cl != null) { System.out.println(" - found delegated answer "+cl+" from "+ldr); return cl; } } catch (Exception ex) {} } } return super.findClass(name); } public URL findResource(String name) { URL u = null; System.out.println("boot findResource(\""+name+"\")"); for (Enumeration e = children.elements() ; e.hasMoreElements() ;) { DelegatedClassLoader ldr = (DelegatedClassLoader)e.nextElement(); if (ldr != null) { try { u = ldr.delegatedFindResource(name); if (u != null) { System.out.println(" - found delegated answer "+u+" from "+ldr); return u; } } catch (Exception ex) {} } } return super.findResource(name); } } rJava/jri/configure0000755000176200001440000044236312256051760014030 0ustar liggesusers#! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.61 for JRI 0.3. # # Report bugs to . # # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, # 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. ## --------------------- ## ## M4sh Initialization. ## ## --------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac fi # PATH needs CR # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then echo "#! /bin/sh" >conf$$.sh echo "exit 0" >>conf$$.sh chmod +x conf$$.sh if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then PATH_SEPARATOR=';' else PATH_SEPARATOR=: fi rm -f conf$$.sh fi # Support unset when possible. if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then as_unset=unset else as_unset=false fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) as_nl=' ' IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. case $0 in *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 { (exit 1); exit 1; } fi # Work around bugs in pre-3.0 UWIN ksh. for as_var in ENV MAIL MAILPATH do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. for as_var in \ LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ LC_TELEPHONE LC_TIME do if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then eval $as_var=C; export $as_var else ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var fi done # Required to use basename. if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi # Name of the executable. as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # CDPATH. $as_unset CDPATH if test "x$CONFIG_SHELL" = x; then if (eval ":") 2>/dev/null; then as_have_required=yes else as_have_required=no fi if test $as_have_required = yes && (eval ": (as_func_return () { (exit \$1) } as_func_success () { as_func_return 0 } as_func_failure () { as_func_return 1 } as_func_ret_success () { return 0 } as_func_ret_failure () { return 1 } exitcode=0 if as_func_success; then : else exitcode=1 echo as_func_success failed. fi if as_func_failure; then exitcode=1 echo as_func_failure succeeded. fi if as_func_ret_success; then : else exitcode=1 echo as_func_ret_success failed. fi if as_func_ret_failure; then exitcode=1 echo as_func_ret_failure succeeded. fi if ( set x; as_func_ret_success y && test x = \"\$1\" ); then : else exitcode=1 echo positional parameters were not saved. fi test \$exitcode = 0) || { (exit 1); exit 1; } ( as_lineno_1=\$LINENO as_lineno_2=\$LINENO test \"x\$as_lineno_1\" != \"x\$as_lineno_2\" && test \"x\`expr \$as_lineno_1 + 1\`\" = \"x\$as_lineno_2\") || { (exit 1); exit 1; } ") 2> /dev/null; then : else as_candidate_shells= as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. case $as_dir in /*) for as_base in sh bash ksh sh5; do as_candidate_shells="$as_candidate_shells $as_dir/$as_base" done;; esac done IFS=$as_save_IFS for as_shell in $as_candidate_shells $SHELL; do # Try only shells that exist, to save several forks. if { test -f "$as_shell" || test -f "$as_shell.exe"; } && { ("$as_shell") 2> /dev/null <<\_ASEOF if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac fi : _ASEOF }; then CONFIG_SHELL=$as_shell as_have_required=yes if { "$as_shell" 2> /dev/null <<\_ASEOF if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac fi : (as_func_return () { (exit $1) } as_func_success () { as_func_return 0 } as_func_failure () { as_func_return 1 } as_func_ret_success () { return 0 } as_func_ret_failure () { return 1 } exitcode=0 if as_func_success; then : else exitcode=1 echo as_func_success failed. fi if as_func_failure; then exitcode=1 echo as_func_failure succeeded. fi if as_func_ret_success; then : else exitcode=1 echo as_func_ret_success failed. fi if as_func_ret_failure; then exitcode=1 echo as_func_ret_failure succeeded. fi if ( set x; as_func_ret_success y && test x = "$1" ); then : else exitcode=1 echo positional parameters were not saved. fi test $exitcode = 0) || { (exit 1); exit 1; } ( as_lineno_1=$LINENO as_lineno_2=$LINENO test "x$as_lineno_1" != "x$as_lineno_2" && test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2") || { (exit 1); exit 1; } _ASEOF }; then break fi fi done if test "x$CONFIG_SHELL" != x; then for as_var in BASH_ENV ENV do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var done export CONFIG_SHELL exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} fi if test $as_have_required = no; then echo This script requires a shell more modern than all the echo shells that I found on your system. Please install a echo modern shell, or manually run the script under such a echo shell if you do have one. { (exit 1); exit 1; } fi fi fi (eval "as_func_return () { (exit \$1) } as_func_success () { as_func_return 0 } as_func_failure () { as_func_return 1 } as_func_ret_success () { return 0 } as_func_ret_failure () { return 1 } exitcode=0 if as_func_success; then : else exitcode=1 echo as_func_success failed. fi if as_func_failure; then exitcode=1 echo as_func_failure succeeded. fi if as_func_ret_success; then : else exitcode=1 echo as_func_ret_success failed. fi if as_func_ret_failure; then exitcode=1 echo as_func_ret_failure succeeded. fi if ( set x; as_func_ret_success y && test x = \"\$1\" ); then : else exitcode=1 echo positional parameters were not saved. fi test \$exitcode = 0") || { echo No shell found that supports shell functions. echo Please tell autoconf@gnu.org about your system, echo including any error possibly output before this echo message } as_lineno_1=$LINENO as_lineno_2=$LINENO test "x$as_lineno_1" != "x$as_lineno_2" && test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || { # Create $as_me.lineno as a copy of $as_myself, but with $LINENO # uniformly replaced by the line number. The first 'sed' inserts a # line-number line after each line using $LINENO; the second 'sed' # does the real work. The second script uses 'N' to pair each # line-number line with the line containing $LINENO, and appends # trailing '-' during substitution so that $LINENO is not a special # case at line end. # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the # scripts with optimization help from Paolo Bonzini. Blame Lee # E. McMahon (1931-1989) for sed's syntax. :-) sed -n ' p /[$]LINENO/= ' <$as_myself | sed ' s/[$]LINENO.*/&-/ t lineno b :lineno N :loop s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ t loop s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 { (exit 1); exit 1; }; } # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). . "./$as_me.lineno" # Exit status is that of the last command. exit } if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in -n*) case `echo 'x\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. *) ECHO_C='\c';; esac;; *) ECHO_N='-n';; esac if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir fi echo >conf$$.file if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -p'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -p' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then as_mkdir_p=: else test -d ./-p && rmdir ./-p as_mkdir_p=false fi if test -x / >/dev/null 2>&1; then as_test_x='test -x' else if ls -dL / >/dev/null 2>&1; then as_ls_L_option=L else as_ls_L_option= fi as_test_x=' eval sh -c '\'' if test -d "$1"; then test -d "$1/."; else case $1 in -*)set "./$1";; esac; case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in ???[sx]*):;;*)false;;esac;fi '\'' sh ' fi as_executable_p=$as_test_x # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" exec 7<&0 &1 # Name of the host. # hostname on some systems (SVR3.2, Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` # # Initializations. # ac_default_prefix=/usr/local ac_clean_files= ac_config_libobj_dir=. LIBOBJS= cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= SHELL=${CONFIG_SHELL-/bin/sh} # Identity of this package. PACKAGE_NAME='JRI' PACKAGE_TARNAME='jri' PACKAGE_VERSION='0.3' PACKAGE_STRING='JRI 0.3' PACKAGE_BUGREPORT='simon.urbanek@r-project.org' ac_unique_file="src/jri.h" ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datarootdir datadir sysconfdir sharedstatedir localstatedir includedir oldincludedir docdir infodir htmldir dvidir pdfdir psdir libdir localedir mandir DEFS ECHO_C ECHO_N ECHO_T LIBS build_alias host_alias target_alias build build_cpu build_vendor build_os host host_cpu host_vendor host_os R_HOME R_SHARE_DIR R_DOC_DIR R_INCLUDE_DIR CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CPP GREP EGREP JAVA_PROG JAVAC JAVAH JAR JAVA_HOME JAVA_LD_PATH JAVA_LIBS JAVA_INC JAVA_CFLAGS JNILD JNISO JNIPREFIX CPICF RINC RLD DEFFLAGS LIBOBJS LTLIBOBJS' ac_subst_files='' ac_precious_vars='build_alias host_alias target_alias CC CFLAGS LDFLAGS LIBS CPPFLAGS CPP' # Initialize some variables set by options. ac_init_help= ac_init_version=false # The variables have the same names as the options, with # dashes changed to underlines. cache_file=/dev/null exec_prefix=NONE no_create= no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= verbose= x_includes=NONE x_libraries=NONE # Installation directory options. # These are left unexpanded so users can "make install exec_prefix=/foo" # and all the variables that are supposed to be based on exec_prefix # by default will actually change. # Use braces instead of parens because sh, perl, etc. also accept them. # (The list follows the same order as the GNU Coding Standards.) bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datarootdir='${prefix}/share' datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' infodir='${datarootdir}/info' htmldir='${docdir}' dvidir='${docdir}' pdfdir='${docdir}' psdir='${docdir}' libdir='${exec_prefix}/lib' localedir='${datarootdir}/locale' mandir='${datarootdir}/man' ac_prev= ac_dashdash= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval $ac_prev=\$ac_option ac_prev= continue fi case $ac_option in *=*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; *) ac_optarg=yes ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. case $ac_dashdash$ac_option in --) ac_dashdash=yes ;; -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir=$ac_optarg ;; -build | --build | --buil | --bui | --bu) ac_prev=build_alias ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build_alias=$ac_optarg ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file=$ac_optarg ;; --config-cache | -C) cache_file=config.cache ;; -datadir | --datadir | --datadi | --datad) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=*) datadir=$ac_optarg ;; -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ | --dataroo | --dataro | --datar) ac_prev=datarootdir ;; -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) datarootdir=$ac_optarg ;; -disable-* | --disable-*) ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_feature" : ".*[^-._$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid feature name: $ac_feature" >&2 { (exit 1); exit 1; }; } ac_feature=`echo $ac_feature | sed 's/[-.]/_/g'` eval enable_$ac_feature=no ;; -docdir | --docdir | --docdi | --doc | --do) ac_prev=docdir ;; -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) docdir=$ac_optarg ;; -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) ac_prev=dvidir ;; -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) dvidir=$ac_optarg ;; -enable-* | --enable-*) ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_feature" : ".*[^-._$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid feature name: $ac_feature" >&2 { (exit 1); exit 1; }; } ac_feature=`echo $ac_feature | sed 's/[-.]/_/g'` eval enable_$ac_feature=\$ac_optarg ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix=$ac_optarg ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he | -h) ac_init_help=long ;; -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) ac_init_help=recursive ;; -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) ac_init_help=short ;; -host | --host | --hos | --ho) ac_prev=host_alias ;; -host=* | --host=* | --hos=* | --ho=*) host_alias=$ac_optarg ;; -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) ac_prev=htmldir ;; -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ | --ht=*) htmldir=$ac_optarg ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir=$ac_optarg ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir=$ac_optarg ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir=$ac_optarg ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir=$ac_optarg ;; -localedir | --localedir | --localedi | --localed | --locale) ac_prev=localedir ;; -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) localedir=$ac_optarg ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst | --locals) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir=$ac_optarg ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c | -n) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir=$ac_optarg ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix=$ac_optarg ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix=$ac_optarg ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix=$ac_optarg ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name=$ac_optarg ;; -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) ac_prev=pdfdir ;; -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) pdfdir=$ac_optarg ;; -psdir | --psdir | --psdi | --psd | --ps) ac_prev=psdir ;; -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) psdir=$ac_optarg ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir=$ac_optarg ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir=$ac_optarg ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site=$ac_optarg ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir=$ac_optarg ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir=$ac_optarg ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target_alias ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target_alias=$ac_optarg ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers | -V) ac_init_version=: ;; -with-* | --with-*) ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_package" : ".*[^-._$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid package name: $ac_package" >&2 { (exit 1); exit 1; }; } ac_package=`echo $ac_package | sed 's/[-.]/_/g'` eval with_$ac_package=\$ac_optarg ;; -without-* | --without-*) ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_package" : ".*[^-._$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid package name: $ac_package" >&2 { (exit 1); exit 1; }; } ac_package=`echo $ac_package | sed 's/[-.]/_/g'` eval with_$ac_package=no ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes=$ac_optarg ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; -*) { echo "$as_me: error: unrecognized option: $ac_option Try \`$0 --help' for more information." >&2 { (exit 1); exit 1; }; } ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid variable name: $ac_envvar" >&2 { (exit 1); exit 1; }; } eval $ac_envvar=\$ac_optarg export $ac_envvar ;; *) # FIXME: should be removed in autoconf 3.0. echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && echo "$as_me: WARNING: invalid host type: $ac_option" >&2 : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} ;; esac done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` { echo "$as_me: error: missing argument to $ac_option" >&2 { (exit 1); exit 1; }; } fi # Be sure to have absolute directory names. for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ libdir localedir mandir do eval ac_val=\$$ac_var case $ac_val in [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 { (exit 1); exit 1; }; } done # There might be people who depend on the old broken behavior: `$host' # used to hold the argument of --host etc. # FIXME: To remove some day. build=$build_alias host=$host_alias target=$target_alias # FIXME: To remove some day. if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. If a cross compiler is detected then cross compile mode will be used." >&2 elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi fi ac_tool_prefix= test -n "$host_alias" && ac_tool_prefix=$host_alias- test "$silent" = yes && exec 6>/dev/null ac_pwd=`pwd` && test -n "$ac_pwd" && ac_ls_di=`ls -di .` && ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || { echo "$as_me: error: Working directory cannot be determined" >&2 { (exit 1); exit 1; }; } test "X$ac_ls_di" = "X$ac_pwd_ls_di" || { echo "$as_me: error: pwd does not report name of working directory" >&2 { (exit 1); exit 1; }; } # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then the parent directory. ac_confdir=`$as_dirname -- "$0" || $as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$0" : 'X\(//\)[^/]' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || echo X"$0" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` srcdir=$ac_confdir if test ! -r "$srcdir/$ac_unique_file"; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2 { (exit 1); exit 1; }; } fi ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ac_abs_confdir=`( cd "$srcdir" && test -r "./$ac_unique_file" || { echo "$as_me: error: $ac_msg" >&2 { (exit 1); exit 1; }; } pwd)` # When building in place, set srcdir=. if test "$ac_abs_confdir" = "$ac_pwd"; then srcdir=. fi # Remove unnecessary trailing slashes from srcdir. # Double slashes in file names in object file debugging info # mess up M-x gdb in Emacs. case $srcdir in */) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; esac for ac_var in $ac_precious_vars; do eval ac_env_${ac_var}_set=\${${ac_var}+set} eval ac_env_${ac_var}_value=\$${ac_var} eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} eval ac_cv_env_${ac_var}_value=\$${ac_var} done # # Report the --help message. # if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF \`configure' configures JRI 0.3 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. Configuration: -h, --help display this help and exit --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit -q, --quiet, --silent do not print \`checking...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or \`..'] Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX] By default, \`make install' will install all the files in \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify an installation prefix other than \`$ac_default_prefix' using \`--prefix', for instance \`--prefix=\$HOME'. For better control, use the options below. Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] --datadir=DIR read-only architecture-independent data [DATAROOTDIR] --infodir=DIR info documentation [DATAROOTDIR/info] --localedir=DIR locale-dependent data [DATAROOTDIR/locale] --mandir=DIR man documentation [DATAROOTDIR/man] --docdir=DIR documentation root [DATAROOTDIR/doc/jri] --htmldir=DIR html documentation [DOCDIR] --dvidir=DIR dvi documentation [DOCDIR] --pdfdir=DIR pdf documentation [DOCDIR] --psdir=DIR ps documentation [DOCDIR] _ACEOF cat <<\_ACEOF System types: --build=BUILD configure for building on BUILD [guessed] --host=HOST cross-compile to build programs to run on HOST [BUILD] _ACEOF fi if test -n "$ac_init_help"; then case $ac_init_help in short | recursive ) echo "Configuration of JRI 0.3:";; esac cat <<\_ACEOF Some influential environment variables: CC C compiler command CFLAGS C compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory LIBS libraries to pass to the linker, e.g. -l CPPFLAGS C/C++/Objective C preprocessor flags, e.g. -I if you have headers in a nonstandard directory CPP C preprocessor Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. Report bugs to . _ACEOF ac_status=$? fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue test -d "$ac_dir" || continue ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,/..,g;s,/,,'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix cd "$ac_dir" || { ac_status=$?; continue; } # Check for guested configure. if test -f "$ac_srcdir/configure.gnu"; then echo && $SHELL "$ac_srcdir/configure.gnu" --help=recursive elif test -f "$ac_srcdir/configure"; then echo && $SHELL "$ac_srcdir/configure" --help=recursive else echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi || ac_status=$? cd "$ac_pwd" || { ac_status=$?; break; } done fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF JRI configure 0.3 generated by GNU Autoconf 2.61 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF exit fi cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by JRI $as_me 0.3, which was generated by GNU Autoconf 2.61. Invocation command line was $ $0 $@ _ACEOF exec 5>>config.log { cat <<_ASUNAME ## --------- ## ## Platform. ## ## --------- ## hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` /usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` _ASUNAME as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. echo "PATH: $as_dir" done IFS=$as_save_IFS } >&5 cat >&5 <<_ACEOF ## ----------- ## ## Core tests. ## ## ----------- ## _ACEOF # Keep a trace of the command line. # Strip out --no-create and --no-recursion so they do not pile up. # Strip out --silent because we don't want to record it for future runs. # Also quote any args containing shell meta-characters. # Make two passes to allow for proper duplicate-argument suppression. ac_configure_args= ac_configure_args0= ac_configure_args1= ac_must_keep_next=false for ac_pass in 1 2 do for ac_arg do case $ac_arg in -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) continue ;; *\'*) ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;; 2) ac_configure_args1="$ac_configure_args1 '$ac_arg'" if test $ac_must_keep_next = true; then ac_must_keep_next=false # Got value, back to normal. else case $ac_arg in *=* | --config-cache | -C | -disable-* | --disable-* \ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ | -with-* | --with-* | -without-* | --without-* | --x) case "$ac_configure_args0 " in "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; esac ;; -* ) ac_must_keep_next=true ;; esac fi ac_configure_args="$ac_configure_args '$ac_arg'" ;; esac done done $as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; } $as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; } # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. # WARNING: Use '\'' to represent an apostrophe within the trap. # WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. trap 'exit_status=$? # Save into config.log some information that might help in debugging. { echo cat <<\_ASBOX ## ---------------- ## ## Cache variables. ## ## ---------------- ## _ASBOX echo # The following way of writing the cache mishandles newlines in values, ( for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5 echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( *) $as_unset $ac_var ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( *${as_nl}ac_space=\ *) sed -n \ "s/'\''/'\''\\\\'\'''\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" ;; #( *) sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) echo cat <<\_ASBOX ## ----------------- ## ## Output variables. ## ## ----------------- ## _ASBOX echo for ac_var in $ac_subst_vars do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac echo "$ac_var='\''$ac_val'\''" done | sort echo if test -n "$ac_subst_files"; then cat <<\_ASBOX ## ------------------- ## ## File substitutions. ## ## ------------------- ## _ASBOX echo for ac_var in $ac_subst_files do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac echo "$ac_var='\''$ac_val'\''" done | sort echo fi if test -s confdefs.h; then cat <<\_ASBOX ## ----------- ## ## confdefs.h. ## ## ----------- ## _ASBOX echo cat confdefs.h echo fi test "$ac_signal" != 0 && echo "$as_me: caught signal $ac_signal" echo "$as_me: exit $exit_status" } >&5 rm -f core *.core core.conftest.* && rm -f -r conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status ' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -f -r conftest* confdefs.h # Predefined preprocessor variables. cat >>confdefs.h <<_ACEOF #define PACKAGE_NAME "$PACKAGE_NAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_TARNAME "$PACKAGE_TARNAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_VERSION "$PACKAGE_VERSION" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_STRING "$PACKAGE_STRING" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" _ACEOF # Let the site file select an alternate cache file if it wants to. # Prefer explicitly selected file to automatically selected ones. if test -n "$CONFIG_SITE"; then set x "$CONFIG_SITE" elif test "x$prefix" != xNONE; then set x "$prefix/share/config.site" "$prefix/etc/config.site" else set x "$ac_default_prefix/share/config.site" \ "$ac_default_prefix/etc/config.site" fi shift for ac_site_file do if test -r "$ac_site_file"; then { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5 echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" fi done if test -r "$cache_file"; then # Some versions of bash will fail to source /dev/null (special # files actually), so we avoid doing that. if test -f "$cache_file"; then { echo "$as_me:$LINENO: loading cache $cache_file" >&5 echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . "$cache_file";; *) . "./$cache_file";; esac fi else { echo "$as_me:$LINENO: creating cache $cache_file" >&5 echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false for ac_var in $ac_precious_vars; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set eval ac_old_val=\$ac_cv_env_${ac_var}_value eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5 echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5 echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} { echo "$as_me:$LINENO: former value: $ac_old_val" >&5 echo "$as_me: former value: $ac_old_val" >&2;} { echo "$as_me:$LINENO: current value: $ac_new_val" >&5 echo "$as_me: current value: $ac_new_val" >&2;} ac_cache_corrupted=: fi;; esac # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in *\'*) ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. *) ac_configure_args="$ac_configure_args '$ac_arg'" ;; esac fi done if $ac_cache_corrupted; then { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5 echo "$as_me: error: changes in the environment can compromise the build" >&2;} { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5 echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;} { (exit 1); exit 1; }; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_config_headers="$ac_config_headers src/config.h" ac_aux_dir= for ac_dir in tools "$srcdir"/tools; do if test -f "$ac_dir/install-sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install-sh -c" break elif test -f "$ac_dir/install.sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install.sh -c" break elif test -f "$ac_dir/shtool"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/shtool install -c" break fi done if test -z "$ac_aux_dir"; then { { echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in tools \"$srcdir\"/tools" >&5 echo "$as_me: error: cannot find install-sh or install.sh in tools \"$srcdir\"/tools" >&2;} { (exit 1); exit 1; }; } fi # These three variables are undocumented and unsupported, # and are intended to be withdrawn in a future Autoconf release. # They can cause serious problems if a builder's source tree is in a directory # whose full name contains unusual characters. ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. # Make sure we can run config.sub. $SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || { { echo "$as_me:$LINENO: error: cannot run $SHELL $ac_aux_dir/config.sub" >&5 echo "$as_me: error: cannot run $SHELL $ac_aux_dir/config.sub" >&2;} { (exit 1); exit 1; }; } { echo "$as_me:$LINENO: checking build system type" >&5 echo $ECHO_N "checking build system type... $ECHO_C" >&6; } if test "${ac_cv_build+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_build_alias=$build_alias test "x$ac_build_alias" = x && ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` test "x$ac_build_alias" = x && { { echo "$as_me:$LINENO: error: cannot guess build type; you must specify one" >&5 echo "$as_me: error: cannot guess build type; you must specify one" >&2;} { (exit 1); exit 1; }; } ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || { { echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $ac_build_alias failed" >&5 echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $ac_build_alias failed" >&2;} { (exit 1); exit 1; }; } fi { echo "$as_me:$LINENO: result: $ac_cv_build" >&5 echo "${ECHO_T}$ac_cv_build" >&6; } case $ac_cv_build in *-*-*) ;; *) { { echo "$as_me:$LINENO: error: invalid value of canonical build" >&5 echo "$as_me: error: invalid value of canonical build" >&2;} { (exit 1); exit 1; }; };; esac build=$ac_cv_build ac_save_IFS=$IFS; IFS='-' set x $ac_cv_build shift build_cpu=$1 build_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: build_os=$* IFS=$ac_save_IFS case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac { echo "$as_me:$LINENO: checking host system type" >&5 echo $ECHO_N "checking host system type... $ECHO_C" >&6; } if test "${ac_cv_host+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "x$host_alias" = x; then ac_cv_host=$ac_cv_build else ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || { { echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $host_alias failed" >&5 echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $host_alias failed" >&2;} { (exit 1); exit 1; }; } fi fi { echo "$as_me:$LINENO: result: $ac_cv_host" >&5 echo "${ECHO_T}$ac_cv_host" >&6; } case $ac_cv_host in *-*-*) ;; *) { { echo "$as_me:$LINENO: error: invalid value of canonical host" >&5 echo "$as_me: error: invalid value of canonical host" >&2;} { (exit 1); exit 1; }; };; esac host=$ac_cv_host ac_save_IFS=$IFS; IFS='-' set x $ac_cv_host shift host_cpu=$1 host_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: host_os=$* IFS=$ac_save_IFS case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac # find R home : ${R_HOME=`R RHOME`} if test -z "${R_HOME}"; then echo "could not determine R_HOME" exit 1 fi # we attempt to use the same compiler as R did RBIN="${R_HOME}/bin/R" R_CC=`"${RBIN}" CMD config CC` R_CPP=`"${RBIN}" CMD config CPP` R_CFLAGS=`"${RBIN}" CMD config CFLAGS` # find R_SHARE_DIR : ${R_SHARE_DIR=`"${RBIN}" CMD sh -c 'echo $R_SHARE_DIR'`} if test -z "${R_SHARE_DIR}"; then echo "could not determine R_SHARE_DIR" exit 1 fi # find R_DOC_DIR : ${R_DOC_DIR=`"${RBIN}" CMD sh -c 'echo $R_DOC_DIR'`} if test -z "${R_DOC_DIR}"; then echo "could not determine R_DOC_DIR" exit 1 fi # find R_INCLUDE_DIR : ${R_INCLUDE_DIR=`"${RBIN}" CMD sh -c 'echo $R_INCLUDE_DIR'`} if test -z "${R_INCLUDE_DIR}"; then echo "could not determine R_INCLUDE_DIR" exit 1 fi # if user did not specify CC then we use R's settings. # if CC was set then user is responsible for CFLAGS as well! if test -z "${CC}"; then CC="${R_CC}" CPP="${R_CPP}" CFLAGS="${R_CFLAGS}" fi RINC=`"${RBIN}" CMD config --cppflags` RLD=`"${RBIN}" CMD config --ldflags` if test -z "$RLD"; then { { echo "$as_me:$LINENO: error: R was not compiled with --enable-R-shlib *** You must have libR.so or equivalent in order to use JRI *** " >&5 echo "$as_me: error: R was not compiled with --enable-R-shlib *** You must have libR.so or equivalent in order to use JRI *** " >&2;} { (exit 1); exit 1; }; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}gcc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { echo "$as_me:$LINENO: result: $CC" >&5 echo "${ECHO_T}$CC" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_ac_ct_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="gcc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 echo "${ECHO_T}$ac_ct_CC" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&5 echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}cc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { echo "$as_me:$LINENO: result: $CC" >&5 echo "${ECHO_T}$CC" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi fi fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { echo "$as_me:$LINENO: result: $CC" >&5 echo "${ECHO_T}$CC" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then for ac_prog in cl.exe do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { echo "$as_me:$LINENO: result: $CC" >&5 echo "${ECHO_T}$CC" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC for ac_prog in cl.exe do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_ac_ct_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="$ac_prog" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 echo "${ECHO_T}$ac_ct_CC" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi test -n "$ac_ct_CC" && break done if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&5 echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi fi fi test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH See \`config.log' for more details." >&5 echo "$as_me: error: no acceptable C compiler found in \$PATH See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } # Provide some information about the compiler. echo "$as_me:$LINENO: checking for C compiler version" >&5 ac_compiler=`set X $ac_compile; echo $2` { (ac_try="$ac_compiler --version >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compiler --version >&5") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } { (ac_try="$ac_compiler -v >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compiler -v >&5") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } { (ac_try="$ac_compiler -V >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compiler -V >&5") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files a.out a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. { echo "$as_me:$LINENO: checking for C compiler default output file name" >&5 echo $ECHO_N "checking for C compiler default output file name... $ECHO_C" >&6; } ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` # # List of possible output files, starting from the most likely. # The algorithm is not robust to junk in `.', hence go to wildcards (a.*) # only as a last resort. b.out is created by i960 compilers. ac_files='a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out' # # The IRIX 6 linker writes into existing files which may not be # executable, retaining their permissions. Remove them first so a # subsequent execution test works. ac_rmfiles= for ac_file in $ac_files do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) ;; * ) ac_rmfiles="$ac_rmfiles $ac_file";; esac done rm -f $ac_rmfiles if { (ac_try="$ac_link_default" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link_default") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. # So ignore a value of `no', otherwise this would lead to `EXEEXT = no' # in a Makefile. We should not override ac_cv_exeext if it was cached, # so that the user can short-circuit this test for compilers unknown to # Autoconf. for ac_file in $ac_files '' do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) ;; [ab].out ) # We found the default executable, but exeext='' is most # certainly right. break;; *.* ) if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; then :; else ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` fi # We set ac_cv_exeext here because the later test for it is not # safe: cross compilers may not add the suffix if given an `-o' # argument, so we may need to know it at that point already. # Even if this section looks crufty: it has the advantage of # actually working. break;; * ) break;; esac done test "$ac_cv_exeext" = no && ac_cv_exeext= else ac_file='' fi { echo "$as_me:$LINENO: result: $ac_file" >&5 echo "${ECHO_T}$ac_file" >&6; } if test -z "$ac_file"; then echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { echo "$as_me:$LINENO: error: C compiler cannot create executables See \`config.log' for more details." >&5 echo "$as_me: error: C compiler cannot create executables See \`config.log' for more details." >&2;} { (exit 77); exit 77; }; } fi ac_exeext=$ac_cv_exeext # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. { echo "$as_me:$LINENO: checking whether the C compiler works" >&5 echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6; } # FIXME: These cross compiler hacks should be removed for Autoconf 3.0 # If not cross compiling, check that we can run a simple program. if test "$cross_compiling" != yes; then if { ac_try='./$ac_file' { (case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_try") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else { { echo "$as_me:$LINENO: error: cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details." >&5 echo "$as_me: error: cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } fi fi fi { echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6; } rm -f a.out a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. { echo "$as_me:$LINENO: checking whether we are cross compiling" >&5 echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6; } { echo "$as_me:$LINENO: result: $cross_compiling" >&5 echo "${ECHO_T}$cross_compiling" >&6; } { echo "$as_me:$LINENO: checking for suffix of executables" >&5 echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6; } if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with # `rm'. for ac_file in conftest.exe conftest conftest.*; do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` break;; * ) break;; esac done else { { echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute suffix of executables: cannot compile and link See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } fi rm -f conftest$ac_cv_exeext { echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5 echo "${ECHO_T}$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT { echo "$as_me:$LINENO: checking for suffix of object files" >&5 echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6; } if test "${ac_cv_objext+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.o conftest.obj if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then for ac_file in conftest.o conftest.obj conftest.*; do test -f "$ac_file" || continue; case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac done else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute suffix of object files: cannot compile See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi { echo "$as_me:$LINENO: result: $ac_cv_objext" >&5 echo "${ECHO_T}$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT { echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6; } if test "${ac_cv_c_compiler_gnu+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_compiler_gnu=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi { echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6; } GCC=`test $ac_compiler_gnu = yes && echo yes` ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6; } if test "${ac_cv_prog_cc_g+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no CFLAGS="-g" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_prog_cc_g=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 CFLAGS="" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_prog_cc_g=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi { echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 echo "${ECHO_T}$ac_cv_prog_cc_g" >&6; } if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi { echo "$as_me:$LINENO: checking for $CC option to accept ISO C89" >&5 echo $ECHO_N "checking for $CC option to accept ISO C89... $ECHO_C" >&6; } if test "${ac_cv_prog_cc_c89+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_cv_prog_cc_c89=no ac_save_CC=$CC cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include #include #include /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); static char *e (p, i) char **p; int i; { return p[i]; } static char *f (char * (*g) (char **, int), char **p, ...) { char *s; va_list v; va_start (v,p); s = g (p, va_arg (v,int)); va_end (v); return s; } /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not '\xHH' hex character constants. These don't provoke an error unfortunately, instead are silently treated as 'x'. The following induces an error, until -std is added to get proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an array size at least. It's necessary to write '\x00'==0 to get something that's true only with -std. */ int osf4_cc_array ['\x00' == 0 ? 1 : -1]; /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters inside strings and character constants. */ #define FOO(x) 'x' int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); int argc; char **argv; int main () { return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ; return 0; } _ACEOF for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_prog_cc_c89=$ac_arg else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c89" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi # AC_CACHE_VAL case "x$ac_cv_prog_cc_c89" in x) { echo "$as_me:$LINENO: result: none needed" >&5 echo "${ECHO_T}none needed" >&6; } ;; xno) { echo "$as_me:$LINENO: result: unsupported" >&5 echo "${ECHO_T}unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c89" { echo "$as_me:$LINENO: result: $ac_cv_prog_cc_c89" >&5 echo "${ECHO_T}$ac_cv_prog_cc_c89" >&6; } ;; esac ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5 echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6; } # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then if test "${ac_cv_prog_CPP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else # Double quotes because CPP needs to be expanded for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" do ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if { (ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then : else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 # Broken: fails on valid input. continue fi rm -f conftest.err conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if { (ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then # Broken: success on invalid input. continue else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.err conftest.$ac_ext if $ac_preproc_ok; then break fi done ac_cv_prog_CPP=$CPP fi CPP=$ac_cv_prog_CPP else ac_cv_prog_CPP=$CPP fi { echo "$as_me:$LINENO: result: $CPP" >&5 echo "${ECHO_T}$CPP" >&6; } ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if { (ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then : else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 # Broken: fails on valid input. continue fi rm -f conftest.err conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if { (ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then # Broken: success on invalid input. continue else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details." >&5 echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { echo "$as_me:$LINENO: checking for grep that handles long lines and -e" >&5 echo $ECHO_N "checking for grep that handles long lines and -e... $ECHO_C" >&6; } if test "${ac_cv_path_GREP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else # Extract the first word of "grep ggrep" to use in msg output if test -z "$GREP"; then set dummy grep ggrep; ac_prog_name=$2 if test "${ac_cv_path_GREP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_path_GREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in grep ggrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue # Check for GNU ac_path_GREP and select it if it is found. # Check for GNU $ac_path_GREP case `"$ac_path_GREP" --version 2>&1` in *GNU*) ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; *) ac_count=0 echo $ECHO_N "0123456789$ECHO_C" >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" echo 'GREP' >> "conftest.nl" "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break ac_count=`expr $ac_count + 1` if test $ac_count -gt ${ac_path_GREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_GREP_found && break 3 done done done IFS=$as_save_IFS fi GREP="$ac_cv_path_GREP" if test -z "$GREP"; then { { echo "$as_me:$LINENO: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 echo "$as_me: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} { (exit 1); exit 1; }; } fi else ac_cv_path_GREP=$GREP fi fi { echo "$as_me:$LINENO: result: $ac_cv_path_GREP" >&5 echo "${ECHO_T}$ac_cv_path_GREP" >&6; } GREP="$ac_cv_path_GREP" { echo "$as_me:$LINENO: checking for egrep" >&5 echo $ECHO_N "checking for egrep... $ECHO_C" >&6; } if test "${ac_cv_path_EGREP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 then ac_cv_path_EGREP="$GREP -E" else # Extract the first word of "egrep" to use in msg output if test -z "$EGREP"; then set dummy egrep; ac_prog_name=$2 if test "${ac_cv_path_EGREP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_path_EGREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in egrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue # Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP case `"$ac_path_EGREP" --version 2>&1` in *GNU*) ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; *) ac_count=0 echo $ECHO_N "0123456789$ECHO_C" >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" echo 'EGREP' >> "conftest.nl" "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break ac_count=`expr $ac_count + 1` if test $ac_count -gt ${ac_path_EGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_EGREP_found && break 3 done done done IFS=$as_save_IFS fi EGREP="$ac_cv_path_EGREP" if test -z "$EGREP"; then { { echo "$as_me:$LINENO: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 echo "$as_me: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} { (exit 1); exit 1; }; } fi else ac_cv_path_EGREP=$EGREP fi fi fi { echo "$as_me:$LINENO: result: $ac_cv_path_EGREP" >&5 echo "${ECHO_T}$ac_cv_path_EGREP" >&6; } EGREP="$ac_cv_path_EGREP" { echo "$as_me:$LINENO: checking for ANSI C header files" >&5 echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6; } if test "${ac_cv_header_stdc+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include #include #include int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_header_stdc=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_header_stdc=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "memchr" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "free" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include #if ((' ' & 0x0FF) == 0x020) # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #else # define ISLOWER(c) \ (('a' <= (c) && (c) <= 'i') \ || ('j' <= (c) && (c) <= 'r') \ || ('s' <= (c) && (c) <= 'z')) # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) #endif #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) return 2; return 0; } _ACEOF rm -f conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_try") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then : else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) ac_cv_header_stdc=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi fi { echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 echo "${ECHO_T}$ac_cv_header_stdc" >&6; } if test $ac_cv_header_stdc = yes; then cat >>confdefs.h <<\_ACEOF #define STDC_HEADERS 1 _ACEOF fi ## RUN_JAVA(variable for the result, parameters) ## ---------- ## runs the java interpreter ${JAVA_PROG} with specified parameters and ## saves the output to the supplied variable. The exit value is ignored. if test -n "${CONFIGURED}"; then ## re-map varibles that don't match JAVA_PROG="${JAVA}" JAVA_INC="${JAVA_CPPFLAGS}" JAVA_LD_PATH="${JAVA_LD_LIBRARY_PATH}" else ## find java compiler binaries if test -z "${JAVA_HOME}" ; then JAVA_PATH=${PATH} else JAVA_PATH=${JAVA_HOME}:${JAVA_HOME}/jre/bin:${JAVA_HOME}/bin:${JAVA_HOME}/../bin:${PATH} fi ## if 'java' is not on the PATH or JAVA_HOME, add some guesses as of ## where java could live JAVA_PATH=${JAVA_PATH}:/usr/java/bin:/usr/jdk/bin:/usr/lib/java/bin:/usr/lib/jdk/bin:/usr/local/java/bin:/usr/local/jdk/bin:/usr/local/lib/java/bin:/usr/local/lib/jdk/bin for ac_prog in java do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_path_JAVA_PROG+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else case $JAVA_PROG in [\\/]* | ?:[\\/]*) ac_cv_path_JAVA_PROG="$JAVA_PROG" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in ${JAVA_PATH} do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_JAVA_PROG="$as_dir/$ac_word$ac_exec_ext" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi JAVA_PROG=$ac_cv_path_JAVA_PROG if test -n "$JAVA_PROG"; then { echo "$as_me:$LINENO: result: $JAVA_PROG" >&5 echo "${ECHO_T}$JAVA_PROG" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi test -n "$JAVA_PROG" && break done ## FIXME: we may want to check for jikes, kaffe and others... for ac_prog in javac do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_path_JAVAC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else case $JAVAC in [\\/]* | ?:[\\/]*) ac_cv_path_JAVAC="$JAVAC" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in ${JAVA_PATH} do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_JAVAC="$as_dir/$ac_word$ac_exec_ext" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi JAVAC=$ac_cv_path_JAVAC if test -n "$JAVAC"; then { echo "$as_me:$LINENO: result: $JAVAC" >&5 echo "${ECHO_T}$JAVAC" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi test -n "$JAVAC" && break done for ac_prog in javah do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_path_JAVAH+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else case $JAVAH in [\\/]* | ?:[\\/]*) ac_cv_path_JAVAH="$JAVAH" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in ${JAVA_PATH} do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_JAVAH="$as_dir/$ac_word$ac_exec_ext" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi JAVAH=$ac_cv_path_JAVAH if test -n "$JAVAH"; then { echo "$as_me:$LINENO: result: $JAVAH" >&5 echo "${ECHO_T}$JAVAH" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi test -n "$JAVAH" && break done for ac_prog in jar do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_path_JAR+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else case $JAR in [\\/]* | ?:[\\/]*) ac_cv_path_JAR="$JAR" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in ${JAVA_PATH} do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_JAR="$as_dir/$ac_word$ac_exec_ext" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi JAR=$ac_cv_path_JAR if test -n "$JAR"; then { echo "$as_me:$LINENO: result: $JAR" >&5 echo "${ECHO_T}$JAR" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi test -n "$JAR" && break done fi have_all_java=yes if test -z "$JAVA_PROG"; then have_all_java=no; fi if test -z "$JAVAC"; then have_all_java=no; fi if test -z "$JAVAH"; then have_all_java=no; fi if test -z "$JAR"; then have_all_java=no; fi if test ${have_all_java} = no; then { { echo "$as_me:$LINENO: error: one or more Java tools are missing. *** JDK is incomplete! Please make sure you have a complete JDK. JRE is *not* sufficient." >&5 echo "$as_me: error: one or more Java tools are missing. *** JDK is incomplete! Please make sure you have a complete JDK. JRE is *not* sufficient." >&2;} { (exit 1); exit 1; }; } fi ## this is where our test-class lives getsp_cp=tools { echo "$as_me:$LINENO: checking whether Java interpreter works" >&5 echo $ECHO_N "checking whether Java interpreter works... $ECHO_C" >&6; } acx_java_works=no if test -n "${JAVA_PROG}" ; then acx_java_result= if test -z "${JAVA_PROG}"; then echo "$as_me:$LINENO: JAVA_PROG is not set, cannot run java -classpath ${getsp_cp} getsp -test" >&5 else echo "$as_me:$LINENO: running ${JAVA_PROG} -classpath ${getsp_cp} getsp -test" >&5 acx_java_result=`${JAVA_PROG} -classpath ${getsp_cp} getsp -test 2>&5` echo "$as_me:$LINENO: output: '$acx_java_result'" >&5 fi acx_jc_result=$acx_java_result if test "${acx_jc_result}" = "Test1234OK"; then acx_java_works=yes fi acx_jc_result= fi if test -z "${CONFIGURED}"; then if test ${acx_java_works} = yes; then { echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6; } { echo "$as_me:$LINENO: checking for Java environment" >&5 echo $ECHO_N "checking for Java environment... $ECHO_C" >&6; } ## retrieve JAVA_HOME from Java itself if not set if test -z "${JAVA_HOME}" ; then acx_java_result= if test -z "${JAVA_PROG}"; then echo "$as_me:$LINENO: JAVA_PROG is not set, cannot run java -classpath ${getsp_cp} getsp java.home" >&5 else echo "$as_me:$LINENO: running ${JAVA_PROG} -classpath ${getsp_cp} getsp java.home" >&5 acx_java_result=`${JAVA_PROG} -classpath ${getsp_cp} getsp java.home 2>&5` echo "$as_me:$LINENO: output: '$acx_java_result'" >&5 fi JAVA_HOME=$acx_java_result fi ## the availability of JAVA_HOME will tell us whether it's supported if test -z "${JAVA_HOME}" ; then if test x$acx_java_env_msg != xyes; then { echo "$as_me:$LINENO: result: not found" >&5 echo "${ECHO_T}not found" >&6; } fi else { echo "$as_me:$LINENO: result: in ${JAVA_HOME}" >&5 echo "${ECHO_T}in ${JAVA_HOME}" >&6; } case "${host_os}" in darwin*) JAVA_LIBS="-framework JavaVM" JAVA_LD_PATH= ;; *) acx_java_result= if test -z "${JAVA_PROG}"; then echo "$as_me:$LINENO: JAVA_PROG is not set, cannot run java -classpath ${getsp_cp} getsp -libs" >&5 else echo "$as_me:$LINENO: running ${JAVA_PROG} -classpath ${getsp_cp} getsp -libs" >&5 acx_java_result=`${JAVA_PROG} -classpath ${getsp_cp} getsp -libs 2>&5` echo "$as_me:$LINENO: output: '$acx_java_result'" >&5 fi JAVA_LIBS=$acx_java_result JAVA_LIBS="${JAVA_LIBS} -ljvm" acx_java_result= if test -z "${JAVA_PROG}"; then echo "$as_me:$LINENO: JAVA_PROG is not set, cannot run java -classpath ${getsp_cp} getsp java.library.path" >&5 else echo "$as_me:$LINENO: running ${JAVA_PROG} -classpath ${getsp_cp} getsp java.library.path" >&5 acx_java_result=`${JAVA_PROG} -classpath ${getsp_cp} getsp java.library.path 2>&5` echo "$as_me:$LINENO: output: '$acx_java_result'" >&5 fi JAVA_LD_PATH=$acx_java_result ;; esac ## note that we actually don't test JAVA_LIBS - we hope that the detection ## was correct. We should also test the functionality for javac. have_java=yes fi else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } { { echo "$as_me:$LINENO: error: Java not found. Please install JDK 1.4 or later, make sure that the binaries are on the PATH and re-try. If that doesn't work, set JAVA_HOME correspondingly." >&5 echo "$as_me: error: Java not found. Please install JDK 1.4 or later, make sure that the binaries are on the PATH and re-try. If that doesn't work, set JAVA_HOME correspondingly." >&2;} { (exit 1); exit 1; }; } fi as_ac_File=`echo "ac_cv_file_${JAVA_HOME}/include/jni.h" | $as_tr_sh` { echo "$as_me:$LINENO: checking for ${JAVA_HOME}/include/jni.h" >&5 echo $ECHO_N "checking for ${JAVA_HOME}/include/jni.h... $ECHO_C" >&6; } if { as_var=$as_ac_File; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 else test "$cross_compiling" = yes && { { echo "$as_me:$LINENO: error: cannot check for file existence when cross compiling" >&5 echo "$as_me: error: cannot check for file existence when cross compiling" >&2;} { (exit 1); exit 1; }; } if test -r "${JAVA_HOME}/include/jni.h"; then eval "$as_ac_File=yes" else eval "$as_ac_File=no" fi fi ac_res=`eval echo '${'$as_ac_File'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } if test `eval echo '${'$as_ac_File'}'` = yes; then JNI_H="${JAVA_HOME}/include" else as_ac_File=`echo "ac_cv_file_${JAVA_HOME}/jni.h" | $as_tr_sh` { echo "$as_me:$LINENO: checking for ${JAVA_HOME}/jni.h" >&5 echo $ECHO_N "checking for ${JAVA_HOME}/jni.h... $ECHO_C" >&6; } if { as_var=$as_ac_File; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 else test "$cross_compiling" = yes && { { echo "$as_me:$LINENO: error: cannot check for file existence when cross compiling" >&5 echo "$as_me: error: cannot check for file existence when cross compiling" >&2;} { (exit 1); exit 1; }; } if test -r "${JAVA_HOME}/jni.h"; then eval "$as_ac_File=yes" else eval "$as_ac_File=no" fi fi ac_res=`eval echo '${'$as_ac_File'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } if test `eval echo '${'$as_ac_File'}'` = yes; then JNI_H="${JAVA_HOME}" else as_ac_File=`echo "ac_cv_file_${JAVA_HOME}/../include/jni.h" | $as_tr_sh` { echo "$as_me:$LINENO: checking for ${JAVA_HOME}/../include/jni.h" >&5 echo $ECHO_N "checking for ${JAVA_HOME}/../include/jni.h... $ECHO_C" >&6; } if { as_var=$as_ac_File; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 else test "$cross_compiling" = yes && { { echo "$as_me:$LINENO: error: cannot check for file existence when cross compiling" >&5 echo "$as_me: error: cannot check for file existence when cross compiling" >&2;} { (exit 1); exit 1; }; } if test -r "${JAVA_HOME}/../include/jni.h"; then eval "$as_ac_File=yes" else eval "$as_ac_File=no" fi fi ac_res=`eval echo '${'$as_ac_File'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } if test `eval echo '${'$as_ac_File'}'` = yes; then JNI_H="${JAVA_HOME}/../include" else { { echo "$as_me:$LINENO: error: jni headers not found. Please make sure you have a proper JDK installed." >&5 echo "$as_me: error: jni headers not found. Please make sure you have a proper JDK installed." >&2;} { (exit 1); exit 1; }; } fi fi fi JAVA_INC="-I${JNI_H}" : ${JAVA_CFLAGS=-D_REENTRANT} # Sun's JDK needs jni_md.h in in addition to jni.h and unfortunately it's stored somewhere else ... # this should be become more general at some point - so far we're checking linux and solaris only # (well, those are presumably the only platforms supported by Sun's JDK and others don't need this # at least as of now - 01/2004) jac_found_md=no for mddir in . linux solaris ppc irix alpha aix hp-ux genunix cygwin win32 freebsd; do as_ac_File=`echo "ac_cv_file_${JNI_H}/$mddir/jni_md.h" | $as_tr_sh` { echo "$as_me:$LINENO: checking for ${JNI_H}/$mddir/jni_md.h" >&5 echo $ECHO_N "checking for ${JNI_H}/$mddir/jni_md.h... $ECHO_C" >&6; } if { as_var=$as_ac_File; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 else test "$cross_compiling" = yes && { { echo "$as_me:$LINENO: error: cannot check for file existence when cross compiling" >&5 echo "$as_me: error: cannot check for file existence when cross compiling" >&2;} { (exit 1); exit 1; }; } if test -r "${JNI_H}/$mddir/jni_md.h"; then eval "$as_ac_File=yes" else eval "$as_ac_File=no" fi fi ac_res=`eval echo '${'$as_ac_File'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } if test `eval echo '${'$as_ac_File'}'` = yes; then JAVA_INC="${JAVA_INC} -I${JNI_H}/$mddir" jac_found_md=yes fi if test ${jac_found_md} = yes; then break; fi done fi ## the configure variables may contain $(JAVA_HOME) which for testing needs to be replaced by the real path if test `echo foo | sed -e 's:foo:bar:'` = bar; then JAVA_INC0=`echo ${JAVA_INC} | sed -e 's:$(JAVA_HOME):'${JAVA_HOME}':g'` JAVA_LIBS0=`echo ${JAVA_LIBS} | sed -e 's:$(JAVA_HOME):'${JAVA_HOME}':g'` JAVA_LD_PATH0=`echo ${JAVA_LD_PATH} | sed -e 's:$(JAVA_HOME):'${JAVA_HOME}':g'` else { echo "$as_me:$LINENO: WARNING: sed is not working properly - the configuration may fail" >&5 echo "$as_me: WARNING: sed is not working properly - the configuration may fail" >&2;} JAVA_INC0="${JAVA_INC}" JAVA_LIBS0="${JAVA_LIBS}" JAVA_LD_PATH0="${JAVA_LD_PATH}" fi LIBS="${LIBS} ${JAVA_LIBS0}" CFLAGS="${CFLAGS} ${JAVA_CFLAGS} ${JAVA_INC0}" { echo "$as_me:$LINENO: checking whether JNI programs can be compiled" >&5 echo $ECHO_N "checking whether JNI programs can be compiled... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF #include int main(void) { jobject o; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then { echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6; } else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { echo "$as_me:$LINENO: error: Cannot compile a simple JNI program. See config.log for details." >&5 echo "$as_me: error: Cannot compile a simple JNI program. See config.log for details." >&2;} { (exit 1); exit 1; }; } fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${JAVA_LD_PATH0} export LD_LIBRARY_PATH { echo "$as_me:$LINENO: checking whether JNI programs can be run" >&5 echo $ECHO_N "checking whether JNI programs can be run... $ECHO_C" >&6; } if test "$cross_compiling" = yes; then { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling See \`config.log' for more details." >&5 echo "$as_me: error: cannot run test program while cross compiling See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } else cat >conftest.$ac_ext <<_ACEOF #include int main(void) { jobject o; return 0; } _ACEOF rm -f conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_try") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then { echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6; } else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) { { echo "$as_me:$LINENO: error: Cannot run a simple JNI program - probably your jvm library is in non-standard location or JVM is unsupported. See config.log for details." >&5 echo "$as_me: error: Cannot run a simple JNI program - probably your jvm library is in non-standard location or JVM is unsupported. See config.log for details." >&2;} { (exit 1); exit 1; }; } fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi { echo "$as_me:$LINENO: checking JNI data types" >&5 echo $ECHO_N "checking JNI data types... $ECHO_C" >&6; } if test "$cross_compiling" = yes; then { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling See \`config.log' for more details." >&5 echo "$as_me: error: cannot run test program while cross compiling See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include int main(void) { return (sizeof(int)==sizeof(jint) && sizeof(long)==sizeof(long) && sizeof(jbyte)==sizeof(char) && sizeof(jshort)==sizeof(short) && sizeof(jfloat)==sizeof(float) && sizeof(jdouble)==sizeof(double))?0:1; } _ACEOF rm -f conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_try") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then { echo "$as_me:$LINENO: result: ok" >&5 echo "${ECHO_T}ok" >&6; } else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) { { echo "$as_me:$LINENO: error: One or more JNI types differ from the corresponding native type. You may need to use non-standard compiler flags or a different compiler in order to fix this." >&5 echo "$as_me: error: One or more JNI types differ from the corresponding native type. You may need to use non-standard compiler flags or a different compiler in order to fix this." >&2;} { (exit 1); exit 1; }; } fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi JNIPREFIX=lib CPICF=`"${RBIN}" CMD config CPICFLAGS` JNISO=.so JNILD=`"${RBIN}" CMD config SHLIB_LDFLAGS`" ${JAVA_LIBS}" # we need to adjust a few things according to OS .. case "${host_os}" in darwin*) JNISO=.jnilib JNILD="-dynamiclib -framework JavaVM" CPICF=-fno-common if test -e "${R_HOME}/lib/i386" -a -e "${R_HOME}/lib/ppc" -a -e "${R_HOME}/lib/libR.dylib"; then # we have an universal framework, so we will use stubs and fat lib RLD="-framework R" RINC="-I${R_HOME}/include" # we can even cross-compile, maybe if test -z "${FORCE_NATIVE}"; then # find out the archs of JavaVM and build all of them jarchs=`file -L /System/Library/Frameworks/JavaVM.framework/JavaVM 2>/dev/null | sed -n 's/.*for architecture //p' | sed 's:).*::' | sed 's:ppc7.*:ppc:' | tr '\n' ' '` jrarchs='' ## ok, we have Java archs, but R may not be available for all of those for a in ${jarchs}; do if test -e "${R_HOME}/lib/$a"; then jrarchs="${jrarchs} $a"; fi done ## if have have more than one arch, display info and add -arch flags if test -n "${jrarchs}"; then echo "*** building fat JNI with gcc for architectures: ${jrarchs} ***" echo "*** use FORCE_NATIVE=yes to avoid this and use R settings ***" CFLAGS="" LDFLAGS="" CC="gcc" for a in ${jrarchs}; do CC="${CC} -arch $a"; done fi fi fi ;; *) ;; esac origCFLAGS=$CFLAGS CFLAGS="${CFLAGS} ${R_CFLAGS} ${RINC}" { echo "$as_me:$LINENO: checking whether Rinterface.h exports R_CStackXXX variables" >&5 echo $ECHO_N "checking whether Rinterface.h exports R_CStackXXX variables... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF #define CSTACK_DEFNS #include #include int main(void) { return R_CStackLimit?0:1; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then { echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6; } DEFFLAGS="${DEFFLAGS} -DRIF_HAS_CSTACK" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { echo "$as_me:$LINENO: checking whether Rinterface.h exports R_SignalHandlers" >&5 echo $ECHO_N "checking whether Rinterface.h exports R_SignalHandlers... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF #include #include int main(void) { return R_SignalHandlers; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then { echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6; } DEFFLAGS="${DEFFLAGS} -DRIF_HAS_RSIGHAND" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext CFLAGS=${origCFLAGS} ac_config_files="$ac_config_files src/Makefile" ac_config_files="$ac_config_files Makefile" ac_config_files="$ac_config_files run" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs, see configure's option --config-cache. # It is not useful on other systems. If it contains results you don't # want to keep, you may remove or edit it. # # config.status only pays attention to the cache file if you give it # the --recheck option to rerun configure. # # `ac_cv_env_foo' variables (set or unset) will be overridden when # loading this file, other *unset* `ac_cv_foo' will be assigned the # following values. _ACEOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, we kill variables containing newlines. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. ( for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5 echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( *) $as_unset $ac_var ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space=' '; set) 2>&1` in #( *${as_nl}ac_space=\ *) # `set' does not quote correctly, so add quotes (double-quote # substitution turns \\\\ into \\, and sed turns \\ into \). sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" ;; #( *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) | sed ' /^ac_cv_env_/b end t clear :clear s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ t end s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then test "x$cache_file" != "x/dev/null" && { echo "$as_me:$LINENO: updating cache $cache_file" >&5 echo "$as_me: updating cache $cache_file" >&6;} cat confcache >$cache_file else { echo "$as_me:$LINENO: not updating unwritable cache $cache_file" >&5 echo "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi rm -f confcache test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' DEFS=-DHAVE_CONFIG_H ac_libobjs= ac_ltlibobjs= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' ac_i=`echo "$ac_i" | sed "$ac_script"` # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR # will be set to the directory where LIBOBJS objects are built. ac_libobjs="$ac_libobjs \${LIBOBJDIR}$ac_i\$U.$ac_objext" ac_ltlibobjs="$ac_ltlibobjs \${LIBOBJDIR}$ac_i"'$U.lo' done LIBOBJS=$ac_libobjs LTLIBOBJS=$ac_ltlibobjs : ${CONFIG_STATUS=./config.status} ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" { echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5 echo "$as_me: creating $CONFIG_STATUS" >&6;} cat >$CONFIG_STATUS <<_ACEOF #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. # Compiler output produced by configure, useful for debugging # configure, is in config.log if it exists. debug=false ac_cs_recheck=false ac_cs_silent=false SHELL=\${CONFIG_SHELL-$SHELL} _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF ## --------------------- ## ## M4sh Initialization. ## ## --------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac fi # PATH needs CR # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then echo "#! /bin/sh" >conf$$.sh echo "exit 0" >>conf$$.sh chmod +x conf$$.sh if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then PATH_SEPARATOR=';' else PATH_SEPARATOR=: fi rm -f conf$$.sh fi # Support unset when possible. if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then as_unset=unset else as_unset=false fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) as_nl=' ' IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. case $0 in *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 { (exit 1); exit 1; } fi # Work around bugs in pre-3.0 UWIN ksh. for as_var in ENV MAIL MAILPATH do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. for as_var in \ LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ LC_TELEPHONE LC_TIME do if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then eval $as_var=C; export $as_var else ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var fi done # Required to use basename. if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi # Name of the executable. as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # CDPATH. $as_unset CDPATH as_lineno_1=$LINENO as_lineno_2=$LINENO test "x$as_lineno_1" != "x$as_lineno_2" && test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || { # Create $as_me.lineno as a copy of $as_myself, but with $LINENO # uniformly replaced by the line number. The first 'sed' inserts a # line-number line after each line using $LINENO; the second 'sed' # does the real work. The second script uses 'N' to pair each # line-number line with the line containing $LINENO, and appends # trailing '-' during substitution so that $LINENO is not a special # case at line end. # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the # scripts with optimization help from Paolo Bonzini. Blame Lee # E. McMahon (1931-1989) for sed's syntax. :-) sed -n ' p /[$]LINENO/= ' <$as_myself | sed ' s/[$]LINENO.*/&-/ t lineno b :lineno N :loop s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ t loop s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 { (exit 1); exit 1; }; } # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). . "./$as_me.lineno" # Exit status is that of the last command. exit } if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in -n*) case `echo 'x\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. *) ECHO_C='\c';; esac;; *) ECHO_N='-n';; esac if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir fi echo >conf$$.file if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -p'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -p' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then as_mkdir_p=: else test -d ./-p && rmdir ./-p as_mkdir_p=false fi if test -x / >/dev/null 2>&1; then as_test_x='test -x' else if ls -dL / >/dev/null 2>&1; then as_ls_L_option=L else as_ls_L_option= fi as_test_x=' eval sh -c '\'' if test -d "$1"; then test -d "$1/."; else case $1 in -*)set "./$1";; esac; case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in ???[sx]*):;;*)false;;esac;fi '\'' sh ' fi as_executable_p=$as_test_x # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" exec 6>&1 # Save the log message, to keep $[0] and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" This file was extended by JRI $as_me 0.3, which was generated by GNU Autoconf 2.61. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ on `(hostname || uname -n) 2>/dev/null | sed 1q` " _ACEOF cat >>$CONFIG_STATUS <<_ACEOF # Files that config.status was made for. config_files="$ac_config_files" config_headers="$ac_config_headers" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF ac_cs_usage="\ \`$as_me' instantiates files from templates according to the current configuration. Usage: $0 [OPTIONS] [FILE]... -h, --help print this help, then exit -V, --version print version number and configuration settings, then exit -q, --quiet do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions --file=FILE[:TEMPLATE] instantiate the configuration file FILE --header=FILE[:TEMPLATE] instantiate the configuration header FILE Configuration files: $config_files Configuration headers: $config_headers Report bugs to ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF ac_cs_version="\\ JRI config.status 0.3 configured by $0, generated by GNU Autoconf 2.61, with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" Copyright (C) 2006 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." ac_pwd='$ac_pwd' srcdir='$srcdir' _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF # If no file are specified by the user, then we need to provide default # value. By we need to know if files were specified by the user. ac_need_defaults=: while test $# != 0 do case $1 in --*=*) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; *) ac_option=$1 ac_optarg=$2 ac_shift=shift ;; esac case $ac_option in # Handling of the options. -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) echo "$ac_cs_version"; exit ;; --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift CONFIG_FILES="$CONFIG_FILES $ac_optarg" ac_need_defaults=false;; --header | --heade | --head | --hea ) $ac_shift CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg" ac_need_defaults=false;; --he | --h) # Conflict between --help and --header { echo "$as_me: error: ambiguous option: $1 Try \`$0 --help' for more information." >&2 { (exit 1); exit 1; }; };; --help | --hel | -h ) echo "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; # This is an error. -*) { echo "$as_me: error: unrecognized option: $1 Try \`$0 --help' for more information." >&2 { (exit 1); exit 1; }; } ;; *) ac_config_targets="$ac_config_targets $1" ac_need_defaults=false ;; esac shift done ac_configure_extra_args= if $ac_cs_silent; then exec 6>/dev/null ac_configure_extra_args="$ac_configure_extra_args --silent" fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF if \$ac_cs_recheck; then echo "running CONFIG_SHELL=$SHELL $SHELL $0 "$ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6 CONFIG_SHELL=$SHELL export CONFIG_SHELL exec $SHELL "$0"$ac_configure_args \$ac_configure_extra_args --no-create --no-recursion fi _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF exec 5>>config.log { echo sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX echo "$ac_log" } >&5 _ACEOF cat >>$CONFIG_STATUS <<_ACEOF _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF # Handling of arguments. for ac_config_target in $ac_config_targets do case $ac_config_target in "src/config.h") CONFIG_HEADERS="$CONFIG_HEADERS src/config.h" ;; "src/Makefile") CONFIG_FILES="$CONFIG_FILES src/Makefile" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; "run") CONFIG_FILES="$CONFIG_FILES run" ;; *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 echo "$as_me: error: invalid argument: $ac_config_target" >&2;} { (exit 1); exit 1; }; };; esac done # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely # bizarre bug on SunOS 4.1.3. if $ac_need_defaults; then test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers fi # Have a temporary directory for convenience. Make it in the build tree # simply because there is no reason against having it here, and in addition, # creating and moving files from /tmp can sometimes cause problems. # Hook for its removal unless debugging. # Note that there is a small window in which the directory will not be cleaned: # after its creation but before its name has been assigned to `$tmp'. $debug || { tmp= trap 'exit_status=$? { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status ' 0 trap '{ (exit 1); exit 1; }' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") } || { echo "$me: cannot create a temporary directory in ." >&2 { (exit 1); exit 1; } } # # Set up the sed scripts for CONFIG_FILES section. # # No need to generate the scripts if there are no CONFIG_FILES. # This happens for instance when ./config.status config.h if test -n "$CONFIG_FILES"; then _ACEOF ac_delim='%!_!# ' for ac_last_try in false false false false false :; do cat >conf$$subs.sed <<_ACEOF SHELL!$SHELL$ac_delim PATH_SEPARATOR!$PATH_SEPARATOR$ac_delim PACKAGE_NAME!$PACKAGE_NAME$ac_delim PACKAGE_TARNAME!$PACKAGE_TARNAME$ac_delim PACKAGE_VERSION!$PACKAGE_VERSION$ac_delim PACKAGE_STRING!$PACKAGE_STRING$ac_delim PACKAGE_BUGREPORT!$PACKAGE_BUGREPORT$ac_delim exec_prefix!$exec_prefix$ac_delim prefix!$prefix$ac_delim program_transform_name!$program_transform_name$ac_delim bindir!$bindir$ac_delim sbindir!$sbindir$ac_delim libexecdir!$libexecdir$ac_delim datarootdir!$datarootdir$ac_delim datadir!$datadir$ac_delim sysconfdir!$sysconfdir$ac_delim sharedstatedir!$sharedstatedir$ac_delim localstatedir!$localstatedir$ac_delim includedir!$includedir$ac_delim oldincludedir!$oldincludedir$ac_delim docdir!$docdir$ac_delim infodir!$infodir$ac_delim htmldir!$htmldir$ac_delim dvidir!$dvidir$ac_delim pdfdir!$pdfdir$ac_delim psdir!$psdir$ac_delim libdir!$libdir$ac_delim localedir!$localedir$ac_delim mandir!$mandir$ac_delim DEFS!$DEFS$ac_delim ECHO_C!$ECHO_C$ac_delim ECHO_N!$ECHO_N$ac_delim ECHO_T!$ECHO_T$ac_delim LIBS!$LIBS$ac_delim build_alias!$build_alias$ac_delim host_alias!$host_alias$ac_delim target_alias!$target_alias$ac_delim build!$build$ac_delim build_cpu!$build_cpu$ac_delim build_vendor!$build_vendor$ac_delim build_os!$build_os$ac_delim host!$host$ac_delim host_cpu!$host_cpu$ac_delim host_vendor!$host_vendor$ac_delim host_os!$host_os$ac_delim R_HOME!$R_HOME$ac_delim R_SHARE_DIR!$R_SHARE_DIR$ac_delim R_DOC_DIR!$R_DOC_DIR$ac_delim R_INCLUDE_DIR!$R_INCLUDE_DIR$ac_delim CC!$CC$ac_delim CFLAGS!$CFLAGS$ac_delim LDFLAGS!$LDFLAGS$ac_delim CPPFLAGS!$CPPFLAGS$ac_delim ac_ct_CC!$ac_ct_CC$ac_delim EXEEXT!$EXEEXT$ac_delim OBJEXT!$OBJEXT$ac_delim CPP!$CPP$ac_delim GREP!$GREP$ac_delim EGREP!$EGREP$ac_delim JAVA_PROG!$JAVA_PROG$ac_delim JAVAC!$JAVAC$ac_delim JAVAH!$JAVAH$ac_delim JAR!$JAR$ac_delim JAVA_HOME!$JAVA_HOME$ac_delim JAVA_LD_PATH!$JAVA_LD_PATH$ac_delim JAVA_LIBS!$JAVA_LIBS$ac_delim JAVA_INC!$JAVA_INC$ac_delim JAVA_CFLAGS!$JAVA_CFLAGS$ac_delim JNILD!$JNILD$ac_delim JNISO!$JNISO$ac_delim JNIPREFIX!$JNIPREFIX$ac_delim CPICF!$CPICF$ac_delim RINC!$RINC$ac_delim RLD!$RLD$ac_delim DEFFLAGS!$DEFFLAGS$ac_delim LIBOBJS!$LIBOBJS$ac_delim LTLIBOBJS!$LTLIBOBJS$ac_delim _ACEOF if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 77; then break elif $ac_last_try; then { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 echo "$as_me: error: could not make $CONFIG_STATUS" >&2;} { (exit 1); exit 1; }; } else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done ac_eof=`sed -n '/^CEOF[0-9]*$/s/CEOF/0/p' conf$$subs.sed` if test -n "$ac_eof"; then ac_eof=`echo "$ac_eof" | sort -nru | sed 1q` ac_eof=`expr $ac_eof + 1` fi cat >>$CONFIG_STATUS <<_ACEOF cat >"\$tmp/subs-1.sed" <<\CEOF$ac_eof /@[a-zA-Z_][a-zA-Z_0-9]*@/!b end _ACEOF sed ' s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g s/^/s,@/; s/!/@,|#_!!_#|/ :n t n s/'"$ac_delim"'$/,g/; t s/$/\\/; p N; s/^.*\n//; s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g; b n ' >>$CONFIG_STATUS >$CONFIG_STATUS <<_ACEOF :end s/|#_!!_#|//g CEOF$ac_eof _ACEOF # VPATH may cause trouble with some makes, so we remove $(srcdir), # ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=/{ s/:*\$(srcdir):*/:/ s/:*\${srcdir}:*/:/ s/:*@srcdir@:*/:/ s/^\([^=]*=[ ]*\):*/\1/ s/:*$// s/^[^=]*=[ ]*$// }' fi cat >>$CONFIG_STATUS <<\_ACEOF fi # test -n "$CONFIG_FILES" for ac_tag in :F $CONFIG_FILES :H $CONFIG_HEADERS do case $ac_tag in :[FHLC]) ac_mode=$ac_tag; continue;; esac case $ac_mode$ac_tag in :[FHL]*:*);; :L* | :C*:*) { { echo "$as_me:$LINENO: error: Invalid tag $ac_tag." >&5 echo "$as_me: error: Invalid tag $ac_tag." >&2;} { (exit 1); exit 1; }; };; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac ac_save_IFS=$IFS IFS=: set x $ac_tag IFS=$ac_save_IFS shift ac_file=$1 shift case $ac_mode in :L) ac_source=$1;; :[FH]) ac_file_inputs= for ac_f do case $ac_f in -) ac_f="$tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. test -f "$ac_f" || case $ac_f in [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || { { echo "$as_me:$LINENO: error: cannot find input file: $ac_f" >&5 echo "$as_me: error: cannot find input file: $ac_f" >&2;} { (exit 1); exit 1; }; };; esac ac_file_inputs="$ac_file_inputs $ac_f" done # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ configure_input="Generated from "`IFS=: echo $* | sed 's|^[^:]*/||;s|:[^:]*/|, |g'`" by configure." if test x"$ac_file" != x-; then configure_input="$ac_file. $configure_input" { echo "$as_me:$LINENO: creating $ac_file" >&5 echo "$as_me: creating $ac_file" >&6;} fi case $ac_tag in *:-:* | *:-) cat >"$tmp/stdin";; esac ;; esac ac_dir=`$as_dirname -- "$ac_file" || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` { as_dir="$ac_dir" case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || { { echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5 echo "$as_me: error: cannot create directory $as_dir" >&2;} { (exit 1); exit 1; }; }; } ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,/..,g;s,/,,'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix case $ac_mode in :F) # # CONFIG_FILE # _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF # If the template does not know about datarootdir, expand it. # FIXME: This hack should be removed a few years after 2.60. ac_datarootdir_hack=; ac_datarootdir_seen= case `sed -n '/datarootdir/ { p q } /@datadir@/p /@docdir@/p /@infodir@/p /@localedir@/p /@mandir@/p ' $ac_file_inputs` in *datarootdir*) ac_datarootdir_seen=yes;; *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) { echo "$as_me:$LINENO: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} _ACEOF cat >>$CONFIG_STATUS <<_ACEOF ac_datarootdir_hack=' s&@datadir@&$datadir&g s&@docdir@&$docdir&g s&@infodir@&$infodir&g s&@localedir@&$localedir&g s&@mandir@&$mandir&g s&\\\${datarootdir}&$datarootdir&g' ;; esac _ACEOF # Neutralize VPATH when `$srcdir' = `.'. # Shell code in configure.ac might set extrasub. # FIXME: do we really want to maintain this feature? cat >>$CONFIG_STATUS <<_ACEOF sed "$ac_vpsub $extrasub _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b s&@configure_input@&$configure_input&;t t s&@top_builddir@&$ac_top_builddir_sub&;t t s&@srcdir@&$ac_srcdir&;t t s&@abs_srcdir@&$ac_abs_srcdir&;t t s&@top_srcdir@&$ac_top_srcdir&;t t s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t s&@builddir@&$ac_builddir&;t t s&@abs_builddir@&$ac_abs_builddir&;t t s&@abs_top_builddir@&$ac_abs_top_builddir&;t t $ac_datarootdir_hack " $ac_file_inputs | sed -f "$tmp/subs-1.sed" >$tmp/out test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } && { echo "$as_me:$LINENO: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined." >&5 echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined." >&2;} rm -f "$tmp/stdin" case $ac_file in -) cat "$tmp/out"; rm -f "$tmp/out";; *) rm -f "$ac_file"; mv "$tmp/out" $ac_file;; esac ;; :H) # # CONFIG_HEADER # _ACEOF # Transform confdefs.h into a sed script `conftest.defines', that # substitutes the proper values into config.h.in to produce config.h. rm -f conftest.defines conftest.tail # First, append a space to every undef/define line, to ease matching. echo 's/$/ /' >conftest.defines # Then, protect against being on the right side of a sed subst, or in # an unquoted here document, in config.status. If some macros were # called several times there might be several #defines for the same # symbol, which is useless. But do not sort them, since the last # AC_DEFINE must be honored. ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* # These sed commands are passed to sed as "A NAME B PARAMS C VALUE D", where # NAME is the cpp macro being defined, VALUE is the value it is being given. # PARAMS is the parameter list in the macro definition--in most cases, it's # just an empty string. ac_dA='s,^\\([ #]*\\)[^ ]*\\([ ]*' ac_dB='\\)[ (].*,\\1define\\2' ac_dC=' ' ac_dD=' ,' uniq confdefs.h | sed -n ' t rset :rset s/^[ ]*#[ ]*define[ ][ ]*// t ok d :ok s/[\\&,]/\\&/g s/^\('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/ '"$ac_dA"'\1'"$ac_dB"'\2'"${ac_dC}"'\3'"$ac_dD"'/p s/^\('"$ac_word_re"'\)[ ]*\(.*\)/'"$ac_dA"'\1'"$ac_dB$ac_dC"'\2'"$ac_dD"'/p ' >>conftest.defines # Remove the space that was appended to ease matching. # Then replace #undef with comments. This is necessary, for # example, in the case of _POSIX_SOURCE, which is predefined and required # on some systems where configure will not decide to define it. # (The regexp can be short, since the line contains either #define or #undef.) echo 's/ $// s,^[ #]*u.*,/* & */,' >>conftest.defines # Break up conftest.defines: ac_max_sed_lines=50 # First sed command is: sed -f defines.sed $ac_file_inputs >"$tmp/out1" # Second one is: sed -f defines.sed "$tmp/out1" >"$tmp/out2" # Third one will be: sed -f defines.sed "$tmp/out2" >"$tmp/out1" # et cetera. ac_in='$ac_file_inputs' ac_out='"$tmp/out1"' ac_nxt='"$tmp/out2"' while : do # Write a here document: cat >>$CONFIG_STATUS <<_ACEOF # First, check the format of the line: cat >"\$tmp/defines.sed" <<\\CEOF /^[ ]*#[ ]*undef[ ][ ]*$ac_word_re[ ]*\$/b def /^[ ]*#[ ]*define[ ][ ]*$ac_word_re[( ]/b def b :def _ACEOF sed ${ac_max_sed_lines}q conftest.defines >>$CONFIG_STATUS echo 'CEOF sed -f "$tmp/defines.sed"' "$ac_in >$ac_out" >>$CONFIG_STATUS ac_in=$ac_out; ac_out=$ac_nxt; ac_nxt=$ac_in sed 1,${ac_max_sed_lines}d conftest.defines >conftest.tail grep . conftest.tail >/dev/null || break rm -f conftest.defines mv conftest.tail conftest.defines done rm -f conftest.defines conftest.tail echo "ac_result=$ac_in" >>$CONFIG_STATUS cat >>$CONFIG_STATUS <<\_ACEOF if test x"$ac_file" != x-; then echo "/* $configure_input */" >"$tmp/config.h" cat "$ac_result" >>"$tmp/config.h" if diff $ac_file "$tmp/config.h" >/dev/null 2>&1; then { echo "$as_me:$LINENO: $ac_file is unchanged" >&5 echo "$as_me: $ac_file is unchanged" >&6;} else rm -f $ac_file mv "$tmp/config.h" $ac_file fi else echo "/* $configure_input */" cat "$ac_result" fi rm -f "$tmp/out12" ;; esac case $ac_file$ac_mode in "run":F) chmod +x run ;; esac done # for ac_tag { (exit 0); exit 0; } _ACEOF chmod +x $CONFIG_STATUS ac_clean_files=$ac_clean_files_save # configure is writing to config.log, and then calls config.status. # config.status does its own redirection, appending to config.log. # Unfortunately, on DOS this fails, as config.log is still kept open # by configure, so config.status won't be able to write to it; its # output is simply discarded. So we exec the FD to /dev/null, # effectively closing config.log, so it can be properly (re)opened and # appended to by config.status. When coming back to configure, we # need to make the FD available again. if test "$no_create" != yes; then ac_cs_success=: ac_config_status_args= test "$silent" = yes && ac_config_status_args="$ac_config_status_args --quiet" exec 5>/dev/null $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. $ac_cs_success || { (exit 1); exit 1; } fi rJava/jri/configure.win0000644000176200001440000000203712256051760014607 0ustar liggesusers#!/bin/sh # if CONFIGURED is set, then we don't attempt to run findjava # (useful when building inside rJava) if [ -z "$CONFIGURED" ]; then echo "Generate Windows-specific files (src/jvm-w32) ..." make -C src/win32 if [ $? != 0 ]; then exit 1 fi echo "Find Java..." # findjava honors JAVA_HOME environment variable, so we can safely overwite it if [ -e src/win32/findjava.exe ]; then JAVA_HOME=`src/win32/findjava -s -f` R_HOME=`src/win32/findjava -R -s -f` fi fi if [ x$JAVA_HOME = x ]; then echo "ERROR: cannot find Java Development Kit." >&2 echo " Please set JAVA_HOME to specify its location manually" >&2 exit 1 fi if [ x$R_HOME = x ]; then echo "ERROR: cannot find R. Please set R_HOME correspondingly." >&2 exit 1 fi echo " JAVA_HOME=$JAVA_HOME" echo " R_HOME=$R_HOME" echo "JAVAHOME:=$JAVA_HOME" > src/Makefile.wconf echo "RHOME:=$R_HOME" >> src/Makefile.wconf echo "Creating Makefiles ..." cp Makefile.win Makefile cp src/Makefile.win src/Makefile echo "Configuration done." rJava/jri/RList.java0000644000176200001440000001043012256051760014003 0ustar liggesuserspackage org.rosuda.JRI; // JRclient library - client interface to Rserve, see http://www.rosuda.org/Rserve/ // Copyright (C) 2004 Simon Urbanek // --- for licensing information see LICENSE file in the original JRclient distribution --- import java.util.*; /** implementation of R-lists
This is rather preliminary and may change in future since it's not really proper. The point is that the parser tries to interpret lists to be of the form entry=value, where entry is stored in the "head" part, and value is stored in the "body" part. Then using {@link #at(String)} it is possible to fetch "body" for a specific "head". The terminology used is partly from hash fields - "keys" are the elements in "head" and values are in "body" (see {@link #keys}).

On the other hand, R uses lists to store complex internal structures, which are not parsed according to the structure - in that case "head" and "body" have to be evaluated separately according to their meaning in that context. @version $Id: RList.java 2720 2007-03-15 17:35:42Z urbanek $ */ public class RList extends Object { /** xpressions containing head, body and tag. The terminology is a bit misleading (for historical reasons) - head corresponds to CAR, body to CDR and finally tag is TAG. */ public REXP head, body, tag; /** cached keys (from TAG) */ String[] keys = null; /** cached values(from CAR) */ REXP[] values = null; /** flag denoting whether we need to re-fetch the cached values.

the current assumption is that the contents don't change after first retrieval - there is currently no recursive check! */ boolean dirtyCache = true; /** constructs an empty list */ public RList() { head=body=tag=null; } /** fake constructor to keep compatibility with Rserve (for now, will be gone soon) */ public RList(RVector v) { Vector n = v.getNames(); if (n != null) { keys = new String[n.size()]; n.copyInto(keys); } values=new REXP[v.size()]; v.copyInto(values); dirtyCache=false; // head,tail,tag are all invalid! } /** constructs an initialized list @param h head xpression @param b body xpression */ public RList(REXP h, REXP b) { head=h; body=b; tag=null; } /** constructs an initialized list @param h head xpression (CAR) @param t tag xpression (TAG) @param b body/tail xpression (CDR) */ public RList(REXP h, REXP t, REXP b) { head=h; body=b; tag=t; } /** get head xpression (CAR) @return head xpression */ public REXP getHead() { return head; } /** get body xpression (CDR) @return body xpression */ public REXP getBody() { return body; } /** get tag xpression @return tag xpression */ public REXP getTag() { return tag; } /** internal function that updates cached vectors @return true if the conversion was successful */ boolean updateVec() { if (!dirtyCache) return true; // we do NOT run it recursively, because in most cases only once instance is asked RList cur = this; int l = 0; while (cur!=null) { l++; REXP bd = cur.getBody(); cur = (bd==null)?null:bd.asList(); } keys=new String[l]; values=new REXP[l]; cur = this; l=0; while (cur != null) { REXP x = cur.getTag(); if (x!=null) keys[l]=x.asSymbolName(); values[l] = cur.getHead(); REXP bd = cur.getBody(); cur = (bd==null)?null:bd.asList(); l++; } dirtyCache=false; return true; } /** get xpression given a key @param v key @return xpression which corresponds to the given key or null if list is not standartized or key not found */ public REXP at(String v) { if (!updateVec() || keys==null || values==null) return null; int i=0; while (inull if list is not standartized or if index out of bounds */ public REXP at(int i) { return (!updateVec() || values==null || i<0 || i>=values.length)?null:values[i]; } /** returns all keys of the list @return array containing all keys or null if list is not standartized */ public String[] keys() { return (!updateVec())?null:this.keys; } } rJava/jri/tools/0000755000176200001440000000000012256051760013245 5ustar liggesusersrJava/jri/tools/getsp.java0000644000176200001440000000160212256051760015231 0ustar liggesuserspublic class getsp { public static void main(String[] args) { if (args!=null && args.length>0) { if (args[0].compareTo("-test")==0) { System.out.println("Test1234OK"); } else if (args[0].compareTo("-libs")==0) { String prefix="-L"; if (args.length>1) prefix=args[1]; String lp=System.getProperty("java.library.path"); // we're not using StringTokenizer in case the JVM is very crude int i=0,j,k=0; String r=null; String pss=System.getProperty("path.separator"); char ps=':'; if (pss!=null && pss.length()>0) ps=pss.charAt(0); j=lp.length(); while (i<=j) { if (i==j || lp.charAt(i)==ps) { String lib=lp.substring(k,i); k=i+1; if (lib.compareTo(".")!=0) r=(r==null)?(prefix+lib):(r+" "+prefix+lib); } i++; } if (r!=null) System.out.println(r); } else System.out.println(System.getProperty(args[0])); } } } rJava/jri/tools/getsp.class0000644000176200001440000000251412256051760015420 0ustar liggesusers-U'3456@GPEHIJKL       ! " # $ % & 7* 71 A0 B+ C. D/ M( O< Q1 R, S) T- ()I()Ljava/lang/String;()V(I)C(II)Ljava/lang/String;&(Ljava/lang/Object;)Ljava/lang/String;(Ljava/lang/String;)I&(Ljava/lang/String;)Ljava/lang/String;,(Ljava/lang/String;)Ljava/lang/StringBuffer;(Ljava/lang/String;)V([Ljava/lang/String;)V-L-libs-test.Code ConstantValue ExceptionsLineNumberTableLjava/io/PrintStream;LocalVariables SGILineNumber SourceFile Test1234OKappendcharAt compareTo getPropertygetsp getsp.javajava.library.pathjava/io/PrintStreamjava/lang/Objectjava/lang/Stringjava/lang/StringBufferjava/lang/Systemlengthmainoutpath.separatorprintln substringtoStringvalueOf!  N28n ***2 *2L**2LM>6:::6 6,6h ,U,: `6 = Y+  Y+ :*2;j (+ 5 ; @ CJNcil|>7*8*;>?F>rJava/jri/tools/install-sh0000755000176200001440000001270112256051760015252 0ustar liggesusers#!/bin/sh # # install - install a program, script, or datafile # This comes from X11R5 (mit/util/scripts/install.sh). # # Copyright 1991 by the Massachusetts Institute of Technology # # Permission to use, copy, modify, distribute, and sell this software and its # documentation for any purpose is hereby granted without fee, provided that # the above copyright notice appear in all copies and that both that # copyright notice and this permission notice appear in supporting # documentation, and that the name of M.I.T. not be used in advertising or # publicity pertaining to distribution of the software without specific, # written prior permission. M.I.T. makes no representations about the # suitability of this software for any purpose. It is provided "as is" # without express or implied warranty. # # Calling this script install-sh is preferred over install.sh, to prevent # `make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. It can only install one file at a time, a restriction # shared with many OS's install programs. # set DOITPROG to echo to test this script # Don't use :- since 4.3BSD and earlier shells don't like it. doit="${DOITPROG-}" # put in absolute paths if you don't have them in your path; or use env. vars. mvprog="${MVPROG-mv}" cpprog="${CPPROG-cp}" chmodprog="${CHMODPROG-chmod}" chownprog="${CHOWNPROG-chown}" chgrpprog="${CHGRPPROG-chgrp}" stripprog="${STRIPPROG-strip}" rmprog="${RMPROG-rm}" mkdirprog="${MKDIRPROG-mkdir}" transformbasename="" transform_arg="" instcmd="$mvprog" chmodcmd="$chmodprog 0755" chowncmd="" chgrpcmd="" stripcmd="" rmcmd="$rmprog -f" mvcmd="$mvprog" src="" dst="" dir_arg="" while [ x"$1" != x ]; do case $1 in -c) instcmd="$cpprog" shift continue;; -d) dir_arg=true shift continue;; -m) chmodcmd="$chmodprog $2" shift shift continue;; -o) chowncmd="$chownprog $2" shift shift continue;; -g) chgrpcmd="$chgrpprog $2" shift shift continue;; -s) stripcmd="$stripprog" shift continue;; -t=*) transformarg=`echo $1 | sed 's/-t=//'` shift continue;; -b=*) transformbasename=`echo $1 | sed 's/-b=//'` shift continue;; *) if [ x"$src" = x ] then src=$1 else # this colon is to work around a 386BSD /bin/sh bug : dst=$1 fi shift continue;; esac done if [ x"$src" = x ] then echo "install: no input file specified" exit 1 else : fi if [ x"$dir_arg" != x ]; then dst=$src src="" if [ -d $dst ]; then instcmd=: chmodcmd="" else instcmd=$mkdirprog fi else # Waiting for this to be detected by the "$instcmd $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if [ -f "$src" ] || [ -d "$src" ] then : else echo "install: $src does not exist" exit 1 fi if [ x"$dst" = x ] then echo "install: no destination specified" exit 1 else : fi # If destination is a directory, append the input filename; if your system # does not like double slashes in filenames, you may need to add some logic if [ -d $dst ] then dst="$dst"/`basename $src` else : fi fi ## this sed command emulates the dirname command dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` # Make sure that the destination directory exists. # this part is taken from Noah Friedman's mkinstalldirs script # Skip lots of stat calls in the usual case. if [ ! -d "$dstdir" ]; then defaultIFS=' ' IFS="${IFS-${defaultIFS}}" oIFS="${IFS}" # Some sh's can't handle IFS=/ for some reason. IFS='%' set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` IFS="${oIFS}" pathcomp='' while [ $# -ne 0 ] ; do pathcomp="${pathcomp}${1}" shift if [ ! -d "${pathcomp}" ] ; then $mkdirprog "${pathcomp}" else : fi pathcomp="${pathcomp}/" done fi if [ x"$dir_arg" != x ] then $doit $instcmd $dst && if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else : ; fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else : ; fi && if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else : ; fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else : ; fi else # If we're going to rename the final executable, determine the name now. if [ x"$transformarg" = x ] then dstfile=`basename $dst` else dstfile=`basename $dst $transformbasename | sed $transformarg`$transformbasename fi # don't allow the sed command to completely eliminate the filename if [ x"$dstfile" = x ] then dstfile=`basename $dst` else : fi # Make a temp file name in the proper directory. dsttmp=$dstdir/#inst.$$# # Move or copy the file name to the temp name $doit $instcmd $src $dsttmp && trap "rm -f ${dsttmp}" 0 && # and set any options; do chmod last to preserve setuid bits # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $instcmd $src $dsttmp" command. if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else :;fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else :;fi && if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else :;fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else :;fi && # Now rename the file to the real destination. $doit $rmcmd -f $dstdir/$dstfile && $doit $mvcmd $dsttmp $dstdir/$dstfile fi && exit 0 rJava/jri/tools/mkinstalldirs0000755000176200001440000000341112256051760016052 0ustar liggesusers#! /bin/sh # mkinstalldirs --- make directory hierarchy # Author: Noah Friedman # Created: 1993-05-16 # Public domain errstatus=0 dirmode="" usage="\ Usage: mkinstalldirs [-h] [--help] [-m mode] dir ..." # process command line arguments while test $# -gt 0 ; do case "${1}" in -h | --help | --h* ) # -h for help echo "${usage}" 1>&2; exit 0 ;; -m ) # -m PERM arg shift test $# -eq 0 && { echo "${usage}" 1>&2; exit 1; } dirmode="${1}" shift ;; -- ) shift; break ;; # stop option processing -* ) echo "${usage}" 1>&2; exit 1 ;; # unknown option * ) break ;; # first non-opt arg esac done for file do if test -d "$file"; then shift else break fi done case $# in 0) exit 0 ;; esac case $dirmode in '') if mkdir -p -- . 2>/dev/null; then echo "mkdir -p -- $*" exec mkdir -p -- "$@" fi ;; *) if mkdir -m "$dirmode" -p -- . 2>/dev/null; then echo "mkdir -m $dirmode -p -- $*" exec mkdir -m "$dirmode" -p -- "$@" fi ;; esac for file do set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` shift pathcomp= for d do pathcomp="$pathcomp$d" case "$pathcomp" in -* ) pathcomp=./$pathcomp ;; esac if test ! -d "$pathcomp"; then echo "mkdir $pathcomp" mkdir "$pathcomp" || lasterr=$? if test ! -d "$pathcomp"; then errstatus=$lasterr else if test ! -z "$dirmode"; then echo "chmod $dirmode $pathcomp" lasterr="" chmod "$dirmode" "$pathcomp" || lasterr=$? if test ! -z "$lasterr"; then errstatus=$lasterr fi fi fi fi pathcomp="$pathcomp/" done done exit $errstatus # Local Variables: # mode: shell-script # sh-indentation: 3 # End: # mkinstalldirs ends here rJava/jri/tools/config.guess0000755000176200001440000011544312256051760015575 0ustar liggesusers#! /bin/sh # Attempt to guess a canonical system name. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, # 2000, 2001, 2002 Free Software Foundation, Inc. timestamp='2002-07-23' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Originally written by Per Bothner . # Please send patches to . Submit a context # diff and a properly formatted ChangeLog entry. # # This script attempts to guess a canonical system name similar to # config.sub. If it succeeds, it prints the system name on stdout, and # exits with 0. Otherwise, it exits with 1. # # The plan is that this can be called by configure scripts if you # don't specify an explicit build system type. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] Output the configuration name of the system \`$me' is run on. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit 0 ;; --version | -v ) echo "$version" ; exit 0 ;; --help | --h* | -h ) echo "$usage"; exit 0 ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" >&2 exit 1 ;; * ) break ;; esac done if test $# != 0; then echo "$me: too many arguments$help" >&2 exit 1 fi trap 'exit 1' 1 2 15 # CC_FOR_BUILD -- compiler used by this script. Note that the use of a # compiler to aid in system detection is discouraged as it requires # temporary files to be created and, as you can see below, it is a # headache to deal with in a portable fashion. # Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still # use `HOST_CC' if defined, but it is deprecated. # This shell variable is my proudest work .. or something. --bje set_cc_for_build='tmpdir=${TMPDIR-/tmp}/config-guess-$$ ; (old=`umask` && umask 077 && mkdir $tmpdir && umask $old && unset old) || (echo "$me: cannot create $tmpdir" >&2 && exit 1) ; dummy=$tmpdir/dummy ; files="$dummy.c $dummy.o $dummy.rel $dummy" ; trap '"'"'rm -f $files; rmdir $tmpdir; exit 1'"'"' 1 2 15 ; case $CC_FOR_BUILD,$HOST_CC,$CC in ,,) echo "int x;" > $dummy.c ; for c in cc gcc c89 c99 ; do if ($c $dummy.c -c -o $dummy.o) >/dev/null 2>&1 ; then CC_FOR_BUILD="$c"; break ; fi ; done ; rm -f $files ; if test x"$CC_FOR_BUILD" = x ; then CC_FOR_BUILD=no_compiler_found ; fi ;; ,,*) CC_FOR_BUILD=$CC ;; ,*,*) CC_FOR_BUILD=$HOST_CC ;; esac ; unset files' # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 1994-08-24) if (test -f /.attbin/uname) >/dev/null 2>&1 ; then PATH=$PATH:/.attbin ; export PATH fi UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown # Note: order is significant - the case branches are not exclusive. case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently # switched to ELF, *-*-netbsd* would select the old # object file format. This provides both forward # compatibility and a consistent mechanism for selecting the # object file format. # # Note: NetBSD doesn't particularly care about the vendor # portion of the name. We always set it to "unknown". sysctl="sysctl -n hw.machine_arch" UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ /usr/sbin/$sysctl 2>/dev/null || echo unknown)` case "${UNAME_MACHINE_ARCH}" in armeb) machine=armeb-unknown ;; arm*) machine=arm-unknown ;; sh3el) machine=shl-unknown ;; sh3eb) machine=sh-unknown ;; *) machine=${UNAME_MACHINE_ARCH}-unknown ;; esac # The Operating System including object format, if it has switched # to ELF recently, or will in the future. case "${UNAME_MACHINE_ARCH}" in arm*|i386|m68k|ns32k|sh3*|sparc|vax) eval $set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep __ELF__ >/dev/null then # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). # Return netbsd for either. FIX? os=netbsd else os=netbsdelf fi ;; *) os=netbsd ;; esac # The OS release release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. echo "${machine}-${os}${release}" exit 0 ;; amiga:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; arc:OpenBSD:*:*) echo mipsel-unknown-openbsd${UNAME_RELEASE} exit 0 ;; hp300:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; mac68k:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; macppc:OpenBSD:*:*) echo powerpc-unknown-openbsd${UNAME_RELEASE} exit 0 ;; mvme68k:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; mvme88k:OpenBSD:*:*) echo m88k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; mvmeppc:OpenBSD:*:*) echo powerpc-unknown-openbsd${UNAME_RELEASE} exit 0 ;; pmax:OpenBSD:*:*) echo mipsel-unknown-openbsd${UNAME_RELEASE} exit 0 ;; sgi:OpenBSD:*:*) echo mipseb-unknown-openbsd${UNAME_RELEASE} exit 0 ;; sun3:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; wgrisc:OpenBSD:*:*) echo mipsel-unknown-openbsd${UNAME_RELEASE} exit 0 ;; *:OpenBSD:*:*) echo ${UNAME_MACHINE}-unknown-openbsd${UNAME_RELEASE} exit 0 ;; alpha:OSF1:*:*) if test $UNAME_RELEASE = "V4.0"; then UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` fi # A Vn.n version is a released version. # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. eval $set_cc_for_build cat <$dummy.s .data \$Lformat: .byte 37,100,45,37,120,10,0 # "%d-%x\n" .text .globl main .align 4 .ent main main: .frame \$30,16,\$26,0 ldgp \$29,0(\$27) .prologue 1 .long 0x47e03d80 # implver \$0 lda \$2,-1 .long 0x47e20c21 # amask \$2,\$1 lda \$16,\$Lformat mov \$0,\$17 not \$1,\$18 jsr \$26,printf ldgp \$29,0(\$26) mov 0,\$16 jsr \$26,exit .end main EOF $CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null if test "$?" = 0 ; then case `$dummy` in 0-0) UNAME_MACHINE="alpha" ;; 1-0) UNAME_MACHINE="alphaev5" ;; 1-1) UNAME_MACHINE="alphaev56" ;; 1-101) UNAME_MACHINE="alphapca56" ;; 2-303) UNAME_MACHINE="alphaev6" ;; 2-307) UNAME_MACHINE="alphaev67" ;; 2-1307) UNAME_MACHINE="alphaev68" ;; 3-1307) UNAME_MACHINE="alphaev7" ;; esac fi rm -f $dummy.s $dummy && rmdir $tmpdir echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` exit 0 ;; Alpha\ *:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # Should we change UNAME_MACHINE based on the output of uname instead # of the specific Alpha model? echo alpha-pc-interix exit 0 ;; 21064:Windows_NT:50:3) echo alpha-dec-winnt3.5 exit 0 ;; Amiga*:UNIX_System_V:4.0:*) echo m68k-unknown-sysv4 exit 0;; *:[Aa]miga[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-amigaos exit 0 ;; *:[Mm]orph[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-morphos exit 0 ;; *:OS/390:*:*) echo i370-ibm-openedition exit 0 ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix${UNAME_RELEASE} exit 0;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) echo hppa1.1-hitachi-hiuxmpp exit 0;; Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. if test "`(/bin/universe) 2>/dev/null`" = att ; then echo pyramid-pyramid-sysv3 else echo pyramid-pyramid-bsd fi exit 0 ;; NILE*:*:*:dcosx) echo pyramid-pyramid-svr4 exit 0 ;; DRS?6000:UNIX_SV:4.2*:7*) case `/usr/bin/uname -p` in sparc) echo sparc-icl-nx7 && exit 0 ;; esac ;; sun4H:SunOS:5.*:*) echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; i86pc:SunOS:5.*:*) echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; sun4*:SunOS:*:*) case "`/usr/bin/arch -k`" in Series*|S4*) UNAME_RELEASE=`uname -v` ;; esac # Japanese Language versions have a version number like `4.1.3-JL'. echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` exit 0 ;; sun3*:SunOS:*:*) echo m68k-sun-sunos${UNAME_RELEASE} exit 0 ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 case "`/bin/arch`" in sun3) echo m68k-sun-sunos${UNAME_RELEASE} ;; sun4) echo sparc-sun-sunos${UNAME_RELEASE} ;; esac exit 0 ;; aushp:SunOS:*:*) echo sparc-auspex-sunos${UNAME_RELEASE} exit 0 ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not # "atarist" or "atariste" at least should have a processor # > m68000). The system name ranges from "MiNT" over "FreeMiNT" # to the lowercase version "mint" (or "freemint"). Finally # the system name "TOS" denotes a system which is actually not # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit 0 ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit 0 ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit 0 ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) echo m68k-milan-mint${UNAME_RELEASE} exit 0 ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) echo m68k-hades-mint${UNAME_RELEASE} exit 0 ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) echo m68k-unknown-mint${UNAME_RELEASE} exit 0 ;; powerpc:machten:*:*) echo powerpc-apple-machten${UNAME_RELEASE} exit 0 ;; RISC*:Mach:*:*) echo mips-dec-mach_bsd4.3 exit 0 ;; RISC*:ULTRIX:*:*) echo mips-dec-ultrix${UNAME_RELEASE} exit 0 ;; VAX*:ULTRIX*:*:*) echo vax-dec-ultrix${UNAME_RELEASE} exit 0 ;; 2020:CLIX:*:* | 2430:CLIX:*:*) echo clipper-intergraph-clix${UNAME_RELEASE} exit 0 ;; mips:*:*:UMIPS | mips:*:*:RISCos) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #ifdef __cplusplus #include /* for printf() prototype */ int main (int argc, char *argv[]) { #else int main (argc, argv) int argc; char *argv[]; { #endif #if defined (host_mips) && defined (MIPSEB) #if defined (SYSTYPE_SYSV) printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_SVR4) printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); #endif #endif exit (-1); } EOF $CC_FOR_BUILD $dummy.c -o $dummy \ && $dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \ && rm -f $dummy.c $dummy && rmdir $tmpdir && exit 0 rm -f $dummy.c $dummy && rmdir $tmpdir echo mips-mips-riscos${UNAME_RELEASE} exit 0 ;; Motorola:PowerMAX_OS:*:*) echo powerpc-motorola-powermax exit 0 ;; Night_Hawk:*:*:PowerMAX_OS) echo powerpc-harris-powermax exit 0 ;; Night_Hawk:Power_UNIX:*:*) echo powerpc-harris-powerunix exit 0 ;; m88k:CX/UX:7*:*) echo m88k-harris-cxux7 exit 0 ;; m88k:*:4*:R4*) echo m88k-motorola-sysv4 exit 0 ;; m88k:*:3*:R3*) echo m88k-motorola-sysv3 exit 0 ;; AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures UNAME_PROCESSOR=`/usr/bin/uname -p` if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] then if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ [ ${TARGET_BINARY_INTERFACE}x = x ] then echo m88k-dg-dgux${UNAME_RELEASE} else echo m88k-dg-dguxbcs${UNAME_RELEASE} fi else echo i586-dg-dgux${UNAME_RELEASE} fi exit 0 ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) echo m88k-dolphin-sysv3 exit 0 ;; M88*:*:R3*:*) # Delta 88k system running SVR3 echo m88k-motorola-sysv3 exit 0 ;; XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) echo m88k-tektronix-sysv3 exit 0 ;; Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) echo m68k-tektronix-bsd exit 0 ;; *:IRIX*:*:*) echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` exit 0 ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id exit 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX ' i*86:AIX:*:*) echo i386-ibm-aix exit 0 ;; ia64:AIX:*:*) if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} exit 0 ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include main() { if (!__power_pc()) exit(1); puts("powerpc-ibm-aix3.2.5"); exit(0); } EOF $CC_FOR_BUILD $dummy.c -o $dummy && $dummy && rm -f $dummy.c $dummy && rmdir $tmpdir && exit 0 rm -f $dummy.c $dummy && rmdir $tmpdir echo rs6000-ibm-aix3.2.5 elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then echo rs6000-ibm-aix3.2.4 else echo rs6000-ibm-aix3.2 fi exit 0 ;; *:AIX:*:[45]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 else IBM_ARCH=powerpc fi if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${IBM_ARCH}-ibm-aix${IBM_REV} exit 0 ;; *:AIX:*:*) echo rs6000-ibm-aix exit 0 ;; ibmrt:4.4BSD:*|romp-ibm:BSD:*) echo romp-ibm-bsd4.4 exit 0 ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to exit 0 ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) echo rs6000-bull-bosx exit 0 ;; DPX/2?00:B.O.S.:*:*) echo m68k-bull-sysv3 exit 0 ;; 9000/[34]??:4.3bsd:1.*:*) echo m68k-hp-bsd exit 0 ;; hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) echo m68k-hp-bsd4.4 exit 0 ;; 9000/[34678]??:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` case "${UNAME_MACHINE}" in 9000/31? ) HP_ARCH=m68000 ;; 9000/[34]?? ) HP_ARCH=m68k ;; 9000/[678][0-9][0-9]) if [ -x /usr/bin/getconf ]; then sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` case "${sc_cpu_version}" in 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 532) # CPU_PA_RISC2_0 case "${sc_kernel_bits}" in 32) HP_ARCH="hppa2.0n" ;; 64) HP_ARCH="hppa2.0w" ;; '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 esac ;; esac fi if [ "${HP_ARCH}" = "" ]; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #define _HPUX_SOURCE #include #include int main () { #if defined(_SC_KERNEL_BITS) long bits = sysconf(_SC_KERNEL_BITS); #endif long cpu = sysconf (_SC_CPU_VERSION); switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0"); break; case CPU_PA_RISC1_1: puts ("hppa1.1"); break; case CPU_PA_RISC2_0: #if defined(_SC_KERNEL_BITS) switch (bits) { case 64: puts ("hppa2.0w"); break; case 32: puts ("hppa2.0n"); break; default: puts ("hppa2.0"); break; } break; #else /* !defined(_SC_KERNEL_BITS) */ puts ("hppa2.0"); break; #endif default: puts ("hppa1.0"); break; } exit (0); } EOF (CCOPTS= $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null) && HP_ARCH=`$dummy` if test -z "$HP_ARCH"; then HP_ARCH=hppa; fi rm -f $dummy.c $dummy && rmdir $tmpdir fi ;; esac echo ${HP_ARCH}-hp-hpux${HPUX_REV} exit 0 ;; ia64:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` echo ia64-hp-hpux${HPUX_REV} exit 0 ;; 3050*:HI-UX:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include int main () { long cpu = sysconf (_SC_CPU_VERSION); /* The order matters, because CPU_IS_HP_MC68K erroneously returns true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct results, however. */ if (CPU_IS_PA_RISC (cpu)) { switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; default: puts ("hppa-hitachi-hiuxwe2"); break; } } else if (CPU_IS_HP_MC68K (cpu)) puts ("m68k-hitachi-hiuxwe2"); else puts ("unknown-hitachi-hiuxwe2"); exit (0); } EOF $CC_FOR_BUILD $dummy.c -o $dummy && $dummy && rm -f $dummy.c $dummy && rmdir $tmpdir && exit 0 rm -f $dummy.c $dummy && rmdir $tmpdir echo unknown-hitachi-hiuxwe2 exit 0 ;; 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) echo hppa1.1-hp-bsd exit 0 ;; 9000/8??:4.3bsd:*:*) echo hppa1.0-hp-bsd exit 0 ;; *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) echo hppa1.0-hp-mpeix exit 0 ;; hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) echo hppa1.1-hp-osf exit 0 ;; hp8??:OSF1:*:*) echo hppa1.0-hp-osf exit 0 ;; i*86:OSF1:*:*) if [ -x /usr/sbin/sysversion ] ; then echo ${UNAME_MACHINE}-unknown-osf1mk else echo ${UNAME_MACHINE}-unknown-osf1 fi exit 0 ;; parisc*:Lites*:*:*) echo hppa1.1-hp-lites exit 0 ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) echo c1-convex-bsd exit 0 ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit 0 ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) echo c34-convex-bsd exit 0 ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) echo c38-convex-bsd exit 0 ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) echo c4-convex-bsd exit 0 ;; CRAY*Y-MP:*:*:*) echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; CRAY*[A-Z]90:*:*:*) echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ -e 's/\.[^.]*$/.X/' exit 0 ;; CRAY*TS:*:*:*) echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; CRAY*T3D:*:*:*) echo alpha-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; CRAY*T3E:*:*:*) echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; CRAY*SV1:*:*:*) echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit 0 ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} exit 0 ;; sparc*:BSD/OS:*:*) echo sparc-unknown-bsdi${UNAME_RELEASE} exit 0 ;; *:BSD/OS:*:*) echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} exit 0 ;; *:FreeBSD:*:*) # Determine whether the default compiler uses glibc. eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include #if __GLIBC__ >= 2 LIBC=gnu #else LIBC= #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=` rm -f $dummy.c && rmdir $tmpdir echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`${LIBC:+-$LIBC} exit 0 ;; i*:CYGWIN*:*) echo ${UNAME_MACHINE}-pc-cygwin exit 0 ;; i*:MINGW*:*) echo ${UNAME_MACHINE}-pc-mingw32 exit 0 ;; i*:PW*:*) echo ${UNAME_MACHINE}-pc-pw32 exit 0 ;; x86:Interix*:3*) echo i386-pc-interix3 exit 0 ;; i*:Windows_NT*:* | Pentium*:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we # UNAME_MACHINE based on the output of uname instead of i386? echo i386-pc-interix exit 0 ;; i*:UWIN*:*) echo ${UNAME_MACHINE}-pc-uwin exit 0 ;; p*:CYGWIN*:*) echo powerpcle-unknown-cygwin exit 0 ;; prep*:SunOS:5.*:*) echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; *:GNU:*:*) echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` exit 0 ;; i*86:Minix:*:*) echo ${UNAME_MACHINE}-pc-minix exit 0 ;; arm*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit 0 ;; ia64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit 0 ;; m68*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit 0 ;; mips:Linux:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #undef CPU #undef mips #undef mipsel #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) CPU=mipsel #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) CPU=mips #else CPU= #endif #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=` rm -f $dummy.c && rmdir $tmpdir test x"${CPU}" != x && echo "${CPU}-pc-linux-gnu" && exit 0 ;; ppc:Linux:*:*) echo powerpc-unknown-linux-gnu exit 0 ;; ppc64:Linux:*:*) echo powerpc64-unknown-linux-gnu exit 0 ;; alpha:Linux:*:*) case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in EV5) UNAME_MACHINE=alphaev5 ;; EV56) UNAME_MACHINE=alphaev56 ;; PCA56) UNAME_MACHINE=alphapca56 ;; PCA57) UNAME_MACHINE=alphapca56 ;; EV6) UNAME_MACHINE=alphaev6 ;; EV67) UNAME_MACHINE=alphaev67 ;; EV68*) UNAME_MACHINE=alphaev68 ;; esac objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} exit 0 ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in PA7*) echo hppa1.1-unknown-linux-gnu ;; PA8*) echo hppa2.0-unknown-linux-gnu ;; *) echo hppa-unknown-linux-gnu ;; esac exit 0 ;; parisc64:Linux:*:* | hppa64:Linux:*:*) echo hppa64-unknown-linux-gnu exit 0 ;; s390:Linux:*:* | s390x:Linux:*:*) echo ${UNAME_MACHINE}-ibm-linux exit 0 ;; sh*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit 0 ;; sparc:Linux:*:* | sparc64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit 0 ;; x86_64:Linux:*:*) echo x86_64-unknown-linux-gnu exit 0 ;; i*86:Linux:*:*) # The BFD linker knows what the default object file format is, so # first see if it will tell us. cd to the root directory to prevent # problems with other programs or directories called `ld' in the path. # Set LC_ALL=C to ensure ld outputs messages in English. ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \ | sed -ne '/supported targets:/!d s/[ ][ ]*/ /g s/.*supported targets: *// s/ .*// p'` case "$ld_supported_targets" in elf32-i386) TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu" ;; a.out-i386-linux) echo "${UNAME_MACHINE}-pc-linux-gnuaout" exit 0 ;; coff-i386) echo "${UNAME_MACHINE}-pc-linux-gnucoff" exit 0 ;; "") # Either a pre-BFD a.out linker (linux-gnuoldld) or # one that does not give us useful --help. echo "${UNAME_MACHINE}-pc-linux-gnuoldld" exit 0 ;; esac # Determine whether the default compiler is a.out or elf eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include #ifdef __ELF__ # ifdef __GLIBC__ # if __GLIBC__ >= 2 LIBC=gnu # else LIBC=gnulibc1 # endif # else LIBC=gnulibc1 # endif #else #ifdef __INTEL_COMPILER LIBC=gnu #else LIBC=gnuaout #endif #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=` rm -f $dummy.c && rmdir $tmpdir test x"${LIBC}" != x && echo "${UNAME_MACHINE}-pc-linux-${LIBC}" && exit 0 test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0 ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. # earlier versions are messed up and put the nodename in both # sysname and nodename. echo i386-sequent-sysv4 exit 0 ;; i*86:UNIX_SV:4.2MP:2.*) # Unixware is an offshoot of SVR4, but it has its own version # number series starting with 2... # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. # Use sysv4.2uw... so that sysv4* matches it. echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} exit 0 ;; i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} else echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} fi exit 0 ;; i*86:*:5:[78]*) case `/bin/uname -X | grep "^Machine"` in *486*) UNAME_MACHINE=i486 ;; *Pentium) UNAME_MACHINE=i586 ;; *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} exit 0 ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ && UNAME_MACHINE=i586 (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ && UNAME_MACHINE=i686 (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 echo ${UNAME_MACHINE}-pc-sco$UNAME_REL else echo ${UNAME_MACHINE}-pc-sysv32 fi exit 0 ;; i*86:*DOS:*:*) echo ${UNAME_MACHINE}-pc-msdosdjgpp exit 0 ;; pc:*:*:*) # Left here for compatibility: # uname -m prints for DJGPP always 'pc', but it prints nothing about # the processor, so we play safe by assuming i386. echo i386-pc-msdosdjgpp exit 0 ;; Intel:Mach:3*:*) echo i386-pc-mach3 exit 0 ;; paragon:*:*:*) echo i860-intel-osf1 exit 0 ;; i860:*:4.*:*) # i860-SVR4 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 fi exit 0 ;; mini*:CTIX:SYS*5:*) # "miniframe" echo m68010-convergent-sysv exit 0 ;; M68*:*:R3V[567]*:*) test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;; 3[34]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0) OS_REL='' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && echo i486-ncr-sysv4.3${OS_REL} && exit 0 /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && echo i486-ncr-sysv4 && exit 0 ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) echo m68k-unknown-lynxos${UNAME_RELEASE} exit 0 ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 exit 0 ;; i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) echo i386-unknown-lynxos${UNAME_RELEASE} exit 0 ;; TSUNAMI:LynxOS:2.*:*) echo sparc-unknown-lynxos${UNAME_RELEASE} exit 0 ;; rs6000:LynxOS:2.*:*) echo rs6000-unknown-lynxos${UNAME_RELEASE} exit 0 ;; PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*) echo powerpc-unknown-lynxos${UNAME_RELEASE} exit 0 ;; SM[BE]S:UNIX_SV:*:*) echo mips-dde-sysv${UNAME_RELEASE} exit 0 ;; RM*:ReliantUNIX-*:*:*) echo mips-sni-sysv4 exit 0 ;; RM*:SINIX-*:*:*) echo mips-sni-sysv4 exit 0 ;; *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` echo ${UNAME_MACHINE}-sni-sysv4 else echo ns32k-sni-sysv fi exit 0 ;; PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort # says echo i586-unisys-sysv4 exit 0 ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes . # How about differentiating between stratus architectures? -djm echo hppa1.1-stratus-sysv4 exit 0 ;; *:*:*:FTX*) # From seanf@swdc.stratus.com. echo i860-stratus-sysv4 exit 0 ;; *:VOS:*:*) # From Paul.Green@stratus.com. echo hppa1.1-stratus-vos exit 0 ;; mc68*:A/UX:*:*) echo m68k-apple-aux${UNAME_RELEASE} exit 0 ;; news*:NEWS-OS:6*:*) echo mips-sony-newsos6 exit 0 ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if [ -d /usr/nec ]; then echo mips-nec-sysv${UNAME_RELEASE} else echo mips-unknown-sysv${UNAME_RELEASE} fi exit 0 ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. echo powerpc-be-beos exit 0 ;; BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. echo powerpc-apple-beos exit 0 ;; BePC:BeOS:*:*) # BeOS running on Intel PC compatible. echo i586-pc-beos exit 0 ;; SX-4:SUPER-UX:*:*) echo sx4-nec-superux${UNAME_RELEASE} exit 0 ;; SX-5:SUPER-UX:*:*) echo sx5-nec-superux${UNAME_RELEASE} exit 0 ;; Power*:Rhapsody:*:*) echo powerpc-apple-rhapsody${UNAME_RELEASE} exit 0 ;; *:Rhapsody:*:*) echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} exit 0 ;; *:Darwin:*:*) echo `uname -p`-apple-darwin${UNAME_RELEASE} exit 0 ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=`uname -p` if test "$UNAME_PROCESSOR" = "x86"; then UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} exit 0 ;; *:QNX:*:4*) echo i386-pc-qnx exit 0 ;; NSR-[GKLNPTVW]:NONSTOP_KERNEL:*:*) echo nsr-tandem-nsk${UNAME_RELEASE} exit 0 ;; *:NonStop-UX:*:*) echo mips-compaq-nonstopux exit 0 ;; BS2000:POSIX*:*:*) echo bs2000-siemens-sysv exit 0 ;; DS/*:UNIX_System_V:*:*) echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} exit 0 ;; *:Plan9:*:*) # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 # operating systems. if test "$cputype" = "386"; then UNAME_MACHINE=i386 else UNAME_MACHINE="$cputype" fi echo ${UNAME_MACHINE}-unknown-plan9 exit 0 ;; i*86:OS/2:*:*) # If we were able to find `uname', then EMX Unix compatibility # is probably installed. echo ${UNAME_MACHINE}-pc-os2-emx exit 0 ;; *:TOPS-10:*:*) echo pdp10-unknown-tops10 exit 0 ;; *:TENEX:*:*) echo pdp10-unknown-tenex exit 0 ;; KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) echo pdp10-dec-tops20 exit 0 ;; XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) echo pdp10-xkl-tops20 exit 0 ;; *:TOPS-20:*:*) echo pdp10-unknown-tops20 exit 0 ;; *:ITS:*:*) echo pdp10-unknown-its exit 0 ;; i*86:XTS-300:*:STOP) echo ${UNAME_MACHINE}-unknown-stop exit 0 ;; i*86:atheos:*:*) echo ${UNAME_MACHINE}-unknown-atheos exit 0 ;; esac #echo '(No uname command or uname output not recognized.)' 1>&2 #echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 eval $set_cc_for_build cat >$dummy.c < # include #endif main () { #if defined (sony) #if defined (MIPSEB) /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, I don't know.... */ printf ("mips-sony-bsd\n"); exit (0); #else #include printf ("m68k-sony-newsos%s\n", #ifdef NEWSOS4 "4" #else "" #endif ); exit (0); #endif #endif #if defined (__arm) && defined (__acorn) && defined (__unix) printf ("arm-acorn-riscix"); exit (0); #endif #if defined (hp300) && !defined (hpux) printf ("m68k-hp-bsd\n"); exit (0); #endif #if defined (NeXT) #if !defined (__ARCHITECTURE__) #define __ARCHITECTURE__ "m68k" #endif int version; version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; if (version < 4) printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); else printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); exit (0); #endif #if defined (MULTIMAX) || defined (n16) #if defined (UMAXV) printf ("ns32k-encore-sysv\n"); exit (0); #else #if defined (CMU) printf ("ns32k-encore-mach\n"); exit (0); #else printf ("ns32k-encore-bsd\n"); exit (0); #endif #endif #endif #if defined (__386BSD__) printf ("i386-pc-bsd\n"); exit (0); #endif #if defined (sequent) #if defined (i386) printf ("i386-sequent-dynix\n"); exit (0); #endif #if defined (ns32000) printf ("ns32k-sequent-dynix\n"); exit (0); #endif #endif #if defined (_SEQUENT_) struct utsname un; uname(&un); if (strncmp(un.version, "V2", 2) == 0) { printf ("i386-sequent-ptx2\n"); exit (0); } if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ printf ("i386-sequent-ptx1\n"); exit (0); } printf ("i386-sequent-ptx\n"); exit (0); #endif #if defined (vax) # if !defined (ultrix) # include # if defined (BSD) # if BSD == 43 printf ("vax-dec-bsd4.3\n"); exit (0); # else # if BSD == 199006 printf ("vax-dec-bsd4.3reno\n"); exit (0); # else printf ("vax-dec-bsd\n"); exit (0); # endif # endif # else printf ("vax-dec-bsd\n"); exit (0); # endif # else printf ("vax-dec-ultrix\n"); exit (0); # endif #endif #if defined (alliant) && defined (i860) printf ("i860-alliant-bsd\n"); exit (0); #endif exit (1); } EOF $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && $dummy && rm -f $dummy.c $dummy && rmdir $tmpdir && exit 0 rm -f $dummy.c $dummy && rmdir $tmpdir # Apollos put the system type in the environment. test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; } # Convex versions that predate uname can use getsysinfo(1) if [ -x /usr/convex/getsysinfo ] then case `getsysinfo -f cpu_type` in c1*) echo c1-convex-bsd exit 0 ;; c2*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit 0 ;; c34*) echo c34-convex-bsd exit 0 ;; c38*) echo c38-convex-bsd exit 0 ;; c4*) echo c4-convex-bsd exit 0 ;; esac fi cat >&2 < in order to provide the needed information to handle your system. config.guess timestamp = $timestamp uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` /bin/uname -X = `(/bin/uname -X) 2>/dev/null` hostinfo = `(hostinfo) 2>/dev/null` /bin/universe = `(/bin/universe) 2>/dev/null` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` /bin/arch = `(/bin/arch) 2>/dev/null` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` UNAME_MACHINE = ${UNAME_MACHINE} UNAME_RELEASE = ${UNAME_RELEASE} UNAME_SYSTEM = ${UNAME_SYSTEM} UNAME_VERSION = ${UNAME_VERSION} EOF exit 1 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: rJava/jri/tools/config.sub0000755000176200001440000007145312256051760015242 0ustar liggesusers#! /bin/sh # Configuration validation subroutine script. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, # 2000, 2001, 2002 Free Software Foundation, Inc. timestamp='2002-07-03' # This file is (in principle) common to ALL GNU software. # The presence of a machine in this file suggests that SOME GNU software # can handle that machine. It does not imply ALL GNU software can. # # This file is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA. # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Please send patches to . Submit a context # diff and a properly formatted ChangeLog entry. # # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. # If it is invalid, we print an error message on stderr and exit with code 1. # Otherwise, we print the canonical config type on stdout and succeed. # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases # that are meaningful with *any* GNU software. # Each package is responsible for reporting which valid configurations # it does not support. The user should be able to distinguish # a failure to support a valid configuration from a meaningless # configuration. # The goal of this file is to map all the various variations of a given # machine specification into a single specification in the form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM # or in some cases, the newer four-part form: # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM # It is wrong to echo any other type of specification. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] CPU-MFR-OPSYS $0 [OPTION] ALIAS Canonicalize a configuration name. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.sub ($timestamp) Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit 0 ;; --version | -v ) echo "$version" ; exit 0 ;; --help | --h* | -h ) echo "$usage"; exit 0 ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" exit 1 ;; *local*) # First pass through any local machine types. echo $1 exit 0;; * ) break ;; esac done case $# in 0) echo "$me: missing argument$help" >&2 exit 1;; 1) ;; *) echo "$me: too many arguments$help" >&2 exit 1;; esac # Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). # Here we must recognize all the valid KERNEL-OS combinations. maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in nto-qnx* | linux-gnu* | freebsd*-gnu* | storm-chaos* | os2-emx* | windows32-* | rtmk-nova*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ;; *) basic_machine=`echo $1 | sed 's/-[^-]*$//'` if [ $basic_machine != $1 ] then os=`echo $1 | sed 's/.*-/-/'` else os=; fi ;; esac ### Let's recognize common machines as not being operating systems so ### that things like config.sub decstation-3100 work. We also ### recognize some manufacturers as not being operating systems, so we ### can provide default operating systems below. case $os in -sun*os*) # Prevent following clause from handling this invalid input. ;; -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ -apple | -axis) os= basic_machine=$1 ;; -sim | -cisco | -oki | -wec | -winbond) os= basic_machine=$1 ;; -scout) ;; -wrs) os=-vxworks basic_machine=$1 ;; -chorusos*) os=-chorusos basic_machine=$1 ;; -chorusrdb) os=-chorusrdb basic_machine=$1 ;; -hiux*) os=-hiuxwe2 ;; -sco5) os=-sco3.2v5 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco4) os=-sco3.2v4 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2.[4-9]*) os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2v[4-9]*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco*) os=-sco3.2v2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -udk*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -isc) os=-isc2.2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -clix*) basic_machine=clipper-intergraph ;; -isc*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -lynx*) os=-lynxos ;; -ptx*) basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` ;; -windowsnt*) os=`echo $os | sed -e 's/windowsnt/winnt/'` ;; -psos*) os=-psos ;; -mint | -mint[0-9]*) basic_machine=m68k-atari os=-mint ;; esac # Decode aliases for certain CPU-COMPANY combinations. case $basic_machine in # Recognize the basic CPU types without company name. # Some are omitted here because they have special meanings below. 1750a | 580 \ | a29k \ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \ | c4x | clipper \ | d10v | d30v | dlx | dsp16xx \ | fr30 | frv \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | i370 | i860 | i960 | ia64 \ | ip2k \ | m32r | m68000 | m68k | m88k | mcore \ | mips | mipsbe | mipseb | mipsel | mipsle \ | mips16 \ | mips64 | mips64el \ | mips64orion | mips64orionel \ | mips64vr4100 | mips64vr4100el \ | mips64vr4300 | mips64vr4300el \ | mips64vr5000 | mips64vr5000el \ | mipsisa32 | mipsisa32el \ | mipsisa64 | mipsisa64el \ | mipsisa64sb1 | mipsisa64sb1el \ | mipstx39 | mipstx39el \ | mn10200 | mn10300 \ | ns16k | ns32k \ | openrisc | or32 \ | pdp10 | pdp11 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ | pyramid \ | sh | sh[1234] | sh3e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \ | sh64 | sh64le \ | sparc | sparc64 | sparc86x | sparclet | sparclite | sparcv9 | sparcv9b \ | strongarm \ | tahoe | thumb | tic80 | tron \ | v850 | v850e \ | we32k \ | x86 | xscale | xstormy16 | xtensa \ | z8k) basic_machine=$basic_machine-unknown ;; m6811 | m68hc11 | m6812 | m68hc12) # Motorola 68HC11/12. basic_machine=$basic_machine-unknown os=-none ;; m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) ;; # We use `pc' rather than `unknown' # because (1) that's what they normally are, and # (2) the word "unknown" tends to confuse beginning users. i*86 | x86_64) basic_machine=$basic_machine-pc ;; # Object if more than one company name word. *-*-*) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; # Recognize the basic CPU types with company name. 580-* \ | a29k-* \ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ | avr-* \ | bs2000-* \ | c[123]* | c30-* | [cjt]90-* | c54x-* \ | clipper-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ | elxsi-* \ | f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \ | h8300-* | h8500-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ | i*86-* | i860-* | i960-* | ia64-* \ | ip2k-* \ | m32r-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ | m88110-* | m88k-* | mcore-* \ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ | mips16-* \ | mips64-* | mips64el-* \ | mips64orion-* | mips64orionel-* \ | mips64vr4100-* | mips64vr4100el-* \ | mips64vr4300-* | mips64vr4300el-* \ | mips64vr5000-* | mips64vr5000el-* \ | mipsisa32-* | mipsisa32el-* \ | mipsisa64-* | mipsisa64el-* \ | mipsisa64sb1-* | mipsisa64sb1el-* \ | mipstx39 | mipstx39el \ | none-* | np1-* | ns16k-* | ns32k-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ | pyramid-* \ | romp-* | rs6000-* \ | sh-* | sh[1234]-* | sh3e-* | sh[34]eb-* | shbe-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ | sparc-* | sparc64-* | sparc86x-* | sparclet-* | sparclite-* \ | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \ | tahoe-* | thumb-* | tic30-* | tic54x-* | tic80-* | tron-* \ | v850-* | v850e-* | vax-* \ | we32k-* \ | x86-* | x86_64-* | xps100-* | xscale-* | xstormy16-* \ | xtensa-* \ | ymp-* \ | z8k-*) ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. 386bsd) basic_machine=i386-unknown os=-bsd ;; 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) basic_machine=m68000-att ;; 3b*) basic_machine=we32k-att ;; a29khif) basic_machine=a29k-amd os=-udi ;; adobe68k) basic_machine=m68010-adobe os=-scout ;; alliant | fx80) basic_machine=fx80-alliant ;; altos | altos3068) basic_machine=m68k-altos ;; am29k) basic_machine=a29k-none os=-bsd ;; amdahl) basic_machine=580-amdahl os=-sysv ;; amiga | amiga-*) basic_machine=m68k-unknown ;; amigaos | amigados) basic_machine=m68k-unknown os=-amigaos ;; amigaunix | amix) basic_machine=m68k-unknown os=-sysv4 ;; apollo68) basic_machine=m68k-apollo os=-sysv ;; apollo68bsd) basic_machine=m68k-apollo os=-bsd ;; aux) basic_machine=m68k-apple os=-aux ;; balance) basic_machine=ns32k-sequent os=-dynix ;; c90) basic_machine=c90-cray os=-unicos ;; convex-c1) basic_machine=c1-convex os=-bsd ;; convex-c2) basic_machine=c2-convex os=-bsd ;; convex-c32) basic_machine=c32-convex os=-bsd ;; convex-c34) basic_machine=c34-convex os=-bsd ;; convex-c38) basic_machine=c38-convex os=-bsd ;; cray | j90) basic_machine=j90-cray os=-unicos ;; crds | unos) basic_machine=m68k-crds ;; cris | cris-* | etrax*) basic_machine=cris-axis ;; da30 | da30-*) basic_machine=m68k-da30 ;; decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) basic_machine=mips-dec ;; decsystem10* | dec10*) basic_machine=pdp10-dec os=-tops10 ;; decsystem20* | dec20*) basic_machine=pdp10-dec os=-tops20 ;; delta | 3300 | motorola-3300 | motorola-delta \ | 3300-motorola | delta-motorola) basic_machine=m68k-motorola ;; delta88) basic_machine=m88k-motorola os=-sysv3 ;; dpx20 | dpx20-*) basic_machine=rs6000-bull os=-bosx ;; dpx2* | dpx2*-bull) basic_machine=m68k-bull os=-sysv3 ;; ebmon29k) basic_machine=a29k-amd os=-ebmon ;; elxsi) basic_machine=elxsi-elxsi os=-bsd ;; encore | umax | mmax) basic_machine=ns32k-encore ;; es1800 | OSE68k | ose68k | ose | OSE) basic_machine=m68k-ericsson os=-ose ;; fx2800) basic_machine=i860-alliant ;; genix) basic_machine=ns32k-ns ;; gmicro) basic_machine=tron-gmicro os=-sysv ;; go32) basic_machine=i386-pc os=-go32 ;; h3050r* | hiux*) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; h8300hms) basic_machine=h8300-hitachi os=-hms ;; h8300xray) basic_machine=h8300-hitachi os=-xray ;; h8500hms) basic_machine=h8500-hitachi os=-hms ;; harris) basic_machine=m88k-harris os=-sysv3 ;; hp300-*) basic_machine=m68k-hp ;; hp300bsd) basic_machine=m68k-hp os=-bsd ;; hp300hpux) basic_machine=m68k-hp os=-hpux ;; hp3k9[0-9][0-9] | hp9[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k2[0-9][0-9] | hp9k31[0-9]) basic_machine=m68000-hp ;; hp9k3[2-9][0-9]) basic_machine=m68k-hp ;; hp9k6[0-9][0-9] | hp6[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k7[0-79][0-9] | hp7[0-79][0-9]) basic_machine=hppa1.1-hp ;; hp9k78[0-9] | hp78[0-9]) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[0-9][13679] | hp8[0-9][13679]) basic_machine=hppa1.1-hp ;; hp9k8[0-9][0-9] | hp8[0-9][0-9]) basic_machine=hppa1.0-hp ;; hppa-next) os=-nextstep3 ;; hppaosf) basic_machine=hppa1.1-hp os=-osf ;; hppro) basic_machine=hppa1.1-hp os=-proelf ;; i370-ibm* | ibm*) basic_machine=i370-ibm ;; # I'm not sure what "Sysv32" means. Should this be sysv3.2? i*86v32) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv32 ;; i*86v4*) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv4 ;; i*86v) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv ;; i*86sol2) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-solaris2 ;; i386mach) basic_machine=i386-mach os=-mach ;; i386-vsta | vsta) basic_machine=i386-unknown os=-vsta ;; iris | iris4d) basic_machine=mips-sgi case $os in -irix*) ;; *) os=-irix4 ;; esac ;; isi68 | isi) basic_machine=m68k-isi os=-sysv ;; m88k-omron*) basic_machine=m88k-omron ;; magnum | m3230) basic_machine=mips-mips os=-sysv ;; merlin) basic_machine=ns32k-utek os=-sysv ;; mingw32) basic_machine=i386-pc os=-mingw32 ;; miniframe) basic_machine=m68000-convergent ;; *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) basic_machine=m68k-atari os=-mint ;; mips3*-*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` ;; mips3*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown ;; mmix*) basic_machine=mmix-knuth os=-mmixware ;; monitor) basic_machine=m68k-rom68k os=-coff ;; morphos) basic_machine=powerpc-unknown os=-morphos ;; msdos) basic_machine=i386-pc os=-msdos ;; mvs) basic_machine=i370-ibm os=-mvs ;; ncr3000) basic_machine=i486-ncr os=-sysv4 ;; netbsd386) basic_machine=i386-unknown os=-netbsd ;; netwinder) basic_machine=armv4l-rebel os=-linux ;; news | news700 | news800 | news900) basic_machine=m68k-sony os=-newsos ;; news1000) basic_machine=m68030-sony os=-newsos ;; news-3600 | risc-news) basic_machine=mips-sony os=-newsos ;; necv70) basic_machine=v70-nec os=-sysv ;; next | m*-next ) basic_machine=m68k-next case $os in -nextstep* ) ;; -ns2*) os=-nextstep2 ;; *) os=-nextstep3 ;; esac ;; nh3000) basic_machine=m68k-harris os=-cxux ;; nh[45]000) basic_machine=m88k-harris os=-cxux ;; nindy960) basic_machine=i960-intel os=-nindy ;; mon960) basic_machine=i960-intel os=-mon960 ;; nonstopux) basic_machine=mips-compaq os=-nonstopux ;; np1) basic_machine=np1-gould ;; nsr-tandem) basic_machine=nsr-tandem ;; op50n-* | op60c-*) basic_machine=hppa1.1-oki os=-proelf ;; or32 | or32-*) basic_machine=or32-unknown os=-coff ;; OSE68000 | ose68000) basic_machine=m68000-ericsson os=-ose ;; os68k) basic_machine=m68k-none os=-os68k ;; pa-hitachi) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; paragon) basic_machine=i860-intel os=-osf ;; pbd) basic_machine=sparc-tti ;; pbb) basic_machine=m68k-tti ;; pc532 | pc532-*) basic_machine=ns32k-pc532 ;; pentium | p5 | k5 | k6 | nexgen | viac3) basic_machine=i586-pc ;; pentiumpro | p6 | 6x86 | athlon) basic_machine=i686-pc ;; pentiumii | pentium2) basic_machine=i686-pc ;; pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumpro-* | p6-* | 6x86-* | athlon-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumii-* | pentium2-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pn) basic_machine=pn-gould ;; power) basic_machine=power-ibm ;; ppc) basic_machine=powerpc-unknown ;; ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppcle | powerpclittle | ppc-le | powerpc-little) basic_machine=powerpcle-unknown ;; ppcle-* | powerpclittle-*) basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64) basic_machine=powerpc64-unknown ;; ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64le | powerpc64little | ppc64-le | powerpc64-little) basic_machine=powerpc64le-unknown ;; ppc64le-* | powerpc64little-*) basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ps2) basic_machine=i386-ibm ;; pw32) basic_machine=i586-unknown os=-pw32 ;; rom68k) basic_machine=m68k-rom68k os=-coff ;; rm[46]00) basic_machine=mips-siemens ;; rtpc | rtpc-*) basic_machine=romp-ibm ;; s390 | s390-*) basic_machine=s390-ibm ;; s390x | s390x-*) basic_machine=s390x-ibm ;; sa29200) basic_machine=a29k-amd os=-udi ;; sequent) basic_machine=i386-sequent ;; sh) basic_machine=sh-hitachi os=-hms ;; sparclite-wrs | simso-wrs) basic_machine=sparclite-wrs os=-vxworks ;; sps7) basic_machine=m68k-bull os=-sysv2 ;; spur) basic_machine=spur-unknown ;; st2000) basic_machine=m68k-tandem ;; stratus) basic_machine=i860-stratus os=-sysv4 ;; sun2) basic_machine=m68000-sun ;; sun2os3) basic_machine=m68000-sun os=-sunos3 ;; sun2os4) basic_machine=m68000-sun os=-sunos4 ;; sun3os3) basic_machine=m68k-sun os=-sunos3 ;; sun3os4) basic_machine=m68k-sun os=-sunos4 ;; sun4os3) basic_machine=sparc-sun os=-sunos3 ;; sun4os4) basic_machine=sparc-sun os=-sunos4 ;; sun4sol2) basic_machine=sparc-sun os=-solaris2 ;; sun3 | sun3-*) basic_machine=m68k-sun ;; sun4) basic_machine=sparc-sun ;; sun386 | sun386i | roadrunner) basic_machine=i386-sun ;; sv1) basic_machine=sv1-cray os=-unicos ;; symmetry) basic_machine=i386-sequent os=-dynix ;; t3d) basic_machine=alpha-cray os=-unicos ;; t3e) basic_machine=alphaev5-cray os=-unicos ;; t90) basic_machine=t90-cray os=-unicos ;; tic54x | c54x*) basic_machine=tic54x-unknown os=-coff ;; tx39) basic_machine=mipstx39-unknown ;; tx39el) basic_machine=mipstx39el-unknown ;; toad1) basic_machine=pdp10-xkl os=-tops20 ;; tower | tower-32) basic_machine=m68k-ncr ;; udi29k) basic_machine=a29k-amd os=-udi ;; ultra3) basic_machine=a29k-nyu os=-sym1 ;; v810 | necv810) basic_machine=v810-nec os=-none ;; vaxv) basic_machine=vax-dec os=-sysv ;; vms) basic_machine=vax-dec os=-vms ;; vpp*|vx|vx-*) basic_machine=f301-fujitsu ;; vxworks960) basic_machine=i960-wrs os=-vxworks ;; vxworks68) basic_machine=m68k-wrs os=-vxworks ;; vxworks29k) basic_machine=a29k-wrs os=-vxworks ;; w65*) basic_machine=w65-wdc os=-none ;; w89k-*) basic_machine=hppa1.1-winbond os=-proelf ;; windows32) basic_machine=i386-pc os=-windows32-msvcrt ;; xps | xps100) basic_machine=xps100-honeywell ;; ymp) basic_machine=ymp-cray os=-unicos ;; z8k-*-coff) basic_machine=z8k-unknown os=-sim ;; none) basic_machine=none-none os=-none ;; # Here we handle the default manufacturer of certain CPU types. It is in # some cases the only manufacturer, in others, it is the most popular. w89k) basic_machine=hppa1.1-winbond ;; op50n) basic_machine=hppa1.1-oki ;; op60c) basic_machine=hppa1.1-oki ;; romp) basic_machine=romp-ibm ;; rs6000) basic_machine=rs6000-ibm ;; vax) basic_machine=vax-dec ;; pdp10) # there are many clones, so DEC is not a safe bet basic_machine=pdp10-unknown ;; pdp11) basic_machine=pdp11-dec ;; we32k) basic_machine=we32k-att ;; sh3 | sh4 | sh3eb | sh4eb | sh[1234]le | sh3ele) basic_machine=sh-unknown ;; sh64) basic_machine=sh64-unknown ;; sparc | sparcv9 | sparcv9b) basic_machine=sparc-sun ;; cydra) basic_machine=cydra-cydrome ;; orion) basic_machine=orion-highlevel ;; orion105) basic_machine=clipper-highlevel ;; mac | mpw | mac-mpw) basic_machine=m68k-apple ;; pmac | pmac-mpw) basic_machine=powerpc-apple ;; c4x*) basic_machine=c4x-none os=-coff ;; *-unknown) # Make sure to match an already-canonicalized machine name. ;; *) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; esac # Here we canonicalize certain aliases for manufacturers. case $basic_machine in *-digital*) basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` ;; *-commodore*) basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` ;; *) ;; esac # Decode manufacturer-specific aliases for certain operating systems. if [ x"$os" != x"" ] then case $os in # First match some system type aliases # that might get confused with valid system types. # -solaris* is a basic system type, with this one exception. -solaris1 | -solaris1.*) os=`echo $os | sed -e 's|solaris1|sunos4|'` ;; -solaris) os=-solaris2 ;; -svr4*) os=-sysv4 ;; -unixware*) os=-sysv4.2uw ;; -gnu/linux*) os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` ;; # First accept the basic system types. # The portable systems comes first. # Each alternative MUST END IN A *, to match a version number. # -sysv* is not here because it comes later, after sysvr4. -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ | -aos* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ | -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \ | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -chorusos* | -chorusrdb* \ | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ | -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \ | -interix* | -uwin* | -rhapsody* | -darwin* | -opened* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* | -powermax*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) case $basic_machine in x86-* | i*86-*) ;; *) os=-nto$os ;; esac ;; -nto*) os=-nto-qnx ;; -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ | -windows* | -osx | -abug | -netware* | -os9* | -beos* \ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) ;; -mac*) os=`echo $os | sed -e 's|mac|macos|'` ;; -linux*) os=`echo $os | sed -e 's|linux|linux-gnu|'` ;; -sunos5*) os=`echo $os | sed -e 's|sunos5|solaris2|'` ;; -sunos6*) os=`echo $os | sed -e 's|sunos6|solaris3|'` ;; -opened*) os=-openedition ;; -wince*) os=-wince ;; -osfrose*) os=-osfrose ;; -osf*) os=-osf ;; -utek*) os=-bsd ;; -dynix*) os=-bsd ;; -acis*) os=-aos ;; -atheos*) os=-atheos ;; -386bsd) os=-bsd ;; -ctix* | -uts*) os=-sysv ;; -nova*) os=-rtmk-nova ;; -ns2 ) os=-nextstep2 ;; -nsk*) os=-nsk ;; # Preserve the version number of sinix5. -sinix5.*) os=`echo $os | sed -e 's|sinix|sysv|'` ;; -sinix*) os=-sysv4 ;; -triton*) os=-sysv3 ;; -oss*) os=-sysv3 ;; -svr4) os=-sysv4 ;; -svr3) os=-sysv3 ;; -sysvr4) os=-sysv4 ;; # This must come after -sysvr4. -sysv*) ;; -ose*) os=-ose ;; -es1800*) os=-ose ;; -xenix) os=-xenix ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) os=-mint ;; -none) ;; *) # Get rid of the `-' at the beginning of $os. os=`echo $os | sed 's/[^-]*-//'` echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 exit 1 ;; esac else # Here we handle the default operating systems that come with various machines. # The value should be what the vendor currently ships out the door with their # machine or put another way, the most popular os provided with the machine. # Note that if you're going to try to match "-MANUFACTURER" here (say, # "-sun"), then you have to tell the case statement up towards the top # that MANUFACTURER isn't an operating system. Otherwise, code above # will signal an error saying that MANUFACTURER isn't an operating # system, and we'll never get to this point. case $basic_machine in *-acorn) os=-riscix1.2 ;; arm*-rebel) os=-linux ;; arm*-semi) os=-aout ;; # This must come before the *-dec entry. pdp10-*) os=-tops20 ;; pdp11-*) os=-none ;; *-dec | vax-*) os=-ultrix4.2 ;; m68*-apollo) os=-domain ;; i386-sun) os=-sunos4.0.2 ;; m68000-sun) os=-sunos3 # This also exists in the configure program, but was not the # default. # os=-sunos4 ;; m68*-cisco) os=-aout ;; mips*-cisco) os=-elf ;; mips*-*) os=-elf ;; or32-*) os=-coff ;; *-tti) # must be before sparc entry or we get the wrong os. os=-sysv3 ;; sparc-* | *-sun) os=-sunos4.1.1 ;; *-be) os=-beos ;; *-ibm) os=-aix ;; *-wec) os=-proelf ;; *-winbond) os=-proelf ;; *-oki) os=-proelf ;; *-hp) os=-hpux ;; *-hitachi) os=-hiux ;; i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) os=-sysv ;; *-cbm) os=-amigaos ;; *-dg) os=-dgux ;; *-dolphin) os=-sysv3 ;; m68k-ccur) os=-rtu ;; m88k-omron*) os=-luna ;; *-next ) os=-nextstep ;; *-sequent) os=-ptx ;; *-crds) os=-unos ;; *-ns) os=-genix ;; i370-*) os=-mvs ;; *-next) os=-nextstep3 ;; *-gould) os=-sysv ;; *-highlevel) os=-bsd ;; *-encore) os=-bsd ;; *-sgi) os=-irix ;; *-siemens) os=-sysv4 ;; *-masscomp) os=-rtu ;; f30[01]-fujitsu | f700-fujitsu) os=-uxpv ;; *-rom68k) os=-coff ;; *-*bug) os=-coff ;; *-apple) os=-macos ;; *-atari*) os=-mint ;; *) os=-none ;; esac fi # Here we handle the case where we know the os, and the CPU type, but not the # manufacturer. We pick the logical manufacturer. vendor=unknown case $basic_machine in *-unknown) case $os in -riscix*) vendor=acorn ;; -sunos*) vendor=sun ;; -aix*) vendor=ibm ;; -beos*) vendor=be ;; -hpux*) vendor=hp ;; -mpeix*) vendor=hp ;; -hiux*) vendor=hitachi ;; -unos*) vendor=crds ;; -dgux*) vendor=dg ;; -luna*) vendor=omron ;; -genix*) vendor=ns ;; -mvs* | -opened*) vendor=ibm ;; -ptx*) vendor=sequent ;; -vxsim* | -vxworks* | -windiss*) vendor=wrs ;; -aux*) vendor=apple ;; -hms*) vendor=hitachi ;; -mpw* | -macos*) vendor=apple ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) vendor=atari ;; -vos*) vendor=stratus ;; esac basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` ;; esac echo $basic_machine$os exit 0 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: rJava/jri/RFactor.java0000644000176200001440000000563512256051760014321 0ustar liggesuserspackage org.rosuda.JRI; // JRclient library - client interface to Rserve, see http://www.rosuda.org/Rserve/ // Copyright (C) 2004 Simon Urbanek // --- for licensing information see LICENSE file in the original JRclient distribution --- import java.util.*; /** representation of a factor variable. In R there is no actual xpression type called "factor", instead it is coded as an int vector with a list attribute. The parser code of REXP converts such constructs directly into the RFactor objects and defines an own XT_FACTOR type @version $Id: RFactor.java 2909 2008-07-15 15:06:49Z urbanek $ */ public class RFactor extends Object { /** IDs (content: Integer) each entry corresponds to a case, ID specifies the category */ Vector id; /** values (content: String), ergo category names */ Vector val; /** create a new, empty factor var */ public RFactor() { id=new Vector(); val=new Vector(); } /** create a new factor variable, based on the supplied arrays. @param i array of IDs (0..v.length-1) @param v values - category names */ public RFactor(int[] i, String[] v) { this(i, v, 0); } /** create a new factor variable, based on the supplied arrays. @param i array of IDs (base .. v.length-1+base) @param v values - cotegory names @param base of the indexing */ RFactor(int[] i, String[] v, int base) { id=new Vector(); val=new Vector(); int j; if (i!=null && i.length>0) for(j=0;j0) for(j=0;j= id.size()) return null; int j = ((Integer)id.elementAt(i)).intValue(); /* due to the index shift NA (INT_MIN) will turn into INT_MAX if base is 1 */ return (j < 0 || j > 2147483640) ? null : ((String)val.elementAt(j)); } /** returns the number of caes */ public int size() { return id.size(); } /** displayable representation of the factor variable */ public String toString() { //return "{"+((val==null)?";":("levels="+val.size()+";"))+((id==null)?"":("cases="+id.size()))+"}"; StringBuffer sb=new StringBuffer("{levels=("); if (val==null) sb.append("null"); else for (int i=0;i0)?",\"":"\""); sb.append((String)val.elementAt(i)); sb.append("\""); }; sb.append("),ids=("); if (id==null) sb.append("null"); else for (int i=0;i0) sb.append(","); sb.append((Integer)id.elementAt(i)); }; sb.append(")}"); return sb.toString(); } } rJava/jri/Makevars.win0000644000176200001440000000076012256051760014400 0ustar liggesusersR_HOME=$(RHOME) JAVA_HOME=$(JAVAHOME) JAVAINC=-I$(JAVAHOME)/include -I$(JAVAHOME)/include/win32 RINC=-I$(R_HOME)/include JNISO=.dll JAVA_LIBS=-Lwin32 -ljvm JNILD=-shared $(JAVA_LIBS) -L$(RHOME)/src/gnuwin32 -L$(RHOME)/bin$(R_ARCH) -lR -Wl,--kill-at CFLAGS+=-DWin32 -D_JNI_IMPLEMENTATION_ JAVA_PROG=$(JAVAHOME)/bin/java JAVA=$(JAVAHOME)/bin/java JAVAC=$(JAVAHOME)/bin/javac JAVAH=$(JAVAHOME)/bin/javah JAR=$(JAVAHOME)/bin/jar JRIDEPS=win32/libjvm.dll.a JNIPREFIX= PLATFORMT=run.bat JRILIB=jri.dll rJava/jri/RMainLoopCallbacks.java0000644000176200001440000000564412256051760016421 0ustar liggesuserspackage org.rosuda.JRI; /** Interface which must be implmented by any class that wants to pose as the call-back handler for R event loop callbacks. It is legal to return immediately except when user interaction is required: {@link #rReadConsole} and {@link #rChooseFile} are expected to block until the user performs the desired action. */ public interface RMainLoopCallbacks { /** called when R prints output to the console @param re calling engine @param text text to display in the console @param oType output type (0=regular, 1=error/warning) */ public void rWriteConsole (Rengine re, String text, int oType); /** called when R enters or exits a longer evaluation. It is usually a good idea to signal this state to the user, e.g. by changing the cursor to a "hourglass" and back. @param re calling engine @param which identifies whether R enters (1) or exits (0) the busy state */ public void rBusy (Rengine re, int which); /** called when R waits for user input. During the duration of this callback it is safe to re-enter R, and very often it is also the only time. The implementation is free to block on this call until the user hits Enter, but in JRI it is a good idea to call {@link Rengine.rniIdle()} occasionally to allow other event handlers (e.g graphics device UIs) to run. Implementations should NEVER return immediately even if there is no input - such behavior will result in a fast cycling event loop which makes the use of R pretty much impossible. @param re calling engine @param prompt prompt to be displayed at the console prior to user's input @param addToHistory flag telling the handler whether the input should be considered for adding to history (!=0) or not (0) @return user's input to be passed to R for evaluation */ public String rReadConsole (Rengine re, String prompt, int addToHistory); /** called when R want to show a warning/error message (not to be confused with messages displayed in the console output) @param re calling engine @param message message to display */ public void rShowMessage (Rengine re, String message); /** called when R expects the user to choose a file @param re calling engine @param newFile flag determining whether an existing or new file is to be selecteed @return path/name of the selected file */ public String rChooseFile (Rengine re, int newFile); /** called when R requests the console to flush any buffered output @param re calling engine */ public void rFlushConsole (Rengine re); /** called to save the contents of the history (the implementation is responsible of keeping track of the history) @param re calling engine @param filename name of the history file */ public void rSaveHistory (Rengine re, String filename); /** called to load the contents of the history @param re calling engine @param filename name of the history file */ public void rLoadHistory (Rengine re, String filename); } rJava/jri/LICENSE0000644000176200001440000000146212256051760013115 0ustar liggesusers JRI - Java/R Interface Copyright (C) 2004-2007 Simon Urbanek This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; version 2.1 of the License. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library (LGPL.txt); if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA rJava/jri/package-info.java0000644000176200001440000000010112256051760015264 0ustar liggesusers/** * low level Java/R Interface */ package org.rosuda.JRI ; rJava/configure0000755000176200001440000047004612256051760013243 0ustar liggesusers#! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.69 for rJava 0.8. # # Report bugs to . # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. # # # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # Use a proper internal environment variable to ensure we don't fall # into an infinite loop, continuously re-executing ourselves. if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then _as_can_reexec=no; export _as_can_reexec; # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. $as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 as_fn_exit 255 fi # We don't want this to propagate to other subprocesses. { _as_can_reexec=; unset _as_can_reexec;} if test "x$CONFIG_SHELL" = x; then as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST else case \`(set -o) 2>/dev/null\` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi " as_required="as_fn_return () { (exit \$1); } as_fn_success () { as_fn_return 0; } as_fn_failure () { as_fn_return 1; } as_fn_ret_success () { return 0; } as_fn_ret_failure () { return 1; } exitcode=0 as_fn_success || { exitcode=1; echo as_fn_success failed.; } as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : else exitcode=1; echo positional parameters were not saved. fi test x\$exitcode = x0 || exit 1 test -x / || exit 1" as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 test \$(( 1 + 1 )) = 2 || exit 1" if (eval "$as_required") 2>/dev/null; then : as_have_required=yes else as_have_required=no fi if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR as_found=false for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. as_found=: case $as_dir in #( /*) for as_base in sh bash ksh sh5; do # Try only shells that exist, to save several forks. as_shell=$as_dir/$as_base if { test -f "$as_shell" || test -f "$as_shell.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : CONFIG_SHELL=$as_shell as_have_required=yes if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : break 2 fi fi done;; esac as_found=false done $as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : CONFIG_SHELL=$SHELL as_have_required=yes fi; } IFS=$as_save_IFS if test "x$CONFIG_SHELL" != x; then : export CONFIG_SHELL # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. $as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 exit 255 fi if test x$as_have_required = xno; then : $as_echo "$0: This script requires a shell more modern than all" $as_echo "$0: the shells that I found on your system." if test x${ZSH_VERSION+set} = xset ; then $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" $as_echo "$0: be upgraded to zsh 4.3.4 or later." else $as_echo "$0: Please tell bug-autoconf@gnu.org and $0: Simon.Urbanek@r-project.org about your system, $0: including any error possibly output before this $0: message. Then install a modern shell, or manually run $0: the script under such a shell if you do have one." fi exit 1 fi fi fi SHELL=${CONFIG_SHELL-/bin/sh} export SHELL # Unset more variables known to interfere with behavior of common tools. CLICOLOR_FORCE= GREP_OPTIONS= unset CLICOLOR_FORCE GREP_OPTIONS ## --------------------- ## ## M4sh Shell Functions. ## ## --------------------- ## # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p # as_fn_executable_p FILE # ----------------------- # Test if FILE is an executable regular file. as_fn_executable_p () { test -f "$1" && test -x "$1" } # as_fn_executable_p # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits as_lineno_1=$LINENO as_lineno_1a=$LINENO as_lineno_2=$LINENO as_lineno_2a=$LINENO eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) sed -n ' p /[$]LINENO/= ' <$as_myself | sed ' s/[$]LINENO.*/&-/ t lineno b :lineno N :loop s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ t loop s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } # If we had to re-execute with $CONFIG_SHELL, we're ensured to have # already done that, so ensure we don't try to do so again and fall # in an infinite loop. This has already happened in practice. _as_can_reexec=no; export _as_can_reexec # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). . "./$as_me.lineno" # Exit status is that of the last command. exit } ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -pR' fi else as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi as_test_x='test -x' as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" test -n "$DJDIR" || exec 7<&0 &1 # Name of the host. # hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` # # Initializations. # ac_default_prefix=/usr/local ac_clean_files= ac_config_libobj_dir=. LIBOBJS= cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= # Identity of this package. PACKAGE_NAME='rJava' PACKAGE_TARNAME='rjava' PACKAGE_VERSION='0.8' PACKAGE_STRING='rJava 0.8' PACKAGE_BUGREPORT='Simon.Urbanek@r-project.org' PACKAGE_URL='' ac_unique_file="src/rJava.c" # Factoring default headers for most tests. ac_includes_default="\ #include #ifdef HAVE_SYS_TYPES_H # include #endif #ifdef HAVE_SYS_STAT_H # include #endif #ifdef STDC_HEADERS # include # include #else # ifdef HAVE_STDLIB_H # include # endif #endif #ifdef HAVE_STRING_H # if !defined STDC_HEADERS && defined HAVE_MEMORY_H # include # endif # include #endif #ifdef HAVE_STRINGS_H # include #endif #ifdef HAVE_INTTYPES_H # include #endif #ifdef HAVE_STDINT_H # include #endif #ifdef HAVE_UNISTD_H # include #endif" enable_option_checking=no ac_subst_vars='LTLIBOBJS LIBOBJS subdirs JAVAH JAVAC JAVA JAVA_HOME JAVA_CPPFLAGS JAVA_LIBS WANT_JRI_FALSE WANT_JRI_TRUE EGREP GREP CPP OBJEXT EXEEXT ac_ct_CC CPPFLAGS LDFLAGS CFLAGS CC R_HOME target_alias host_alias build_alias LIBS ECHO_T ECHO_N ECHO_C DEFS mandir localedir libdir psdir pdfdir dvidir htmldir infodir docdir oldincludedir includedir localstatedir sharedstatedir sysconfdir datadir datarootdir libexecdir sbindir bindir program_transform_name prefix exec_prefix PACKAGE_URL PACKAGE_BUGREPORT PACKAGE_STRING PACKAGE_VERSION PACKAGE_TARNAME PACKAGE_NAME PATH_SEPARATOR SHELL' ac_subst_files='' ac_user_opts=' enable_option_checking enable_threads enable_jni_cache enable_jri enable_headless enable_debug enable_mem_profile enable_callbacks ' ac_precious_vars='build_alias host_alias target_alias CC CFLAGS LDFLAGS LIBS CPPFLAGS CPP' ac_subdirs_all='jri' # Initialize some variables set by options. ac_init_help= ac_init_version=false ac_unrecognized_opts= ac_unrecognized_sep= # The variables have the same names as the options, with # dashes changed to underlines. cache_file=/dev/null exec_prefix=NONE no_create= no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= verbose= x_includes=NONE x_libraries=NONE # Installation directory options. # These are left unexpanded so users can "make install exec_prefix=/foo" # and all the variables that are supposed to be based on exec_prefix # by default will actually change. # Use braces instead of parens because sh, perl, etc. also accept them. # (The list follows the same order as the GNU Coding Standards.) bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datarootdir='${prefix}/share' datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' infodir='${datarootdir}/info' htmldir='${docdir}' dvidir='${docdir}' pdfdir='${docdir}' psdir='${docdir}' libdir='${exec_prefix}/lib' localedir='${datarootdir}/locale' mandir='${datarootdir}/man' ac_prev= ac_dashdash= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval $ac_prev=\$ac_option ac_prev= continue fi case $ac_option in *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; *=) ac_optarg= ;; *) ac_optarg=yes ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. case $ac_dashdash$ac_option in --) ac_dashdash=yes ;; -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir=$ac_optarg ;; -build | --build | --buil | --bui | --bu) ac_prev=build_alias ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build_alias=$ac_optarg ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file=$ac_optarg ;; --config-cache | -C) cache_file=config.cache ;; -datadir | --datadir | --datadi | --datad) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=*) datadir=$ac_optarg ;; -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ | --dataroo | --dataro | --datar) ac_prev=datarootdir ;; -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) datarootdir=$ac_optarg ;; -disable-* | --disable-*) ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=no ;; -docdir | --docdir | --docdi | --doc | --do) ac_prev=docdir ;; -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) docdir=$ac_optarg ;; -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) ac_prev=dvidir ;; -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) dvidir=$ac_optarg ;; -enable-* | --enable-*) ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=\$ac_optarg ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix=$ac_optarg ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he | -h) ac_init_help=long ;; -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) ac_init_help=recursive ;; -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) ac_init_help=short ;; -host | --host | --hos | --ho) ac_prev=host_alias ;; -host=* | --host=* | --hos=* | --ho=*) host_alias=$ac_optarg ;; -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) ac_prev=htmldir ;; -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ | --ht=*) htmldir=$ac_optarg ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir=$ac_optarg ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir=$ac_optarg ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir=$ac_optarg ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir=$ac_optarg ;; -localedir | --localedir | --localedi | --localed | --locale) ac_prev=localedir ;; -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) localedir=$ac_optarg ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst | --locals) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir=$ac_optarg ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c | -n) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir=$ac_optarg ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix=$ac_optarg ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix=$ac_optarg ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix=$ac_optarg ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name=$ac_optarg ;; -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) ac_prev=pdfdir ;; -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) pdfdir=$ac_optarg ;; -psdir | --psdir | --psdi | --psd | --ps) ac_prev=psdir ;; -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) psdir=$ac_optarg ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir=$ac_optarg ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir=$ac_optarg ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site=$ac_optarg ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir=$ac_optarg ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir=$ac_optarg ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target_alias ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target_alias=$ac_optarg ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers | -V) ac_init_version=: ;; -with-* | --with-*) ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=\$ac_optarg ;; -without-* | --without-*) ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=no ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes=$ac_optarg ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; -*) as_fn_error $? "unrecognized option: \`$ac_option' Try \`$0 --help' for more information" ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. case $ac_envvar in #( '' | [0-9]* | *[!_$as_cr_alnum]* ) as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; esac eval $ac_envvar=\$ac_optarg export $ac_envvar ;; *) # FIXME: should be removed in autoconf 3.0. $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" ;; esac done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` as_fn_error $? "missing argument to $ac_option" fi if test -n "$ac_unrecognized_opts"; then case $enable_option_checking in no) ;; fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; esac fi # Check all directory arguments for consistency. for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ libdir localedir mandir do eval ac_val=\$$ac_var # Remove trailing slashes. case $ac_val in */ ) ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` eval $ac_var=\$ac_val;; esac # Be sure to have absolute directory names. case $ac_val in [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" done # There might be people who depend on the old broken behavior: `$host' # used to hold the argument of --host etc. # FIXME: To remove some day. build=$build_alias host=$host_alias target=$target_alias # FIXME: To remove some day. if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi fi ac_tool_prefix= test -n "$host_alias" && ac_tool_prefix=$host_alias- test "$silent" = yes && exec 6>/dev/null ac_pwd=`pwd` && test -n "$ac_pwd" && ac_ls_di=`ls -di .` && ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || as_fn_error $? "working directory cannot be determined" test "X$ac_ls_di" = "X$ac_pwd_ls_di" || as_fn_error $? "pwd does not report name of working directory" # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then the parent directory. ac_confdir=`$as_dirname -- "$as_myself" || $as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_myself" : 'X\(//\)[^/]' \| \ X"$as_myself" : 'X\(//\)$' \| \ X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_myself" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` srcdir=$ac_confdir if test ! -r "$srcdir/$ac_unique_file"; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" fi ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ac_abs_confdir=`( cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" pwd)` # When building in place, set srcdir=. if test "$ac_abs_confdir" = "$ac_pwd"; then srcdir=. fi # Remove unnecessary trailing slashes from srcdir. # Double slashes in file names in object file debugging info # mess up M-x gdb in Emacs. case $srcdir in */) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; esac for ac_var in $ac_precious_vars; do eval ac_env_${ac_var}_set=\${${ac_var}+set} eval ac_env_${ac_var}_value=\$${ac_var} eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} eval ac_cv_env_${ac_var}_value=\$${ac_var} done # # Report the --help message. # if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF \`configure' configures rJava 0.8 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. Configuration: -h, --help display this help and exit --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit -q, --quiet, --silent do not print \`checking ...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or \`..'] Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX] By default, \`make install' will install all the files in \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify an installation prefix other than \`$ac_default_prefix' using \`--prefix', for instance \`--prefix=\$HOME'. For better control, use the options below. Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] --datadir=DIR read-only architecture-independent data [DATAROOTDIR] --infodir=DIR info documentation [DATAROOTDIR/info] --localedir=DIR locale-dependent data [DATAROOTDIR/locale] --mandir=DIR man documentation [DATAROOTDIR/man] --docdir=DIR documentation root [DATAROOTDIR/doc/rjava] --htmldir=DIR html documentation [DOCDIR] --dvidir=DIR dvi documentation [DOCDIR] --pdfdir=DIR pdf documentation [DOCDIR] --psdir=DIR ps documentation [DOCDIR] _ACEOF cat <<\_ACEOF _ACEOF fi if test -n "$ac_init_help"; then case $ac_init_help in short | recursive ) echo "Configuration of rJava 0.8:";; esac cat <<\_ACEOF Optional Features: --disable-option-checking ignore unrecognized --enable/--with options --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --enable-threads enable the use of threads, i.e. Java is run on a separate thread. This is necessary for some implementations of AWT. This feature is highly experimental, becasue of synchronization issues, so use with care. [no] --enable-jni-cache enable support for caching of the JNI environment. With this option turned on, the JNI state is stored locally and re-used for subsequent calls. This will work *only* if no threads are used, because each thread has a separate JNI state. Enabling this option can give some performance boost for applications that call JNI very often. If used in a threaded environment, it is bound to crash, so use with care. [no] --enable-jri enable Java to R interface (JRI), which allows Java programs to embed R. [auto] --enable-headless enable initialization in headless mode. [auto] --enable-debug enable debug flags and output. [no] --enable-mem-profile enable memory profiling. [debug] --enable-callbacks enable the support for callbacks from Java into R. This requires JRI and is currently experimental/incomplete. [no] Some influential environment variables: CC C compiler command CFLAGS C compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory LIBS libraries to pass to the linker, e.g. -l CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory CPP C preprocessor Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. Report bugs to . _ACEOF ac_status=$? fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue test -d "$ac_dir" || { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || continue ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix cd "$ac_dir" || { ac_status=$?; continue; } # Check for guested configure. if test -f "$ac_srcdir/configure.gnu"; then echo && $SHELL "$ac_srcdir/configure.gnu" --help=recursive elif test -f "$ac_srcdir/configure"; then echo && $SHELL "$ac_srcdir/configure" --help=recursive else $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi || ac_status=$? cd "$ac_pwd" || { ac_status=$?; break; } done fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF rJava configure 0.8 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF exit fi ## ------------------------ ## ## Autoconf initialization. ## ## ------------------------ ## # ac_fn_c_try_compile LINENO # -------------------------- # Try to compile conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_compile # ac_fn_c_try_cpp LINENO # ---------------------- # Try to preprocess conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_cpp () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } > conftest.i && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_cpp # ac_fn_c_try_run LINENO # ---------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. Assumes # that executables *can* be run. ac_fn_c_try_run () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then : ac_retval=0 else $as_echo "$as_me: program exited with status $ac_status" >&5 $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=$ac_status fi rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_run # ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists, giving a warning if it cannot be compiled using # the include files in INCLUDES and setting the cache variable VAR # accordingly. ac_fn_c_check_header_mongrel () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if eval \${$3+:} false; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } else # Is the header compilable? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 $as_echo_n "checking $2 usability... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_header_compiler=yes else ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 $as_echo "$ac_header_compiler" >&6; } # Is the header present? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 $as_echo_n "checking $2 presence... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include <$2> _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : ac_header_preproc=yes else ac_header_preproc=no fi rm -f conftest.err conftest.i conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 $as_echo "$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #(( yes:no: ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 $as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ;; no:yes:* ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 $as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 $as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 $as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 $as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ( $as_echo "## ------------------------------------------ ## ## Report this to Simon.Urbanek@r-project.org ## ## ------------------------------------------ ##" ) | sed "s/^/$as_me: WARNING: /" >&2 ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=\$ac_header_compiler" fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_mongrel # ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists and can be compiled using the include files in # INCLUDES, setting the cache variable VAR accordingly. ac_fn_c_check_header_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_compile # ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES # --------------------------------------------- # Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR # accordingly. ac_fn_c_check_decl () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack as_decl_name=`echo $2|sed 's/ *(.*//'` as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'` { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5 $as_echo_n "checking whether $as_decl_name is declared... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { #ifndef $as_decl_name #ifdef __cplusplus (void) $as_decl_use; #else (void) $as_decl_name; #endif #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_decl # ac_fn_c_try_link LINENO # ----------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_link () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext conftest$ac_exeext if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || test -x conftest$ac_exeext }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would # interfere with the next link command; also delete a directory that is # left behind by Apple's compiler. We do this before executing the actions. rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_link cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by rJava $as_me 0.8, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ _ACEOF exec 5>>config.log { cat <<_ASUNAME ## --------- ## ## Platform. ## ## --------- ## hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` /usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` _ASUNAME as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. $as_echo "PATH: $as_dir" done IFS=$as_save_IFS } >&5 cat >&5 <<_ACEOF ## ----------- ## ## Core tests. ## ## ----------- ## _ACEOF # Keep a trace of the command line. # Strip out --no-create and --no-recursion so they do not pile up. # Strip out --silent because we don't want to record it for future runs. # Also quote any args containing shell meta-characters. # Make two passes to allow for proper duplicate-argument suppression. ac_configure_args= ac_configure_args0= ac_configure_args1= ac_must_keep_next=false for ac_pass in 1 2 do for ac_arg do case $ac_arg in -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) continue ;; *\'*) ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; 2) as_fn_append ac_configure_args1 " '$ac_arg'" if test $ac_must_keep_next = true; then ac_must_keep_next=false # Got value, back to normal. else case $ac_arg in *=* | --config-cache | -C | -disable-* | --disable-* \ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ | -with-* | --with-* | -without-* | --without-* | --x) case "$ac_configure_args0 " in "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; esac ;; -* ) ac_must_keep_next=true ;; esac fi as_fn_append ac_configure_args " '$ac_arg'" ;; esac done done { ac_configure_args0=; unset ac_configure_args0;} { ac_configure_args1=; unset ac_configure_args1;} # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. # WARNING: Use '\'' to represent an apostrophe within the trap. # WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. trap 'exit_status=$? # Save into config.log some information that might help in debugging. { echo $as_echo "## ---------------- ## ## Cache variables. ## ## ---------------- ##" echo # The following way of writing the cache mishandles newlines in values, ( for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( *${as_nl}ac_space=\ *) sed -n \ "s/'\''/'\''\\\\'\'''\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" ;; #( *) sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) echo $as_echo "## ----------------- ## ## Output variables. ## ## ----------------- ##" echo for ac_var in $ac_subst_vars do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo if test -n "$ac_subst_files"; then $as_echo "## ------------------- ## ## File substitutions. ## ## ------------------- ##" echo for ac_var in $ac_subst_files do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo fi if test -s confdefs.h; then $as_echo "## ----------- ## ## confdefs.h. ## ## ----------- ##" echo cat confdefs.h echo fi test "$ac_signal" != 0 && $as_echo "$as_me: caught signal $ac_signal" $as_echo "$as_me: exit $exit_status" } >&5 rm -f core *.core core.conftest.* && rm -f -r conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status ' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -f -r conftest* confdefs.h $as_echo "/* confdefs.h */" > confdefs.h # Predefined preprocessor variables. cat >>confdefs.h <<_ACEOF #define PACKAGE_NAME "$PACKAGE_NAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_TARNAME "$PACKAGE_TARNAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_VERSION "$PACKAGE_VERSION" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_STRING "$PACKAGE_STRING" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_URL "$PACKAGE_URL" _ACEOF # Let the site file select an alternate cache file if it wants to. # Prefer an explicitly selected file to automatically selected ones. ac_site_file1=NONE ac_site_file2=NONE if test -n "$CONFIG_SITE"; then # We do not want a PATH search for config.site. case $CONFIG_SITE in #(( -*) ac_site_file1=./$CONFIG_SITE;; */*) ac_site_file1=$CONFIG_SITE;; *) ac_site_file1=./$CONFIG_SITE;; esac elif test "x$prefix" != xNONE; then ac_site_file1=$prefix/share/config.site ac_site_file2=$prefix/etc/config.site else ac_site_file1=$ac_default_prefix/share/config.site ac_site_file2=$ac_default_prefix/etc/config.site fi for ac_site_file in "$ac_site_file1" "$ac_site_file2" do test "x$ac_site_file" = xNONE && continue if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 $as_echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" \ || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "failed to load site script $ac_site_file See \`config.log' for more details" "$LINENO" 5; } fi done if test -r "$cache_file"; then # Some versions of bash will fail to source /dev/null (special files # actually), so we avoid doing that. DJGPP emulates it as a regular file. if test /dev/null != "$cache_file" && test -f "$cache_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 $as_echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . "$cache_file";; *) . "./$cache_file";; esac fi else { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 $as_echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false for ac_var in $ac_precious_vars; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set eval ac_old_val=\$ac_cv_env_${ac_var}_value eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then # differences in whitespace do not lead to failure. ac_old_val_w=`echo x $ac_old_val` ac_new_val_w=`echo x $ac_new_val` if test "$ac_old_val_w" != "$ac_new_val_w"; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 $as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} ac_cache_corrupted=: else { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 $as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} eval $ac_var=\$ac_old_val fi { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 $as_echo "$as_me: former value: \`$ac_old_val'" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 $as_echo "$as_me: current value: \`$ac_new_val'" >&2;} fi;; esac # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. *) as_fn_append ac_configure_args " '$ac_arg'" ;; esac fi done if $ac_cache_corrupted; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 fi ## -------------------- ## ## Main body of script. ## ## -------------------- ## ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_config_headers="$ac_config_headers src/config.h" # find R home and set CC/CFLAGS : ${R_HOME=`R RHOME`} if test -z "${R_HOME}"; then echo "could not determine R_HOME" exit 1 fi RBIN="${R_HOME}/bin/R" CC=`"${RBIN}" CMD config CC`; CFLAGS=`"${RBIN}" CMD config CFLAGS` LIBS="${PKG_LIBS}" RLD=`"${RBIN}" CMD config --ldflags 2>/dev/null` has_R_shlib=no if test -n "$RLD"; then has_R_shlib=yes fi ## enable threads, i.e. Java is running is a separate thread # Check whether --enable-threads was given. if test "${enable_threads+set}" = set; then : enableval=$enable_threads; want_threads="${enableval}" else want_threads=no fi ## enable JNI-cache # Check whether --enable-jni-cache was given. if test "${enable_jni_cache+set}" = set; then : enableval=$enable_jni_cache; want_jni_cache="${enableval}" else want_jni_cache=no fi ## enable JRI # Check whether --enable-jri was given. if test "${enable_jri+set}" = set; then : enableval=$enable_jri; want_jri="${enableval}" else want_jri=auto fi ## enable headless # Check whether --enable-headless was given. if test "${enable_headless+set}" = set; then : enableval=$enable_headless; want_headless="${enableval}" else want_headless=auto fi ## enable debug flags # Check whether --enable-debug was given. if test "${enable_debug+set}" = set; then : enableval=$enable_debug; want_debug="${enableval}" else want_debug=no fi ## enable memory profiling # Check whether --enable-mem-profile was given. if test "${enable_mem_profile+set}" = set; then : enableval=$enable_mem_profile; want_memprof="${enableval}" else want_memprof=debug fi ## enable callbacks (experimental) # Check whether --enable-callbacks was given. if test "${enable_callbacks+set}" = set; then : enableval=$enable_callbacks; want_callbacks="${enableval}" else want_callbacks=no fi # Checks for programs. ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then for ac_prog in cl.exe do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC for ac_prog in cl.exe do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CC" && break done if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi fi fi test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "no acceptable C compiler found in \$PATH See \`config.log' for more details" "$LINENO" 5; } # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 $as_echo_n "checking whether the C compiler works... " >&6; } ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` # The possible output files: ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" ac_rmfiles= for ac_file in $ac_files do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; * ) ac_rmfiles="$ac_rmfiles $ac_file";; esac done rm -f $ac_rmfiles if { { ac_try="$ac_link_default" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link_default") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. # So ignore a value of `no', otherwise this would lead to `EXEEXT = no' # in a Makefile. We should not override ac_cv_exeext if it was cached, # so that the user can short-circuit this test for compilers unknown to # Autoconf. for ac_file in $ac_files '' do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; [ab].out ) # We found the default executable, but exeext='' is most # certainly right. break;; *.* ) if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; then :; else ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` fi # We set ac_cv_exeext here because the later test for it is not # safe: cross compilers may not add the suffix if given an `-o' # argument, so we may need to know it at that point already. # Even if this section looks crufty: it has the advantage of # actually working. break;; * ) break;; esac done test "$ac_cv_exeext" = no && ac_cv_exeext= else ac_file='' fi if test -z "$ac_file"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "C compiler cannot create executables See \`config.log' for more details" "$LINENO" 5; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 $as_echo_n "checking for C compiler default output file name... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 $as_echo "$ac_file" >&6; } ac_exeext=$ac_cv_exeext rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 $as_echo_n "checking for suffix of executables... " >&6; } if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with # `rm'. for ac_file in conftest.exe conftest conftest.*; do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` break;; * ) break;; esac done else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of executables: cannot compile and link See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest conftest$ac_cv_exeext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 $as_echo "$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { FILE *f = fopen ("conftest.out", "w"); return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF ac_clean_files="$ac_clean_files conftest.out" # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 $as_echo_n "checking whether we are cross compiling... " >&6; } if test "$cross_compiling" != yes; then { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if { ac_try='./conftest$ac_cv_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details" "$LINENO" 5; } fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 $as_echo "$cross_compiling" >&6; } rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 $as_echo_n "checking for suffix of object files... " >&6; } if ${ac_cv_objext+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.o conftest.obj if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : for ac_file in conftest.o conftest.obj conftest.*; do test -f "$ac_file" || continue; case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac done else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of object files: cannot compile See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 $as_echo "$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } if ${ac_cv_c_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_compiler_gnu=yes else ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 $as_echo "$ac_cv_c_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GCC=yes else GCC= fi ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } if ${ac_cv_prog_cc_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes else CFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 $as_echo "$ac_cv_prog_cc_g" >&6; } if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } if ${ac_cv_prog_cc_c89+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include struct stat; /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); static char *e (p, i) char **p; int i; { return p[i]; } static char *f (char * (*g) (char **, int), char **p, ...) { char *s; va_list v; va_start (v,p); s = g (p, va_arg (v,int)); va_end (v); return s; } /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not '\xHH' hex character constants. These don't provoke an error unfortunately, instead are silently treated as 'x'. The following induces an error, until -std is added to get proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an array size at least. It's necessary to write '\x00'==0 to get something that's true only with -std. */ int osf4_cc_array ['\x00' == 0 ? 1 : -1]; /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters inside strings and character constants. */ #define FOO(x) 'x' int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); int argc; char **argv; int main () { return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ; return 0; } _ACEOF for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_c89=$ac_arg fi rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c89" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi # AC_CACHE_VAL case "x$ac_cv_prog_cc_c89" in x) { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 $as_echo "none needed" >&6; } ;; xno) { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 $as_echo "unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c89" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 $as_echo "$ac_cv_prog_cc_c89" >&6; } ;; esac if test "x$ac_cv_prog_cc_c89" != xno; then : fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu # Checks for libraries. # Checks for header files. ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 $as_echo_n "checking how to run the C preprocessor... " >&6; } # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then if ${ac_cv_prog_CPP+:} false; then : $as_echo_n "(cached) " >&6 else # Double quotes because CPP needs to be expanded for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" do ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : break fi done ac_cv_prog_CPP=$CPP fi CPP=$ac_cv_prog_CPP else ac_cv_prog_CPP=$CPP fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 $as_echo "$CPP" >&6; } ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details" "$LINENO" 5; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 $as_echo_n "checking for grep that handles long lines and -e... " >&6; } if ${ac_cv_path_GREP+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$GREP"; then ac_path_GREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in grep ggrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_GREP" || continue # Check for GNU ac_path_GREP and select it if it is found. # Check for GNU $ac_path_GREP case `"$ac_path_GREP" --version 2>&1` in *GNU*) ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'GREP' >> "conftest.nl" "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_GREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_GREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_GREP"; then as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_GREP=$GREP fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 $as_echo "$ac_cv_path_GREP" >&6; } GREP="$ac_cv_path_GREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 $as_echo_n "checking for egrep... " >&6; } if ${ac_cv_path_EGREP+:} false; then : $as_echo_n "(cached) " >&6 else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 then ac_cv_path_EGREP="$GREP -E" else if test -z "$EGREP"; then ac_path_EGREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in egrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_EGREP" || continue # Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP case `"$ac_path_EGREP" --version 2>&1` in *GNU*) ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'EGREP' >> "conftest.nl" "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_EGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_EGREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_EGREP"; then as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_EGREP=$EGREP fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 $as_echo "$ac_cv_path_EGREP" >&6; } EGREP="$ac_cv_path_EGREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } if ${ac_cv_header_stdc+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_stdc=yes else ac_cv_header_stdc=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "memchr" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "free" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #if ((' ' & 0x0FF) == 0x020) # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #else # define ISLOWER(c) \ (('a' <= (c) && (c) <= 'i') \ || ('j' <= (c) && (c) <= 'r') \ || ('s' <= (c) && (c) <= 'z')) # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) #endif #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) return 2; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : else ac_cv_header_stdc=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 $as_echo "$ac_cv_header_stdc" >&6; } if test $ac_cv_header_stdc = yes; then $as_echo "#define STDC_HEADERS 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sys/wait.h that is POSIX.1 compatible" >&5 $as_echo_n "checking for sys/wait.h that is POSIX.1 compatible... " >&6; } if ${ac_cv_header_sys_wait_h+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #ifndef WEXITSTATUS # define WEXITSTATUS(stat_val) ((unsigned int) (stat_val) >> 8) #endif #ifndef WIFEXITED # define WIFEXITED(stat_val) (((stat_val) & 255) == 0) #endif int main () { int s; wait (&s); s = WIFEXITED (s) ? WEXITSTATUS (s) : 1; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_sys_wait_h=yes else ac_cv_header_sys_wait_h=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_sys_wait_h" >&5 $as_echo "$ac_cv_header_sys_wait_h" >&6; } if test $ac_cv_header_sys_wait_h = yes; then $as_echo "#define HAVE_SYS_WAIT_H 1" >>confdefs.h fi # On IRIX 5.3, sys/types and inttypes.h are conflicting. for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ inttypes.h stdint.h unistd.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default " if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done for ac_header in string.h sys/time.h unistd.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done # Checks for typedefs, structures, and compiler characteristics. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for an ANSI C-conforming const" >&5 $as_echo_n "checking for an ANSI C-conforming const... " >&6; } if ${ac_cv_c_const+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __cplusplus /* Ultrix mips cc rejects this sort of thing. */ typedef int charset[2]; const charset cs = { 0, 0 }; /* SunOS 4.1.1 cc rejects this. */ char const *const *pcpcc; char **ppc; /* NEC SVR4.0.2 mips cc rejects this. */ struct point {int x, y;}; static struct point const zero = {0,0}; /* AIX XL C 1.02.0.0 rejects this. It does not let you subtract one const X* pointer from another in an arm of an if-expression whose if-part is not a constant expression */ const char *g = "string"; pcpcc = &g + (g ? g-g : 0); /* HPUX 7.0 cc rejects these. */ ++pcpcc; ppc = (char**) pcpcc; pcpcc = (char const *const *) ppc; { /* SCO 3.2v4 cc rejects this sort of thing. */ char tx; char *t = &tx; char const *s = 0 ? (char *) 0 : (char const *) 0; *t++ = 0; if (s) return 0; } { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */ int x[] = {25, 17}; const int *foo = &x[0]; ++foo; } { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */ typedef const int *iptr; iptr p = 0; ++p; } { /* AIX XL C 1.02.0.0 rejects this sort of thing, saying "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ struct s { int j; const int *ap[3]; } bx; struct s *b = &bx; b->j = 5; } { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ const int foo = 10; if (!foo) return 0; } return !cs[0] && !zero.x; #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_const=yes else ac_cv_c_const=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_const" >&5 $as_echo "$ac_cv_c_const" >&6; } if test $ac_cv_c_const = no; then $as_echo "#define const /**/" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether time.h and sys/time.h may both be included" >&5 $as_echo_n "checking whether time.h and sys/time.h may both be included... " >&6; } if ${ac_cv_header_time+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include int main () { if ((struct tm *) 0) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_time=yes else ac_cv_header_time=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_time" >&5 $as_echo "$ac_cv_header_time" >&6; } if test $ac_cv_header_time = yes; then $as_echo "#define TIME_WITH_SYS_TIME 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${CC} supports static inline..." >&5 $as_echo "$as_me: checking whether ${CC} supports static inline..." >&6;} can_inline=no cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ static inline int foo(int a, int b); static f = 1; static inline int foo(int a, int b) { return a+b; } int main(void) { return foo(f,-1); } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : can_inline=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${can_inline}" >&5 $as_echo "${can_inline}" >&6; } if test "${can_inline}" = yes; then $as_echo "#define HAVE_STATIC_INLINE 1" >>confdefs.h fi ### from R m4/R.m4 - needed to hack R 2.9.x { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether setjmp.h is POSIX.1 compatible" >&5 $as_echo_n "checking whether setjmp.h is POSIX.1 compatible... " >&6; } if ${r_cv_header_setjmp_posix+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { sigjmp_buf b; sigsetjmp(b, 0); siglongjmp(b, 1); ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : r_cv_header_setjmp_posix=yes else r_cv_header_setjmp_posix=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $r_cv_header_setjmp_posix" >&5 $as_echo "$r_cv_header_setjmp_posix" >&6; } ac_fn_c_check_decl "$LINENO" "sigsetjmp" "ac_cv_have_decl_sigsetjmp" "#include " if test "x$ac_cv_have_decl_sigsetjmp" = xyes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_SIGSETJMP $ac_have_decl _ACEOF ac_fn_c_check_decl "$LINENO" "siglongjmp" "ac_cv_have_decl_siglongjmp" "#include " if test "x$ac_cv_have_decl_siglongjmp" = xyes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_SIGLONGJMP $ac_have_decl _ACEOF if test "$ac_cv_have_decl_sigsetjmp" = no; then r_cv_header_setjmp_posix=no fi if test "$ac_cv_have_decl_siglongjmp" = no; then r_cv_header_setjmp_posix=no fi if test "${r_cv_header_setjmp_posix}" = yes; then $as_echo "#define HAVE_POSIX_SETJMP 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking Java support in R" >&5 $as_echo_n "checking Java support in R... " >&6; } R_JAVA_HOME=`"${RBIN}" CMD config JAVA_HOME` : ${JAVA_HOME="${R_JAVA_HOME}"} if test -z "${JAVA_HOME}"; then as_fn_error $? "absent R was configured without Java support. Please run R CMD javareconf as root to add Java support to R. If you do not have root privileges, run R CMD javareconf -e to set all Java-related variables and then install rJava." "$LINENO" 5 fi : ${JAR=`"${RBIN}" CMD config JAR|sed 's/ERROR:.*//'`} : ${JAVA=`"${RBIN}" CMD config JAVA|sed 's/ERROR:.*//'`} : ${JAVAC=`"${RBIN}" CMD config JAVAC|sed 's/ERROR:.*//'`} : ${JAVAH=`"${RBIN}" CMD config JAVAH|sed 's/ERROR:.*//'`} : ${JAVA_CPPFLAGS=`"${RBIN}" CMD config JAVA_CPPFLAGS|sed 's/ERROR:.*//'`} : ${JAVA_LIBS=`"${RBIN}" CMD config JAVA_LIBS|sed 's/ERROR:.*//'`} { $as_echo "$as_me:${as_lineno-$LINENO}: result: present: interpreter : '${JAVA}' archiver : '${JAR}' compiler : '${JAVAC}' header prep.: '${JAVAH}' cpp flags : '${JAVA_CPPFLAGS}' java libs : '${JAVA_LIBS}'" >&5 $as_echo "present: interpreter : '${JAVA}' archiver : '${JAR}' compiler : '${JAVAC}' header prep.: '${JAVAH}' cpp flags : '${JAVA_CPPFLAGS}' java libs : '${JAVA_LIBS}'" >&6; } java_error='One or more Java configuration variables are not set.' if test -z "${JAVA}"; then java_error='Java interpreter is missing or not registered in R' fi if test -z "${JAVAC}"; then java_error='Java Development Kit (JDK) is missing or not registered in R' fi have_all_flags=no if test -n "${JAVA}" && test -n "${JAVAC}" && test -n "${JAVAH}" && \ test -n "${JAVA_CPPFLAGS}" && test -n "${JAVA_LIBS}" && test -n "${JAR}"; then have_all_flags=yes; fi if test "${have_all_flags}" = no; then as_fn_error $? "${java_error} Make sure R is configured with full Java support (including JDK). Run R CMD javareconf as root to add Java support to R. If you don't have root privileges, run R CMD javareconf -e to set all Java-related variables and then install rJava. " "$LINENO" 5 fi if test `echo foo | sed -e 's:foo:bar:'` = bar; then JAVA_CPPFLAGS0=`echo ${JAVA_CPPFLAGS} | sed -e 's:$(JAVA_HOME):'${JAVA_HOME}':g'` JAVA_LIBS0=`echo ${JAVA_LIBS} | sed -e 's:$(JAVA_HOME):'${JAVA_HOME}':g'` JAVA_LD_LIBRARY_PATH0=`echo ${JAVA_LD_LIBRARY_PATH} | sed -e 's:$(JAVA_HOME):'${JAVA_HOME}':g'` else { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: sed is not working properly - the configuration may fail" >&5 $as_echo "$as_me: WARNING: sed is not working properly - the configuration may fail" >&2;} JAVA_CPPFLAGS0="${JAVA_CPPFLAGS}" JAVA_LIBS0="${JAVA_LIBS}" JAVA_LD_LIBRARY_PATH0="${JAVA_LD_LIBRARY_PATH}" fi LIBS="${LIBS} ${JAVA_LIBS0}" CFLAGS="${CFLAGS} ${JAVA_CPPFLAGS0}" LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${JAVA_LD_LIBRARY_PATH0}" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether Java run-time works" >&5 $as_echo_n "checking whether Java run-time works... " >&6; } if "$JAVA" getsp; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } as_fn_error $? "Java interpreter '$JAVA' does not work" "$LINENO" 5 fi has_xrs=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -Xrs is supported" >&5 $as_echo_n "checking whether -Xrs is supported... " >&6; } if "$JAVA" -Xrs getsp; then has_xrs=yes $as_echo "#define HAVE_XRS 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${has_xrs}" >&5 $as_echo "${has_xrs}" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether JNI programs can be compiled" >&5 $as_echo_n "checking whether JNI programs can be compiled... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main(void) { jobject o; JNI_CreateJavaVM(0, 0, 0); return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else as_fn_error $? "Cannot compile a simple JNI program. See config.log for details. Make sure you have Java Development Kit installed and correctly registered in R. If in doubt, re-run \"R CMD javareconf\" as root. " "$LINENO" 5 fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: checking JNI data types" >&5 $as_echo_n "checking JNI data types... " >&6; } if test "$cross_compiling" = yes; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: don't know (cross-compiling)" >&5 $as_echo "don't know (cross-compiling)" >&6; } else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main(void) { return (sizeof(int)==sizeof(jint) && sizeof(long)==sizeof(long) && sizeof(jbyte)==sizeof(char) && sizeof(jshort)==sizeof(short) && sizeof(jfloat)==sizeof(float) && sizeof(jdouble)==sizeof(double))?0:1; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 $as_echo "ok" >&6; } else as_fn_error $? "One or more JNI types differ from the corresponding native type. You may need to use non-standard compiler flags or a different compiler in order to fix this." "$LINENO" 5 fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi if test "${want_jri}" = auto; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether JRI should be compiled (autodetect)" >&5 $as_echo_n "checking whether JRI should be compiled (autodetect)... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${has_R_shlib}" >&5 $as_echo "${has_R_shlib}" >&6; } want_jri=${has_R_shlib} fi if test "x${want_jri}" = xyes; then WANT_JRI_TRUE= WANT_JRI_FALSE='#' else WANT_JRI_TRUE='#' WANT_JRI_FALSE= fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether debugging output should be enabled" >&5 $as_echo_n "checking whether debugging output should be enabled... " >&6; } if test "${want_debug}" = yes; then JAVA_CPPFLAGS="-g -DRJ_DEBUG ${JAVA_CPPFLAGS}" { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether memory profiling is desired" >&5 $as_echo_n "checking whether memory profiling is desired... " >&6; } if test "${want_memprof}" = debug; then want_memprof="${want_debug}" fi if test "${want_memprof}" = yes; then $as_echo "#define MEMPROF 1" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi use_threads=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether threads support is requested" >&5 $as_echo_n "checking whether threads support is requested... " >&6; } if test "${want_threads}" = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether threads can be enabled" >&5 $as_echo_n "checking whether threads can be enabled... " >&6; } # check whether we can add THREADS support UNAME=`uname` # we don't want to run full AC_CANONICAL_HOST, all we care about is OS X if test "x$UNAME" == "xDarwin"; then use_threads=yes $as_echo "#define THREADS 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${use_threads}" >&5 $as_echo "${use_threads}" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi ## enable callbacks if desired { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether callbacks support is requested" >&5 $as_echo_n "checking whether callbacks support is requested... " >&6; } if test "${want_callbacks}" = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } if test "${want_jri}" != yes; then as_fn_error $? "Callbacks support can be only enabled if JRI is enabled as well." "$LINENO" 5 fi $as_echo "#define ENABLE_JRICB 1" >>confdefs.h else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether JNI cache support is requested" >&5 $as_echo_n "checking whether JNI cache support is requested... " >&6; } if test "${want_jni_cache}" = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } if test "${use_threads}" = yes; then as_fn_error $? "Threads and JNI cache cannot be used at the same time, because JNI cache is by definition not thread-safe. Please disable either option." "$LINENO" 5 fi $as_echo "#define JNI_CACHE 1" >>confdefs.h else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether headless init is enabled" >&5 $as_echo_n "checking whether headless init is enabled... " >&6; } if test "${want_headless}" = auto; then want_headless=no ## only Darwin defaults to headless if test x`uname -s 2>/dev/null` = xDarwin; then want_headless=yes fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${want_headless}" >&5 $as_echo "${want_headless}" >&6; } if test "${want_headless}" = yes; then $as_echo "#define USE_HEADLESS_INIT 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether JRI is requested" >&5 $as_echo_n "checking whether JRI is requested... " >&6; } if test "${want_jri}" = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } export R_HOME export JAVA_HOME JAVA_CPPFLAGS JAVA_LIBS JAVA_LD_LIBRARY_PATH JAVA JAVAC JAVAH JAR CONFIGURED=1 export CONFIGURED ac_aux_dir= for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do if test -f "$ac_dir/install-sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install-sh -c" break elif test -f "$ac_dir/install.sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install.sh -c" break elif test -f "$ac_dir/shtool"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/shtool install -c" break fi done if test -z "$ac_aux_dir"; then as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5 fi # These three variables are undocumented and unsupported, # and are intended to be withdrawn in a future Autoconf release. # They can cause serious problems if a builder's source tree is in a directory # whose full name contains unusual characters. ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. subdirs="$subdirs jri" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi ac_config_files="$ac_config_files src/Makevars" ac_config_files="$ac_config_files R/zzz.R" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs, see configure's option --config-cache. # It is not useful on other systems. If it contains results you don't # want to keep, you may remove or edit it. # # config.status only pays attention to the cache file if you give it # the --recheck option to rerun configure. # # `ac_cv_env_foo' variables (set or unset) will be overridden when # loading this file, other *unset* `ac_cv_foo' will be assigned the # following values. _ACEOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, we kill variables containing newlines. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. ( for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space=' '; set) 2>&1` in #( *${as_nl}ac_space=\ *) # `set' does not quote correctly, so add quotes: double-quote # substitution turns \\\\ into \\, and sed turns \\ into \. sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" ;; #( *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) | sed ' /^ac_cv_env_/b end t clear :clear s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ t end s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then if test "x$cache_file" != "x/dev/null"; then { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 $as_echo "$as_me: updating cache $cache_file" >&6;} if test ! -f "$cache_file" || test -h "$cache_file"; then cat confcache >"$cache_file" else case $cache_file in #( */* | ?:*) mv -f confcache "$cache_file"$$ && mv -f "$cache_file"$$ "$cache_file" ;; #( *) mv -f confcache "$cache_file" ;; esac fi fi else { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi rm -f confcache test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' DEFS=-DHAVE_CONFIG_H ac_libobjs= ac_ltlibobjs= U= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' ac_i=`$as_echo "$ac_i" | sed "$ac_script"` # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR # will be set to the directory where LIBOBJS objects are built. as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' done LIBOBJS=$ac_libobjs LTLIBOBJS=$ac_ltlibobjs if test -z "${WANT_JRI_TRUE}" && test -z "${WANT_JRI_FALSE}"; then as_fn_error $? "conditional \"WANT_JRI\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi : "${CONFIG_STATUS=./config.status}" ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 $as_echo "$as_me: creating $CONFIG_STATUS" >&6;} as_write_fail=0 cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. # Compiler output produced by configure, useful for debugging # configure, is in config.log if it exists. debug=false ac_cs_recheck=false ac_cs_silent=false SHELL=\${CONFIG_SHELL-$SHELL} export SHELL _ASEOF cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -pR' fi else as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi # as_fn_executable_p FILE # ----------------------- # Test if FILE is an executable regular file. as_fn_executable_p () { test -f "$1" && test -x "$1" } # as_fn_executable_p as_test_x='test -x' as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" exec 6>&1 ## ----------------------------------- ## ## Main body of $CONFIG_STATUS script. ## ## ----------------------------------- ## _ASEOF test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Save the log message, to keep $0 and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" This file was extended by rJava $as_me 0.8, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ on `(hostname || uname -n) 2>/dev/null | sed 1q` " _ACEOF case $ac_config_files in *" "*) set x $ac_config_files; shift; ac_config_files=$*;; esac case $ac_config_headers in *" "*) set x $ac_config_headers; shift; ac_config_headers=$*;; esac cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # Files that config.status was made for. config_files="$ac_config_files" config_headers="$ac_config_headers" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ac_cs_usage="\ \`$as_me' instantiates files and other configuration actions from templates according to the current configuration. Unless the files and actions are specified as TAGs, all are instantiated by default. Usage: $0 [OPTION]... [TAG]... -h, --help print this help, then exit -V, --version print version number and configuration settings, then exit --config print configuration, then exit -q, --quiet, --silent do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions --file=FILE[:TEMPLATE] instantiate the configuration file FILE --header=FILE[:TEMPLATE] instantiate the configuration header FILE Configuration files: $config_files Configuration headers: $config_headers Report bugs to ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ rJava config.status 0.8 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" Copyright (C) 2012 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." ac_pwd='$ac_pwd' srcdir='$srcdir' test -n "\$AWK" || AWK=awk _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # The default lists apply if the user does not specify any file. ac_need_defaults=: while test $# != 0 do case $1 in --*=?*) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; --*=) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg= ac_shift=: ;; *) ac_option=$1 ac_optarg=$2 ac_shift=shift ;; esac case $ac_option in # Handling of the options. -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) $as_echo "$ac_cs_version"; exit ;; --config | --confi | --conf | --con | --co | --c ) $as_echo "$ac_cs_config"; exit ;; --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; '') as_fn_error $? "missing file argument" ;; esac as_fn_append CONFIG_FILES " '$ac_optarg'" ac_need_defaults=false;; --header | --heade | --head | --hea ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; esac as_fn_append CONFIG_HEADERS " '$ac_optarg'" ac_need_defaults=false;; --he | --h) # Conflict between --help and --header as_fn_error $? "ambiguous option: \`$1' Try \`$0 --help' for more information.";; --help | --hel | -h ) $as_echo "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; # This is an error. -*) as_fn_error $? "unrecognized option: \`$1' Try \`$0 --help' for more information." ;; *) as_fn_append ac_config_targets " $1" ac_need_defaults=false ;; esac shift done ac_configure_extra_args= if $ac_cs_silent; then exec 6>/dev/null ac_configure_extra_args="$ac_configure_extra_args --silent" fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion shift \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 CONFIG_SHELL='$SHELL' export CONFIG_SHELL exec "\$@" fi _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 exec 5>>config.log { echo sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX $as_echo "$ac_log" } >&5 _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Handling of arguments. for ac_config_target in $ac_config_targets do case $ac_config_target in "src/config.h") CONFIG_HEADERS="$CONFIG_HEADERS src/config.h" ;; "src/Makevars") CONFIG_FILES="$CONFIG_FILES src/Makevars" ;; "R/zzz.R") CONFIG_FILES="$CONFIG_FILES R/zzz.R" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac done # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely # bizarre bug on SunOS 4.1.3. if $ac_need_defaults; then test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers fi # Have a temporary directory for convenience. Make it in the build tree # simply because there is no reason against having it here, and in addition, # creating and moving files from /tmp can sometimes cause problems. # Hook for its removal unless debugging. # Note that there is a small window in which the directory will not be cleaned: # after its creation but before its name has been assigned to `$tmp'. $debug || { tmp= ac_tmp= trap 'exit_status=$? : "${ac_tmp:=$tmp}" { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status ' 0 trap 'as_fn_exit 1' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") } || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 ac_tmp=$tmp # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. # This happens for instance with `./config.status config.h'. if test -n "$CONFIG_FILES"; then ac_cr=`echo X | tr X '\015'` # On cygwin, bash can eat \r inside `` if the user requested igncr. # But we know of no other shell where ac_cr would be empty at this # point, so we can use a bashism as a fallback. if test "x$ac_cr" = x; then eval ac_cr=\$\'\\r\' fi ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then ac_cs_awk_cr='\\r' else ac_cs_awk_cr=$ac_cr fi echo 'BEGIN {' >"$ac_tmp/subs1.awk" && _ACEOF { echo "cat >conf$$subs.awk <<_ACEOF" && echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && echo "_ACEOF" } >conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` ac_delim='%!_!# ' for ac_last_try in false false false false false :; do . ./conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` if test $ac_delim_n = $ac_delim_num; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done rm -f conf$$subs.sh cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && _ACEOF sed -n ' h s/^/S["/; s/!.*/"]=/ p g s/^[^!]*!// :repl t repl s/'"$ac_delim"'$// t delim :nl h s/\(.\{148\}\)..*/\1/ t more1 s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ p n b repl :more1 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t nl :delim h s/\(.\{148\}\)..*/\1/ t more2 s/["\\]/\\&/g; s/^/"/; s/$/"/ p b :more2 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t delim ' >$CONFIG_STATUS || ac_write_fail=1 rm -f conf$$subs.awk cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && for (key in S) S_is_set[key] = 1 FS = "" } { line = $ 0 nfields = split(line, field, "@") substed = 0 len = length(field[1]) for (i = 2; i < nfields; i++) { key = field[i] keylen = length(key) if (S_is_set[key]) { value = S[key] line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) len += length(value) + length(field[++i]) substed = 1 } else len += 1 + keylen } print line } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" else cat fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 _ACEOF # VPATH may cause trouble with some makes, so we remove sole $(srcdir), # ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ h s/// s/^/:/ s/[ ]*$/:/ s/:\$(srcdir):/:/g s/:\${srcdir}:/:/g s/:@srcdir@:/:/g s/^:*// s/:*$// x s/\(=[ ]*\).*/\1/ G s/\n// s/^[^=]*=[ ]*$// }' fi cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 fi # test -n "$CONFIG_FILES" # Set up the scripts for CONFIG_HEADERS section. # No need to generate them if there are no CONFIG_HEADERS. # This happens for instance with `./config.status Makefile'. if test -n "$CONFIG_HEADERS"; then cat >"$ac_tmp/defines.awk" <<\_ACAWK || BEGIN { _ACEOF # Transform confdefs.h into an awk script `defines.awk', embedded as # here-document in config.status, that substitutes the proper values into # config.h.in to produce config.h. # Create a delimiter string that does not exist in confdefs.h, to ease # handling of long lines. ac_delim='%!_!# ' for ac_last_try in false false :; do ac_tt=`sed -n "/$ac_delim/p" confdefs.h` if test -z "$ac_tt"; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done # For the awk script, D is an array of macro values keyed by name, # likewise P contains macro parameters if any. Preserve backslash # newline sequences. ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* sed -n ' s/.\{148\}/&'"$ac_delim"'/g t rset :rset s/^[ ]*#[ ]*define[ ][ ]*/ / t def d :def s/\\$// t bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3"/p s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p d :bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3\\\\\\n"\\/p t cont s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p t cont d :cont n s/.\{148\}/&'"$ac_delim"'/g t clear :clear s/\\$// t bsnlc s/["\\]/\\&/g; s/^/"/; s/$/"/p d :bsnlc s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p b cont ' >$CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 for (key in D) D_is_set[key] = 1 FS = "" } /^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { line = \$ 0 split(line, arg, " ") if (arg[1] == "#") { defundef = arg[2] mac1 = arg[3] } else { defundef = substr(arg[1], 2) mac1 = arg[2] } split(mac1, mac2, "(") #) macro = mac2[1] prefix = substr(line, 1, index(line, defundef) - 1) if (D_is_set[macro]) { # Preserve the white space surrounding the "#". print prefix "define", macro P[macro] D[macro] next } else { # Replace #undef with comments. This is necessary, for example, # in the case of _POSIX_SOURCE, which is predefined and required # on some systems where configure will not decide to define it. if (defundef == "undef") { print "/*", prefix defundef, macro, "*/" next } } } { print } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 fi # test -n "$CONFIG_HEADERS" eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS " shift for ac_tag do case $ac_tag in :[FHLC]) ac_mode=$ac_tag; continue;; esac case $ac_mode$ac_tag in :[FHL]*:*);; :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac ac_save_IFS=$IFS IFS=: set x $ac_tag IFS=$ac_save_IFS shift ac_file=$1 shift case $ac_mode in :L) ac_source=$1;; :[FH]) ac_file_inputs= for ac_f do case $ac_f in -) ac_f="$ac_tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. test -f "$ac_f" || case $ac_f in [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; esac case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac as_fn_append ac_file_inputs " '$ac_f'" done # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ configure_input='Generated from '` $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' `' by configure.' if test x"$ac_file" != x-; then configure_input="$ac_file. $configure_input" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 $as_echo "$as_me: creating $ac_file" >&6;} fi # Neutralize special characters interpreted by sed in replacement strings. case $configure_input in #( *\&* | *\|* | *\\* ) ac_sed_conf_input=`$as_echo "$configure_input" | sed 's/[\\\\&|]/\\\\&/g'`;; #( *) ac_sed_conf_input=$configure_input;; esac case $ac_tag in *:-:* | *:-) cat >"$ac_tmp/stdin" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac ac_dir=`$as_dirname -- "$ac_file" || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir="$ac_dir"; as_fn_mkdir_p ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix case $ac_mode in :F) # # CONFIG_FILE # _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # If the template does not know about datarootdir, expand it. # FIXME: This hack should be removed a few years after 2.60. ac_datarootdir_hack=; ac_datarootdir_seen= ac_sed_dataroot=' /datarootdir/ { p q } /@datadir@/p /@docdir@/p /@infodir@/p /@localedir@/p /@mandir@/p' case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in *datarootdir*) ac_datarootdir_seen=yes;; *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 $as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_datarootdir_hack=' s&@datadir@&$datadir&g s&@docdir@&$docdir&g s&@infodir@&$infodir&g s&@localedir@&$localedir&g s&@mandir@&$mandir&g s&\\\${datarootdir}&$datarootdir&g' ;; esac _ACEOF # Neutralize VPATH when `$srcdir' = `.'. # Shell code in configure.ac might set extrasub. # FIXME: do we really want to maintain this feature? cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_sed_extra="$ac_vpsub $extrasub _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b s|@configure_input@|$ac_sed_conf_input|;t t s&@top_builddir@&$ac_top_builddir_sub&;t t s&@top_build_prefix@&$ac_top_build_prefix&;t t s&@srcdir@&$ac_srcdir&;t t s&@abs_srcdir@&$ac_abs_srcdir&;t t s&@top_srcdir@&$ac_top_srcdir&;t t s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t s&@builddir@&$ac_builddir&;t t s&@abs_builddir@&$ac_abs_builddir&;t t s&@abs_top_builddir@&$ac_abs_top_builddir&;t t $ac_datarootdir_hack " eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ "$ac_tmp/out"`; test -z "$ac_out"; } && { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&5 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&2;} rm -f "$ac_tmp/stdin" case $ac_file in -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; esac \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; :H) # # CONFIG_HEADER # if test x"$ac_file" != x-; then { $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" } >"$ac_tmp/config.h" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 $as_echo "$as_me: $ac_file is unchanged" >&6;} else rm -f "$ac_file" mv "$ac_tmp/config.h" "$ac_file" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 fi else $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ || as_fn_error $? "could not create -" "$LINENO" 5 fi ;; esac done # for ac_tag as_fn_exit 0 _ACEOF ac_clean_files=$ac_clean_files_save test $ac_write_fail = 0 || as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 # configure is writing to config.log, and then calls config.status. # config.status does its own redirection, appending to config.log. # Unfortunately, on DOS this fails, as config.log is still kept open # by configure, so config.status won't be able to write to it; its # output is simply discarded. So we exec the FD to /dev/null, # effectively closing config.log, so it can be properly (re)opened and # appended to by config.status. When coming back to configure, we # need to make the FD available again. if test "$no_create" != yes; then ac_cs_success=: ac_config_status_args= test "$silent" = yes && ac_config_status_args="$ac_config_status_args --quiet" exec 5>/dev/null $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. $ac_cs_success || as_fn_exit 1 fi # # CONFIG_SUBDIRS section. # if test "$no_recursion" != yes; then # Remove --cache-file, --srcdir, and --disable-option-checking arguments # so they do not pile up. ac_sub_configure_args= ac_prev= eval "set x $ac_configure_args" shift for ac_arg do if test -n "$ac_prev"; then ac_prev= continue fi case $ac_arg in -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* \ | --c=*) ;; --config-cache | -C) ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) ;; --disable-option-checking) ;; *) case $ac_arg in *\'*) ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac as_fn_append ac_sub_configure_args " '$ac_arg'" ;; esac done # Always prepend --prefix to ensure using the same prefix # in subdir configurations. ac_arg="--prefix=$prefix" case $ac_arg in *\'*) ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac ac_sub_configure_args="'$ac_arg' $ac_sub_configure_args" # Pass --silent if test "$silent" = yes; then ac_sub_configure_args="--silent $ac_sub_configure_args" fi # Always prepend --disable-option-checking to silence warnings, since # different subdirs can have different --enable and --with options. ac_sub_configure_args="--disable-option-checking $ac_sub_configure_args" ac_popdir=`pwd` for ac_dir in : $subdirs; do test "x$ac_dir" = x: && continue # Do not complain, so a configure script can configure whichever # parts of a large source tree are present. test -d "$srcdir/$ac_dir" || continue ac_msg="=== configuring in $ac_dir (`pwd`/$ac_dir)" $as_echo "$as_me:${as_lineno-$LINENO}: $ac_msg" >&5 $as_echo "$ac_msg" >&6 as_dir="$ac_dir"; as_fn_mkdir_p ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix cd "$ac_dir" # Check for guested configure; otherwise get Cygnus style configure. if test -f "$ac_srcdir/configure.gnu"; then ac_sub_configure=$ac_srcdir/configure.gnu elif test -f "$ac_srcdir/configure"; then ac_sub_configure=$ac_srcdir/configure elif test -f "$ac_srcdir/configure.in"; then # This should be Cygnus configure. ac_sub_configure=$ac_aux_dir/configure else { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: no configuration information is in $ac_dir" >&5 $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2;} ac_sub_configure= fi # The recursion is here. if test -n "$ac_sub_configure"; then # Make the cache file name correct relative to the subdirectory. case $cache_file in [\\/]* | ?:[\\/]* ) ac_sub_cache_file=$cache_file ;; *) # Relative name. ac_sub_cache_file=$ac_top_build_prefix$cache_file ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: running $SHELL $ac_sub_configure $ac_sub_configure_args --cache-file=$ac_sub_cache_file --srcdir=$ac_srcdir" >&5 $as_echo "$as_me: running $SHELL $ac_sub_configure $ac_sub_configure_args --cache-file=$ac_sub_cache_file --srcdir=$ac_srcdir" >&6;} # The eval makes quoting arguments work. eval "\$SHELL \"\$ac_sub_configure\" $ac_sub_configure_args \ --cache-file=\"\$ac_sub_cache_file\" --srcdir=\"\$ac_srcdir\"" || as_fn_error $? "$ac_sub_configure failed for $ac_dir" "$LINENO" 5 fi cd "$ac_popdir" done fi if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} fi rJava/man/0000755000176200001440000000000012256051760012074 5ustar liggesusersrJava/man/jengine.Rd0000644000176200001440000000230412256051760014001 0ustar liggesusers\name{jengine} \alias{.jengine} \title{ Java callback engineCast a Java object to another class } \description{ \code{.jengine} obtains the current callback engine or starts it. } \usage{ .jengine(start=FALSE, silent=FALSE) } \arguments{ \item{start}{if set to \code{TRUE} then the callback engine is started if it is not yet active} \item{silent}{if set to \code{TRUE} then NULL is returned if there is no engine available. Otherwise an error is raised} } \value{ Returns a Java object reference (\code{jobjRef}) to the current Java callback engine. } \details{ \code{.jengine} can be used to detect whether the engine was started or to start the engine. Before any callbacks from Java into R can be performed, the Java callback engine must be initialized, loading Java/R Interface (JRI). If JRI was not started and \code{start} is set to \code{TRUE} then \code{.jengine} will load necessary classes and start it. Note that JRI is an optional part of rJava and requires R shared library at the moment. By default rJava will continue with installation even if JRI cannot be built. } \seealso{ \code{\link{.jcall}} } \examples{ \dontrun{ .jengine(TRUE) } } \keyword{interface} rJava/man/loader.Rd0000644000176200001440000000124512256051760013633 0ustar liggesusers\name{loader} \alias{.jaddClassPath} \alias{.jclassPath} \title{ Java class loader } \description{ \code{.jaddClassPath} adds directories or JAR files to the class path. \code{.jclassPath} returns a vector containg the current entries in the class path } \usage{ .jaddClassPath(path) .jclassPath() } \arguments{ \item{path}{character string vector listing the paths to add to the class path} } \value{ \code{.jclassPath} returns a charactger vector listing the class path sequence. } %\details{ % %} %\seealso{ % \code{\link{.jpackage}} %} \examples{ \dontrun{ .jaddClassPath("/my/jars/foo.jar","/my/classes/") print(.jclassPath()) } } \keyword{interface} rJava/man/J.Rd0000644000176200001440000000423212256051760012555 0ustar liggesusers\name{J} \alias{J} \title{ High level API for accessing Java } \description{ \code{J} creates a Java class reference or calls a Java method } \usage{ J(class, method, ...) } \arguments{ \item{class}{ java object reference or fully qualified class name in JNI notation (e.g "java/lang/String" ) or standard java notation (e.g "java.lang.String") } \item{method}{ if present then \code{J} results in a method call, otherwise it just creates a class name reference. } \item{\dots}{ optional parameters that will be passed to the method (if the \code{method} argument is present) } } \details{ \code{J} is the high-level access to Java. If the \code{method} argument is missing then \code{code} must be a class name and \code{J} creates a class name reference that can be used either in a call to \code{new} to create a new Java object (e.g. \code{new(J("java.lang.String"), "foo")}) or with \code{$} operator to call a static method (e.g. \code{J("java.lang.Double")$parseDouble("10.2")}.) If the \code{method} argument is present then it must be a string vector of length one which defines the method to be called on the object. } \value{ If \code{method} is missing the the returned value is an object of the class \code{jclassName}. Otherwise the value is the result of the method invocation. In the latter case Java exceptions may be thrown and the function doesn't return. } \note{ \code{J} is a high-level API which is slower than \code{\link{.jnew}} or \code{\link{.jcall}} since it has to use reflection to find the most suitable method. } \seealso{ \code{\link{.jcall}}, \code{\link{.jnew}} } \examples{ \dontshow{.jinit()} if (!nzchar(Sys.getenv("NOAWT"))) { f <- new(J("java.awt.Frame"), "Hello") f$setVisible(TRUE) } J("java.lang.Double")$parseDouble("10.2") J("java.lang.Double", "parseDouble", "10.2" ) Double <- J("java.lang.Double") Double$parseDouble( "10.2") # String[] strings = new String[]{ "string", "array" } ; strings <- .jarray( c("string", "array") ) # this uses the JList( Object[] ) constructor # even though the "strings" parameter is a String[] l <- new( J("javax.swing.JList"), strings) } \keyword{interface} rJava/man/show.Rd0000644000176200001440000000137112256051760013345 0ustar liggesusers\name{show} \alias{show,jobjRef-method} \alias{str,jobjRef-method} \alias{show,jarrayRef-method} \alias{show,jclassName-method} \title{Show a Java Object Reference} \description{ Display a Java object reference in a descriptive, textual form. The default implementation calls \code{toString} Java method to obtain object's printable value and uses calls \code{show} on the resulting string garnished with additional details. } \section{Methods}{ \describe{ \item{show}{\code{signature(object = "jobjRef")}: ... } \item{show}{\code{signature(object = "jarrayRef")}: ... } \item{show}{\code{signature(object = "jclassName")}: ... } \item{str}{\code{signature(object = "jobjRef")}: currently identical to show } } } \keyword{interface} rJava/man/jserialize.Rd0000644000176200001440000001054312256051760014527 0ustar liggesusers\name{jserialize} \alias{.jserialize} \alias{.junserialize} \alias{.jcache} \title{ Java object serialization } \description{ \code{.jserialize} serializes a Java object into raw vector using Java serialization. \code{.junserialize} re-constructs a Java object from its serialized (raw-vector) form. \code{.jcache} updates, retrieves or removes R-side object cache which can be used for persistent storage of Java objects across sessions. } \usage{ .jserialize(o) .junserialize(data) .jcache(o, update=TRUE) } \arguments{ \item{o}{Java object} \item{data}{serialized Java object as a raw vector} \item{update}{must be \code{TRUE} (cache is updated), \code{FALSE} (cache is retrieved) or \code{NULL} (cache is deleted).} } \value{ \code{.jserialize} returns a raw vector \code{.junserialize} returns a Java object or \code{NULL} if an error occurred (currently you may use \code{.jcheck()} to further investigate the error) \code{.jcache} returns the current cache (usually a raw vector) or \code{NULL} if there is no cache. } \details{ Not all Java objects support serialization, see Java documentation for details. Note that Java serialization and serialization of R objects are two entirely different mechanisms that cannot be interchanged. \code{.jserialize} and \code{.junserialize} can be used to access Java serialization facilities. \code{.jcache} manipulates the R-side Java object cache associated with a given Java reference: Java objects do not persist across sessions, because the Java Virtual Machine (JVM) is destroyed when R is closed. All saved Java object references will be restored as \code{null} references, since the corresponding objects no longer exist (see R documentation on serialization). However, it is possible to serialize a Java object (if supported by the object) and store its serialized form in R. This allows for the object to be deserialized when loaded into another active session (but see notes below!) R-side cache consists of a serialized form of the object as raw vector. This cache is attached to the Java object and thus will be saved when the Java object is saved. rJava provides an automated way of deserializing Java references if they are \code{null} references and have a cache attached. This is done on-demand basis whenever a reference to a Java object is required. Therefore packages can use \code{.jcache} to provide a way of creating Java references that persist across sessions. However, they must be very cautious in doing so. First, make sure the serialized form is not too big. Storing whole datasets in Java serialized form will hog immense amounts of memory on the R side and should be avoided. In addition, be aware that the cache is just a snapshot, it doesn't change when the referenced Java object is modified. Hence it is most useful only for references that are not modified outside R. Finally, internal references to other Java objects accessible from R are not retained (see below). Most common use of \code{.jcache} is with Java references that point to definitions of methods (e.g., models) and other descriptive objects which are then used by other, active Java classes to act upon. Caching of such active objects is not a good idea, they should be instantiated by functions that operate on the descriptive references instead. \emph{Important note:} the serialization of Java references does NOT take into account any dependencies on the R side. Therefore if you hold a reference to a Java object in R that is also referenced by the serialized Java object on the Java side, then this relationship cannot be retained upon restore. Instead, two copies of disjoint objects will be created which can cause confusion and errorneous behavior. The cache is attached to the reference external pointer and thus it is shared with all copies of the same reference (even when changed via \code{\link{.jcast}} etc.), but it is independent of other references to the object obtained separately (e.g., via \code{\link{.jcall}} or \code{\link{.jfield}}). Also note that deserialization (even automated one) requires a running virtual machine. Therefore you must make sure that either \code{\link{.jinit}} or \code{\link{.jpackage}} is used before any Java references are accessed. } %\seealso{ %} %\examples{ %\dontrun{ %} %} \keyword{interface} rJava/man/jrectRef-class.Rd0000644000176200001440000002532612256051760015242 0ustar liggesusers\name{jrectRef-class} \Rdversion{1.1} \docType{class} \alias{jrectRef-class} \alias{[,jrectRef-method} \alias{length,jrectRef-method} \alias{str,jrectRef-method} \alias{dim,jrectRef-method} \alias{dim<-,jrectRef-method} \alias{unique,jrectRef-method} \alias{duplicated,jrectRef-method} \alias{anyDuplicated,jrectRef-method} \alias{sort,jrectRef-method} \alias{rev,jrectRef-method} \alias{min,jrectRef-method} \alias{max,jrectRef-method} \alias{range,jrectRef-method} \title{Rectangular java arrays} \description{References to java arrays that are guaranteed to be rectangular, i.e similar to R arrays} \section{Objects from the Class}{ Objects of this class should *not* be created directly. Instead, they usually come as a result of a java method call. } \section{Slots}{ \describe{ \item{\code{jsig}:}{JNI signature of the array type} \item{\code{jobj}:}{Internal identifier of the object} \item{\code{jclass}:}{Inherited from \code{jobjRef}, but unspecified} \item{\code{dimension}:}{dimension vector of the array} } } \section{Extends}{ Class \code{"\linkS4class{jarrayRef}"}, directly. Class \code{"\linkS4class{jobjRef}"}, by class "jarrayRef", distance 2. } \section{Methods}{ \describe{ \item{length}{\code{signature(x = "jrectRef")}: The number of elements in the array. Note that if the array has more than one dimension, it gives the number of arrays in the first dimension, and not the total number of atomic objects in tha array (like R does). This gives what would be returned by \code{array.length} in java.} \item{str}{\code{signature(object = "jrectRef")}: ... } \item{[}{\code{signature(x = "jrectRef")}: R indexing of rectangular java arrays } \item{dim}{\code{signature(x = "jrectRef")}: extracts the dimensions of the array } \item{dim<-}{\code{signature(x = "jrectRef")}: sets the dimensions of the array } \item{unique}{\code{signature(x = "jrectRef")}: unique objects in the array} \item{duplicated}{\code{signature(x = "jrectRef")}: see \code{\link{duplicated}} } \item{anyDuplicated}{\code{signature(x = "jrectRef")}: see \code{\link{anyDuplicated}} } \item{sort}{\code{signature(x = "jrectRef")}: returns a \emph{new} array with elements from x in order } \item{rev}{\code{signature(x = "jrectRef")}: returns a \emph{new} array with elements from x reversed } \item{min}{\code{signature(x = "jrectRef")}: the smallest object in the array (in the sense of the Comparable interface) } \item{max}{\code{signature(x = "jrectRef")}: the biggest object in the array (in the sense of the Comparable interface) } \item{range}{\code{signature(x = "jrectRef")}: the range of the array (in the sense of the Comparable interface) } } } \examples{ \dontshow{ # these examples are only unit tests so far .jinit() } v <- new( J("java.util.Vector") ) v$add( "hello" ) v$add( "world" ) v$add( new( J("java.lang.Double"), "10.2" ) ) array <- v$toArray() array[ c(TRUE,FALSE,TRUE) ] array[ 1:2 ] array[ -3 ] # length length( array ) \dontshow{stopifnot(length(array) == 3L)} # also works as a pseudo field as in java array$length \dontshow{stopifnot(array$length == 3L)} \dontshow{ # # 2d dim2d <- c(5L, 2L) x <- .jcall( "RectangularArrayExamples", "[[Z", "getBooleanDoubleRectangularArrayExample", evalArray = TRUE, simplify = TRUE) stopifnot( identical( typeof( x ), "logical" ) ) stopifnot( identical( dim(x) , dim2d ) ) stopifnot( identical( as.vector(x), rep( c(FALSE,TRUE), 5 ) ) ) x <- .jcall( "RectangularArrayExamples", "[[I", "getIntDoubleRectangularArrayExample", evalArray = TRUE, simplify = TRUE ) stopifnot( identical( typeof( x ), "integer" ) ) stopifnot( identical( dim(x) , dim2d ) ) stopifnot( identical( as.vector(x), 0:9 ) ) x <- .jcall( "RectangularArrayExamples", "[[B", "getByteDoubleRectangularArrayExample", evalArray = TRUE, simplify = TRUE ) stopifnot( identical( typeof( x ), "raw" ) ) stopifnot( identical( dim(x) , dim2d ) ) stopifnot( identical( as.vector(x), as.raw(0:9) ) ) x <- .jcall( "RectangularArrayExamples", "[[J", "getLongDoubleRectangularArrayExample", evalArray = TRUE, simplify = TRUE ) stopifnot( identical( typeof( x ), "double" ) ) stopifnot( identical( dim(x) , dim2d ) ) stopifnot( identical( as.vector(x), as.numeric(0:9) ) ) x <- .jcall( "RectangularArrayExamples", "[[S", "getShortDoubleRectangularArrayExample", evalArray = TRUE, simplify = TRUE ) stopifnot( identical( typeof( x ), "integer" ) ) stopifnot( identical( dim(x) , dim2d ) ) stopifnot( identical( as.vector(x), 0:9 ) ) x <- .jcall( "RectangularArrayExamples", "[[D", "getDoubleDoubleRectangularArrayExample", evalArray = TRUE, simplify = TRUE ) stopifnot( identical( typeof( x ), "double" ) ) stopifnot( identical( dim(x) , dim2d ) ) stopifnot( identical( as.vector(x), as.numeric(0:9) ) ) x <- .jcall( "RectangularArrayExamples", "[[C", "getCharDoubleRectangularArrayExample", evalArray = TRUE, simplify = TRUE ) stopifnot( identical( typeof( x ), "integer" ) ) stopifnot( identical( dim(x) , dim2d ) ) stopifnot( identical( as.vector(x), 0:9 ) ) x <- .jcall( "RectangularArrayExamples", "[[F", "getFloatDoubleRectangularArrayExample", evalArray = TRUE, simplify = TRUE ) stopifnot( identical( typeof( x ), "double" ) ) stopifnot( identical( dim(x) , dim2d ) ) stopifnot( identical( as.vector(x), as.numeric(0:9) ) ) x <- .jcall( "RectangularArrayExamples", "[[Ljava/lang/String;", "getStringDoubleRectangularArrayExample", evalArray = TRUE, simplify = TRUE ) stopifnot( identical( typeof( x ), "character" ) ) stopifnot( identical( dim(x) , dim2d ) ) stopifnot( identical( as.vector(x), as.character(0:9) ) ) # 3d dim3d <- c(5L, 3L, 2L) x <- .jcall( "RectangularArrayExamples", "[[[Z", "getBooleanTripleRectangularArrayExample", evalArray = TRUE, simplify = TRUE) stopifnot( identical( typeof( x ), "logical" ) ) stopifnot( identical( dim(x) , dim3d ) ) stopifnot( identical( as.vector(x), rep( c(FALSE,TRUE), 15L ) ) ) x <- .jcall( "RectangularArrayExamples", "[[[I", "getIntTripleRectangularArrayExample", evalArray = TRUE, simplify = TRUE ) stopifnot( identical( typeof( x ), "integer" ) ) stopifnot( identical( dim(x) , dim3d ) ) stopifnot( identical( as.vector(x), 0:29 ) ) x <- .jcall( "RectangularArrayExamples", "[[[B", "getByteTripleRectangularArrayExample", evalArray = TRUE, simplify = TRUE ) stopifnot( identical( typeof( x ), "raw" ) ) stopifnot( identical( dim(x) , dim3d ) ) stopifnot( identical( as.vector(x), as.raw(0:29) ) ) x <- .jcall( "RectangularArrayExamples", "[[[J", "getLongTripleRectangularArrayExample", evalArray = TRUE, simplify = TRUE ) stopifnot( identical( typeof( x ), "double" ) ) stopifnot( identical( dim(x) , dim3d ) ) stopifnot( identical( as.vector(x), as.numeric(0:29) ) ) x <- .jcall( "RectangularArrayExamples", "[[[S", "getShortTripleRectangularArrayExample", evalArray = TRUE, simplify = TRUE ) stopifnot( identical( typeof( x ), "integer" ) ) stopifnot( identical( dim(x) , dim3d ) ) stopifnot( identical( as.vector(x), 0:29 ) ) x <- .jcall( "RectangularArrayExamples", "[[[D", "getDoubleTripleRectangularArrayExample", evalArray = TRUE, simplify = TRUE ) stopifnot( identical( typeof( x ), "double" ) ) stopifnot( identical( dim(x) , dim3d ) ) stopifnot( identical( as.vector(x), as.numeric(0:29) ) ) x <- .jcall( "RectangularArrayExamples", "[[[C", "getCharTripleRectangularArrayExample", evalArray = TRUE, simplify = TRUE ) stopifnot( identical( typeof( x ), "integer" ) ) stopifnot( identical( dim(x) , dim3d ) ) stopifnot( identical( as.vector(x), 0:29 ) ) x <- .jcall( "RectangularArrayExamples", "[[[F", "getFloatTripleRectangularArrayExample", evalArray = TRUE, simplify = TRUE ) stopifnot( identical( typeof( x ), "double" ) ) stopifnot( identical( dim(x) , dim3d ) ) stopifnot( identical( as.vector(x), as.numeric(0:29) ) ) x <- .jcall( "RectangularArrayExamples", "[[[Ljava/lang/String;", "getStringTripleRectangularArrayExample", evalArray = TRUE, simplify = TRUE ) stopifnot( identical( typeof( x ), "character" ) ) stopifnot( identical( dim(x) , dim3d ) ) stopifnot( identical( as.vector(x), as.character(0:29) ) ) # testing the indexing xj <- .jarray( x, dispatch = TRUE ) stopifnot( dim( xj[ ,, ] ) == c( 5L, 3L, 2L ) ) stopifnot( dim( xj[ ] ) == c( 5L, 3L, 2L ) ) stopifnot( dim( xj[ ,,1,drop= TRUE] ) == c( 5L, 3L ) ) stopifnot( dim( xj[ ,,1,drop= FALSE] ) == c( 5L, 3L, 1L ) ) stopifnot( dim( xj[ ,1,,drop= TRUE] ) == c( 5L, 2L ) ) stopifnot( dim( xj[ ,1,,drop= FALSE] ) == c( 5L, 1L, 2L ) ) stopifnot( dim( xj[ 1,,,drop= TRUE] ) == c( 3L, 2L ) ) stopifnot( dim( xj[ 1,,,drop= FALSE] ) == c( 1L, 3L, 2L ) ) stopifnot( dim( xj[ ,1,1,drop= TRUE] ) == c( 5L ) ) stopifnot( dim( xj[ ,1,1,drop= FALSE] ) == c( 5L, 1L, 1L ) ) stopifnot( dim( xj[ 1,1,1,drop= TRUE] ) == c( 1L ) ) stopifnot( dim( xj[ 1,1,1,drop= FALSE] ) == c( 1L, 1L, 1L ) ) # testing simplify stopifnot( identical( xj[simplify=TRUE], x) ) stopifnot( identical( xj[,1,,simplify=TRUE], x[,1,]) ) stopifnot( identical( xj[,1,-1,simplify=TRUE], x[,1,-1]) ) stopifnot( identical( xj[4,1,c(TRUE,FALSE),simplify=TRUE], x[4,1,c(TRUE,FALSE)]) ) stopifnot( identical( xj[1:10,simplify=TRUE], x[1:10]) ) # test dim<- dim( xj ) <- c( 15L, 2L ) stopifnot( xj@jsig == "[[Ljava/lang/String;" ) stopifnot( dim( xj ) == c(15L, 2L ) ) dim( xj ) <- NULL stopifnot( xj@jsig == "[Ljava/lang/String;" ) stopifnot( dim( xj ) == 30L ) # test unique # **** FIXME: this should really work even with dispatch=FALSE since # it's a vector but it does not! It applies to everything # below x <- .jarray( rep( 1:2, each = 5 ), dispatch = TRUE ) xu <- unique( x ) stopifnot( dim(xu) == 2L ) p1 <- .jnew( "java/awt/Point" ) p2 <- .jnew( "java/awt/Point" ) x <- .jarray( list( p1, p2 ), dispatch = TRUE ) xu <- unique( x ) stopifnot( dim( xu ) == 1L ) # test duplicated x <- .jarray( rep( 1:2, each = 5 ), dispatch = TRUE ) xd <- duplicated( x ) stopifnot( xd == rep( c( FALSE, TRUE, TRUE, TRUE, TRUE), 2L ) ) if (rJava:::.base.has.anyDuplicated) stopifnot( anyDuplicated( x ) == 2L ) p1 <- .jnew( "java/awt/Point" ) p2 <- .jnew( "java/awt/Point" ) x <- .jarray( list( p1, p2 ), dispatch = TRUE ) xd <- duplicated( x ) stopifnot( xd == c( FALSE, TRUE) ) if (rJava:::.base.has.anyDuplicated) stopifnot( anyDuplicated( x ) == 2L ) # test sort, rev d1 <- .jnew("java/lang/Double", 0) d2 <- .jnew("java/lang/Double", -1) a <- .jarray( list( d1, d2), dispatch = TRUE ) stopifnot( sort( a )[[1]]$doubleValue() == -1.0 ) stopifnot( rev( a )[[1]]$doubleValue() == -1.0 ) # test min, max, range Double <- J("java.lang.Double") a <- .jarray( list( new( Double, 10 ), new( Double, 4), new( Double, 5) ), "java/lang/Double", dispatch = TRUE ) stopifnot( min( a )$doubleValue() == 4 ) stopifnot( max( a )$doubleValue() == 10 ) stopifnot( range(a)[[1]]$doubleValue() == 4 ) stopifnot( range(a)[[2]]$doubleValue() == 10) } } \keyword{classes} rJava/man/jsimplify.Rd0000644000176200001440000000210012256051760014362 0ustar liggesusers\name{jsimplify} \alias{.jsimplify} \title{ Converts Java object to a simple scalar if possible } \description{ \code{.jsimplify} attempts to convert Java objects that represent simple scalars into corresponding scalar representation in R. } \usage{ .jsimplify(o) } \arguments{ \item{o}{arbitrary object} } \value{ Simple scalar or \code{o} unchanged. } \details{ If \code{o} is not a Java object reference, \code{o} is returned as-is. If \code{o} is a reference to a scalar object (such as single integer, number, string or boolean) then the value of that object is returned as R vector of the corresponding type and length one. This function is used by \code{\link{.jfield}} to simplify the results of field access if required. Currently there is no function inverse to this, the usual way to wrap scalar values in Java references is to use \code{\link{.jnew}} as the corresponding constructor. } \seealso{ \code{\link{.jfield}} } \examples{ \dontrun{ i <- .jnew("java/lang/Integer", as.integer(10)) print(i) print(.jsimplify(i)) } } \keyword{interface} rJava/man/rep.Rd0000644000176200001440000000131212256051760013146 0ustar liggesusers\name{rep} \alias{rep,jarrayRef-method} \alias{rep,jobjRef-method} \alias{rep,jrectRef-method} \title{Creates java arrays by cloning} \description{ Creates a java array by cloning a reference several times } \section{Methods}{ \describe{ \item{rep}{\code{signature(object = "jobjRef")}: ... } \item{rep}{\code{signature(object = "jarrayRef")}: ... } \item{rep}{\code{signature(object = "jrectRef")}: ... } } } \seealso{ \code{\link[base]{rep}} or \code{\link{.jarray}} } \examples{ \dontshow{.jinit()} if (!nzchar(Sys.getenv("NOAWT"))) { p <- .jnew( "java.awt.Point" ) a <- rep( p, 10 ) stopifnot( dim(a) == c(10L ) ) a[[1]]$move( 10L, 50L ) stopifnot( a[[2]]$getX() == 0.0 ) } } rJava/man/instanceof.Rd0000644000176200001440000000243612256051760014521 0ustar liggesusers\name{.jinstanceof} \Rdversion{1.1} \alias{\%instanceof\%} \alias{.jinstanceof} \title{ Is a java object an instance of a given java class } \description{ Is a java object an instance of a given java class } \usage{ o \%instanceof\% cl .jinstanceof( o, cl ) } \arguments{ \item{o}{java object reference} \item{cl}{java class. This can be a character vector of length one giving the name of the class, or another java object, or an instance of the Class class, or a object of class \code{jclassName}.} } \value{ TRUE if o is an instance of cl } \author{ Romain Francois } \examples{ \dontshow{ .jinit() } Double <- J("java.lang.Double") d <- new( Double, "10.2" ) # character d \%instanceof\% "java.lang.Double" d \%instanceof\% "java.lang.Number" # jclassName d \%instanceof\% Double # instance of Class Double.class <- Double@jobj d \%instanceof\% Double.class # other object other.double <- new( Double, 10.2 ) d \%instanceof\% other.double \dontshow{ % simple unit tests stopifnot( d \%instanceof\% "java.lang.Double" ) stopifnot( d \%instanceof\% "java.lang.Number" ) stopifnot( d \%instanceof\% "java.lang.Object" ) stopifnot( d \%instanceof\% Double.class ) stopifnot( d \%instanceof\% other.double ) stopifnot( d \%instanceof\% Double ) } } \keyword{ interface } rJava/man/jclassName.Rd0000644000176200001440000000252512256051760014447 0ustar liggesusers\name{jclassName-class} \docType{class} \alias{jclassName-class} \alias{as.character,jclassName-method} \title{Class "jclassName" - a representation of a Java class name } \description{ This class holds a name of a class in Java. } \section{Objects from the Class}{ Objects of this class should *not* be created directly. Instead, the function \code{\link{J}} should be used to create new objects of this class. } \section{Slots}{ \describe{ \item{\code{name}:}{Name of the class (in source code notation)} \item{\code{jobj}:}{Object representing the class in Java} } } \section{Methods}{ The objects of class \code{jclassName} are used indirectly to be able to create new Java objects via \code{new} such as \code{new(J("java.lang.String"), "foo")} or to use the \code{$} convenience operator on static classes, such as \code{J("java.lang.Double")$parseDouble("10.2")}. \describe{ \item{\code{as.character}}{\code{signature(x = "jclassName")}: returns the class name as a string vector of length one. } } } %\references{ ~put references to the literature/web site here ~ } \author{ Simon Urbanek } %\note{ ~~further notes~~ } % ~Make other sections like Warning with \section{Warning }{....} ~ \seealso{ \code{\link{J}}, \code{\link{new}} } %\examples{ %##---- Should be DIRECTLY executable !! ---- %} \keyword{classes} rJava/man/jcastToArray.Rd0000644000176200001440000000516712256051760015002 0ustar liggesusers\name{jcastToArray} \alias{.jcastToArray} \title{ Ensures that a given object is an array reference } \description{ \code{.jcastToArray} takes a Java object reference of any kind and returns Java array reference if the given object is a reference to an array. } \usage{ .jcastToArray(obj, signature=NULL, class="", quiet=FALSE) } \arguments{ \item{obj}{Java object reference to cast or a scalar vector} \item{signature}{array signature in JNI notation (e.g. \code{"[I"} for an array of integers). If set to \code{NULL} (the default), the signature is automatically determined from the object's class.} \item{class}{force the result to pose as a particular Java class. This has the same effect as using \code{\link{.jcast}} on the result and is provided for convenience only.} \item{quiet}{if set to \code{TRUE}, no failures are reported and the original object is returned unmodified.} } \value{ Returns a Java array reference (\code{jarrayRef}) on success. If \code{quiet} is \code{TRUE} then the result can also be the original object in the case of failure. } \details{ Sometimes a result of a method is by definition of the class \code{java.lang.Object}, but the acutal referenced object may be an array. In that case the method returns a Java object reference instead of an array reference. In order to obtain an array reference, it is necessary to cast such an object to an array reference - this is done using the above \code{.jcastToArray} function. The input is an object reference that points to an array. Ususally the signature should be left at \code{NULL} such that it is determined from the object's class. This is also a check, because if the object's class is not an array, then the functions fails either with an error (when \code{quiet=FALSE}) or by returing the original object (when \code{quiet=TRUE}). If the signature is set to anything else, it is not verified and the array reference is always created, even if it may be invalid and unusable. For convenience \code{.jcastToArray} also accepts non-references in which case it simply calls \code{\link{.jarray}}, ignoring all other parameters. } \examples{ \dontrun{ a <- .jarray(1:10) print(a) # let's create an array containing the array aa <- .jarray(list(a)) print(aa) ba <- .jevalArray(aa)[[1]] # it is NOT the inverse, because .jarray works on a list of objects print(ba) # so we need to cast the object into an array b <- .jcastToArray(ba) # only now a and b are the same array reference print(b) # for convenience .jcastToArray behaves like .jarray for non-references print(.jcastToArray(1:10/2)) } } \keyword{interface} rJava/man/jinit.Rd0000644000176200001440000000627312256051760013510 0ustar liggesusers\name{jinit} \alias{.jinit} \title{ Initialize Java VM } \description{ \code{.jinit} initializes the Java Virtual Machine (JVM). This function must be called before any rJava functions can be used. } \usage{ .jinit(classpath = NULL, parameters = getOption("java.parameters"), ..., silent = FALSE, force.init = FALSE) } \arguments{ \item{classpath}{Any additional classes to include in the Java class paths (i.e. locations of Java classes to use). This path will be prepended to paths specified in the \code{CLASSPATH} environment variable. Do NOT set this system class path initializing a package, use \code{\link{.jpackage}} instead, see details.} \item{parameters}{character vector of parameters to be passed to the virtual machine. They are implementation dependent and apply to JDK version 1.2 or higher only. Please note that each parameter must be in a separate element of the array, you cannot use a space-separated string with multiple parameters.} \item{...}{Other optional Java initialization parameters (implementation-dependent).} \item{silent}{If set to \code{TRUE} no warnings are issued.} \item{force.init}{If set to \code{TRUE} JVM is re-initialized even if it is already running.} } \value{ The return value is an integer specifying whether and how the VM was initialized. Negative values indicate failure, zero denotes successful initialization and positive values signify partially successful initilization (i.e. the VM is up, but parameters or class path could not be set due to an existing or incompatible VM). } \details{ Starting with version 0.5 rJava provides a custom class laoder that can automatically track classes and native libraries that are provided in R packages. Therefore R packages should NOT use \code{.jinit}, but call \code{\link{.jpackage}} instead. In addition this allows the use of class path modifying function \code{\link{.jaddClassPath}}. Important note: if a class is found on the system class path (i.e. on the \code{classpath} specified to \code{.jinit}) then the system class loader is used instead of the rJava loader, which can lead to problems with reflection and native library support is not enabled. Therefore it is highly recommended to use \code{.jpackage} or \code{.jaddClassPath} instead of \code{classpath} (save for system classes). Stating with version 0.3-8 rJava is now capable of modifying the class path on the fly for certain Sun-based Java virtual machines, even when attaching to an existing VM. However, this is done by exploiting the way ClassLoader is implemented and may fail in the future. In general it is officially not possible to change the class path of a running VM. At any rate, it is impossible to change any other VM parameters of a running VM, so when using \code{.jinit} in a package, be generous with limits and don't use VM parameters to unnecessarily restrict resources (or preferably use \code{\link{.jpackage}} instead). } \seealso{ \code{\link{.jpackage}} } \examples{ \dontrun{ ## set heap size limit to 512MB (see java -X) and ## use "myClasses.jar" as the class path .jinit(classpath="myClasses.jar", parameters="-Xmx512m") } } \keyword{interface} rJava/man/new.Rd0000644000176200001440000000140112256051760013150 0ustar liggesusers\name{new} \alias{new,jclassName-method} \title{ Create a new Java object } \description{ Creates a new Java object and invokes the constructor with given arguments. } \section{Methods}{ \describe{ \item{\code{new}}{\code{signature(Class = "jclassName")}: ... } } } \details{ The \code{new} method is used as the high-level API to create new Java objects (for low-level access see \code{\link{.jnew}}). It returns the newly created Java object. \code{...} arguments are passed to the constructor of the class specified as \code{J("class.name")}. } \seealso{ \code{\link{.jnew}}, \code{\link{jclassName-class}} } \examples{ \dontrun{ v <- new(J("java.lang.String"), "Hello World!") v$length() v$indexOf("World") names(v) } } \keyword{interface} rJava/man/jcheck.Rd0000644000176200001440000000666412256051760013626 0ustar liggesusers\name{jcheck} \alias{.jcheck} \alias{.jthrow} \alias{.jclear} \alias{.jgetEx} \title{ Java exception handling } \description{ \code{.jcheck} checks the Java VM for any pending exceptions and clears them. \code{.jthrow} throws a Java exception. \code{.jgetEx} polls for any pending expections and returns the exception object. \code{.jclear} clears a pending exception. } \usage{ .jcheck(silent = FALSE) .jthrow(exception, message = NULL) .jgetEx(clear = FALSE) .jclear() } \arguments{ \item{silent}{If set to \code{FALSE} then Java is instructed to print the exception on \code{stderr}. Note that Windows Rgui doesn't show \code{stderr} so it will not appear there (as of rJava 0.5-1 some errors that the JVM prints using the vfprintf callback are passed to R. However, some parts are printed using \code{System.err} in which case the ususal redirection using the \code{System} class can be used by the user).} \item{exception}{is either a class name of an exception to create or a throwable object reference that is to be thrown.} \item{message}{if \code{exception} is a class name then this parameter specifies the string to be used as the message of the exception. This parameter is ignored if \code{exception} is a reference.} \item{clear}{if set to \code{TRUE} then the returned exception is also cleared, otherwise the throwable is returned without clearing the cause.} } \value{ \code{.jcheck} returns \code{TRUE} if an exception occurred or \code{FALSE} otherwise. \code{.jgetEx} returns \code{NULL} if there are no pending exceptions or an object of the class "java.lang.Throwable" representing the current exception. } \details{ Please note that some functions (such as \code{\link{.jnew}} or \code{\link{.jcall}}) call \code{.jcheck} implicitly unless instructed to not do so. If you want to handle Java exceptions, you should make sure that those function don't clear the exception you may want to catch. The exception handling is still as a very low-level and experimental, because it requires polling of exceptions. A more elaboate system using constructs similar to \code{try} ... \code{catch} is planned for next major version of \code{rJava}. \emph{Warning:} When requesting exceptions to not be cleared automatically, please note that the \code{show} method (which is called by \code{print}) has a side-effect of making a Java call to get the string representation of a Java object. This implies that it will be impeded by any pending exceptions. Therefore exceptions obtained through \code{.jgetEx} can be stored, but should not be printed (or otherwise used in Java calls) until after the exception is cleared. In general, all Java calls will fail (possibly silently) until the exception is cleared. } \seealso{ \code{\link{.jcall}}, \code{\link{.jnew}} } \examples{ \donttest{ # we try to create a bogus object and # instruct .jnew to not clear the exception # this will raise an exception v <- .jnew("foo/bar", check=FALSE) # you can poll for the exception, but don't try to print it # (see details above) if (!is.null(e<-.jgetEx())) print("Java exception was raised") # expect TRUE result here because the exception was still not cleared print(.jcheck(silent=TRUE)) # next invocation will be FALSE because the exception is now cleared print(.jcheck(silent=TRUE)) # now you can print the actual expection (even after it was cleared) print(e) } } \keyword{interface} rJava/man/jobjRef-class.Rd0000644000176200001440000000212312256051760015045 0ustar liggesusers\name{jobjRef-class} \docType{class} \alias{jobjRef-class} \title{Class "jobjRef" - Reference to a Java object } \description{ This class describes a reference to an object held in a JavaVM. } \section{Objects from the Class}{ Objects of this class should *not* be created directly. Instead, the function \code{\link{.jnew}} should be use to create new Java objects. They can also be created as results of the \code{\link{.jcall}} function. } \section{Slots}{ \describe{ \item{\code{jobj}:}{Internal identifier of the object (external pointer to be precise)} \item{\code{jclass}:}{Java class name of the object (in JNI notation)} } Java-side attributes are not accessed via slots, but the \code{$} operator instead. } \section{Methods}{ This object's Java methods are not accessed directly. Instead, \code{\link{.jcall}} JNI-API should be used for invoking Java methods. For convenience the \code{$} operator can be used to call methods via reflection API. } \author{ Simon Urbanek } \seealso{ \code{\link{.jnew}}, \code{\link{.jcall}} or \code{\link{jarrayRef-class}} } \keyword{classes} rJava/man/jreflection.Rd0000644000176200001440000000326112256051760014671 0ustar liggesusers\name{jreflection} \alias{.jmethods} \alias{.jfields} \alias{.jconstructors} \title{ Simple helper functions for Java reflection } \description{ \code{.jconstructors} returns a character vector with all constructors for a given class or object. \code{.jmethods} returns a character vector with all methods for a given class or object. \code{.jfields} returns a character vector with all fileds (aka attributes) for a given class or object. } \usage{ .jconstructors(o, as.obj = FALSE) .jmethods(o, name = NULL, as.obj = FALSE) .jfields(o, name = NULL, as.obj = FALSE) } \arguments{ \item{o}{Name of a class (either notation is fine) or an object whose class will be queried} \item{name}{Name of the method/field to look for. May contain regular expressions except for \code{^$}.} \item{as.obj}{if \code{TRUE} then a list of Java objects is returned, otherwise a character vector (obtained by calling \code{toString()} on each entry).} } \value{ Returns a character vector (if \code{as.obj} is \code{FALSE}) or a list of Java objects. Each entry corresponds to the \code{Constructor} resp. \code{Method} resp. \code{Field} object. } \details{ There first two functions are intended to help with finding correct signatures for methods and constructors. Since the low-level API in rJava doesn't use reflection automatically, it is necessary to provide a proper signature. That is somewhat easier using the above methods. } \seealso{ \code{\link{.jcall}}, \code{\link{.jnew}}, \code{\link{.jcast}} or \code{\link{$,jobjRef-method}} } \examples{ \dontrun{ .jconstructors("java/util/Vector") v <- .jnew("java/util/Vector") .jmethods(v, "add") } } \keyword{interface} rJava/man/jfloat-class.Rd0000644000176200001440000000364312256051760014753 0ustar liggesusers\name{jfloat-class} \docType{class} \alias{jfloat-class} \alias{jlong-class} \alias{jbyte-class} \alias{jchar-class} \title{Classes "jfloat", "jlong", "jbyte" and "jchar" specify Java native types that are not native in R} \description{ These classes wrap a numeric vector to be treated as \code{float} or \code{long} argument when passed to Java and an integer vector to be treated as \code{byte} or \code{char}. R doesn't distinguish between \code{double} and \code{float}, but Java does. In order to satisfy object types, numeric vectors that should be converted to floats or long on the Java side must be wrapped in this class. In addition \code{jbyte} must be used when passing scalar byte (but not byte arrays, those are mapped into RAW vectors). Finally \code{jchar} it used when mapping integer vectors into unicode Java character vectors.} \section{Objects from the Class}{ Objects can be created by calling \code{\link{.jfloat}}, \code{\link{.jlong}}, \code{\link{.jbyte}} or \code{\link{.jchar}} respectively. } \section{Slots}{ \describe{ \item{\code{.Data}:}{Payload} } } \section{Extends}{ "jfloat" and "jlong": Class \code{"numeric"}, from data part. Class \code{"vector"}, by class \code{"numeric"}. "jbyte" and "jchar": Class \code{"integer"}, from data part. Class \code{"vector"}, by class \code{"integer"}. } \section{Methods}{ "jfloat" and "jlong" have no methods other than those inherited from "numeric". "jbyte" and "jchar" have no methods other than those inherited from "integer". } %\references{ ~put references to the literature/web site here ~ } \author{ Simon Urbanek } %\note{ ~~further notes~~ } % ~Make other sections like Warning with \section{Warning }{....} ~ \seealso{ \code{\link{.jfloat}}, \code{\link{.jlong}}, \code{\link{.jbyte}}, \code{\link{.jchar}} and \code{\link{.jcall}} } %\examples{ %##---- Should be DIRECTLY executable !! ---- %} \keyword{classes} rJava/man/javaImport.Rd0000644000176200001440000000235012256051760014477 0ustar liggesusers\name{javaImport} \alias{javaImport} \title{ Attach mechanism for java packages } \description{ The \code{javaImport} function creates an item on R's search that maps names to class names references found in one or several "imported" java packages. } \usage{ javaImport(packages = "java.lang") } \arguments{ \item{packages}{character vector containing java package paths} } \value{ An external pointer to a java specific \code{UserDefinedDatabase} object } \references{ \emph{User-Defined Tables in the R Search Path}. Duncan Temple Lang. December 4, 2001 \url{http://www.omegahat.org/RObjectTables/} } \author{ Romain Francois } \note{ Currently the list of objects in the imported package is populated as new objects are found, \emph{not} at creation time. } \section{Warning}{ This feature is experimental. Use with caution, and don't forget to detach. } \seealso{ \code{\link{attach}} } \examples{ \dontrun{ attach( javaImport( "java.util" ), pos = 2 , name = "java:java.util" ) # now we can just do something like this v <- new( Vector ) v$add( "foobar" ) ls( pos = 2 ) # or this m <- new( HashMap ) m$put( "foo", "bar" ) ls( pos = 2 ) # or even this : Collections$EMPTY_MAP } } \keyword{ programming } rJava/man/clone.Rd0000644000176200001440000000223312256051760013463 0ustar liggesusers\name{clone} \alias{clone} \alias{clone,jobjRef-method} \alias{clone,jarrayRef-method} \alias{clone,jrectRef-method} \title{ Object cloner } \description{ Generic function to clone objects } \usage{ clone(x, ...) } \section{Methods}{ \describe{ \item{clone}{\code{signature(x = "jobjRef")}: clone a java object reference (must implement Cloneable) } \item{clone}{\code{signature(x = "jarrayRef")}: clone a java rugged array (not yet implemented) } \item{clone}{\code{signature(x = "jrectRef")}: clone a java rectangular array (not yet implemented) } } } \arguments{ \item{x}{An object to clone} \item{\dots}{Further arguments, ignored} } \value{ A clone of the object } \section{Warning}{ The implementation of clone for java object references uses the clone method of the Object class. The reading of its description in the java help page is \emph{strongly} recommended. } \examples{ \dontshow{.jinit()} p1 <- .jnew("java/awt/Point" ) p2 <- clone( p1 ) p2$move( 10L, 10L ) p1$getX() # check that p1 and p2 are not references to the same java object stopifnot( p1$getX() == 0 ) stopifnot( p2$getX() == 10 ) } \keyword{ programming } rJava/man/jfloat.Rd0000644000176200001440000000375112256051760013650 0ustar liggesusers\name{jfloat} \alias{.jfloat} \alias{.jlong} \alias{.jbyte} \alias{.jchar} \alias{.jshort} \alias{jfloat} \alias{jlong} \alias{jbyte} \alias{jchar} \alias{jshort} \title{ Wrap numeric vector as flat Java parameter } \description{ \code{.jfloat} marks a numeric vector as an object that can be used as parameter to Java calls that require \code{float} parameters. Similarly, \code{.jlong} marks a numeric vector as \code{long} parameter. } \usage{ .jfloat(x) .jlong(x) .jbyte(x) .jchar(x) .jshort(x) } \arguments{ \item{x}{numeric vector} } \value{ Returns a numeric vector of the class \code{jfloat}, \code{jlong}, \code{jbyte}, \code{jshort} or \code{jchar} that can be used as parameter to Java calls that require \code{float}, \code{long}, \code{byte}, \code{short} or \code{char} parameters respectively. } \details{ R has no native \code{float} or \code{long} type. Numeric vectors are stored as \code{double}s, hence there is no native way to pass float numbers to Java methods. The \code{.jfloat} call marks a numeric vector as having the Java type \code{float} by wrapping it in the \code{jfloat} class. The class is still a subclass of \code{numeric}, therefore all regular R operations are unaffected by this. Similarly, \code{.jlong} is used to mark a numeric vector as a parameter of the \code{long} Java type. Please note that in general R has no native type that will hold a \code{long} value, so conversion between Java's \code{long} type and R's numeric is potentially lossy. \code{.jbyte} is used when a scalar byte is to be passed ot Java. Note that byte arrays are natively passed as RAW vectors, not as \code{.jbyte} arrays. \code{jchar} is strictly experimental and may be based on \code{character} vectors in the future. } \seealso{ \code{\link{.jcall}}, \code{\link{jfloat-class}} } %\examples{ %\dontrun{ %v <- .jnew("java/util/Vector") %.jcall("java/lang/System","I","identityHashCode",.jcast(v, "java/lang/Object")) %} %} \keyword{interface} rJava/man/jequals.Rd0000644000176200001440000001217212256051760014032 0ustar liggesusers\name{jequals} \alias{.jequals} \alias{.jcompare} \alias{!=,ANY,jobjRef-method} \alias{!=,jobjRef,jobjRef-method} \alias{!=,jobjRef,ANY-method} \alias{==,ANY,jobjRef-method} \alias{==,jobjRef,jobjRef-method} \alias{==,jobjRef,ANY-method} \alias{<,ANY,jobjRef-method} \alias{<,jobjRef,jobjRef-method} \alias{<,jobjRef,ANY-method} \alias{>,ANY,jobjRef-method} \alias{>,jobjRef,jobjRef-method} \alias{>,jobjRef,ANY-method} \alias{<=,ANY,jobjRef-method} \alias{<=,jobjRef,jobjRef-method} \alias{<=,jobjRef,ANY-method} \alias{>=,ANY,jobjRef-method} \alias{>=,jobjRef,jobjRef-method} \alias{>=,jobjRef,ANY-method} \title{ Comparing Java References } \description{ \code{.jequals} function can be used to determine whether two objects are equal. In addition, it allows mixed comparison of non-Java object for convenience, unless strict comparison is desired. The binary operators \code{==} and \code{!=} are mapped to (non-strict) call to \code{.jequals} for convenience. \code{.jcompare} compares two objects in the sense of the \code{java.lang.Comparable} interface. The binary operators \code{<}, \code{>}, \code{<=}, \code{>=} are mapped to calls to \code{.jcompare} for convenience } \usage{ .jequals(a, b, strict = FALSE) .jcompare( a, b ) } \arguments{ \item{a}{first object} \item{b}{second object} \item{strict}{when set to \code{TRUE} then non-references save for \code{NULL} are always treated as different, see details.} } \value{ \code{.jequals} returns \code{TRUE} if both object are considered equal, \code{FALSE} otherwise. \code{.jcompare} returns the result of the \code{compareTo} java method of the object a applied to b } \section{Methods}{ \describe{ \item{!=}{\code{signature(e1 = "ANY", e2 = "jobjRef")}: ... } \item{!=}{\code{signature(e1 = "jobjRef", e2 = "jobjRef")}: ... } \item{!=}{\code{signature(e1 = "jobjRef", e2 = "ANY")}: ... } \item{==}{\code{signature(e1 = "ANY", e2 = "jobjRef")}: ... } \item{==}{\code{signature(e1 = "jobjRef", e2 = "jobjRef")}: ... } \item{==}{\code{signature(e1 = "jobjRef", e2 = "ANY")}: ... } \item{<}{\code{signature(e1 = "ANY", e2 = "jobjRef")}: ... } \item{<}{\code{signature(e1 = "jobjRef", e2 = "jobjRef")}: ... } \item{<}{\code{signature(e1 = "jobjRef", e2 = "ANY")}: ... } \item{>}{\code{signature(e1 = "ANY", e2 = "jobjRef")}: ... } \item{>}{\code{signature(e1 = "jobjRef", e2 = "jobjRef")}: ... } \item{>}{\code{signature(e1 = "jobjRef", e2 = "ANY")}: ... } \item{>=}{\code{signature(e1 = "ANY", e2 = "jobjRef")}: ... } \item{>=}{\code{signature(e1 = "jobjRef", e2 = "jobjRef")}: ... } \item{>=}{\code{signature(e1 = "jobjRef", e2 = "ANY")}: ... } \item{<=}{\code{signature(e1 = "ANY", e2 = "jobjRef")}: ... } \item{<=}{\code{signature(e1 = "jobjRef", e2 = "jobjRef")}: ... } \item{<=}{\code{signature(e1 = "jobjRef", e2 = "ANY")}: ... } } } \details{ \code{.jequals} compares two Java objects by calling \code{equals} method of one of the objects and passing the other object as its argument. This allows Java objects to define the `equality' in object-dependent way. In addition, \code{.jequals} allows the comparison of Java object to other scalar R objects. This is done by creating a temporary Java object that corresponds to the R object and using it for a call to the \code{equals} method. If such conversion is not possible a warning is produced and the result it \code{FALSE}. The automatic conversion will be avoided if \code{strict} parameter is set to \code{TRUE}. \code{NULL} values in \code{a} or \code{b} are replaced by Java \code{null}-references and thus \code{.jequals(NULL,NULL)} is \code{TRUE}. If neither \code{a} and \code{b} are Java objects (with the exception of both being \code{NULL}) then the result is identical to that of \code{all.equal(a,b)}. Neither comparison operators nor \code{.jequals} supports vectors and returns \code{FALSE} in that case. A warning is also issued unless strict comparison was requested. } \note{ Don't use \code{x == NULL} to check for \code{null}-references, because \code{x} could be \code{NULL} and thus the result would be an empty vector. Use \code{\link{is.jnull}} instead. (In theory \code{is.jnull} and \code{x == .jnull()} are the the same, but \code{is.jnull} is more efficient.) } \seealso{ \code{\link{is.jnull}} } \examples{ \dontshow{.jinit()} s <- .jnew("java/lang/String", "foo") .jequals(s, "foo") # TRUE .jequals(s, "foo", strict=TRUE) # FALSE - "foo" is not a Java object t <- s .jequals(s, t, strict=TRUE) # TRUE s=="foo" # TRUE \dontshow{ stopifnot( .jequals(s, "foo"), !.jequals(s, "foo", strict=TRUE), .jequals(s, t, strict=TRUE), s == "foo" ) } Double <- J("java.lang.Double") d1 <- new( Double, 0.0 ) d2 <- new( Double, 1.0 ) d3 <- new( Double, 0.0 ) d1 < d2 d1 <= d3 d1 >= d3 d1 > d2 # cannot compare a Double and a String try( d1 < "foo" ) # but can compare a Double and an Integer d1 < 10L \dontshow{ stopifnot( d1 < d2 , d1 <= d3 , d1 >= d3 , ! (d1 > d2 ) , inherits( try( d1 < "foo", silent = TRUE ), "try-error" ), d1 < 10L ) } } \keyword{interface} rJava/man/accessOp.Rd0000644000176200001440000000614112256051760014125 0ustar liggesusers\name{JavaAccess} \alias{$,jobjRef-method} \alias{$,jclassName-method} \alias{$<-,jobjRef-method} \alias{$<-,jclassName-method} \alias{names,jobjRef-method} \alias{names,jclassName-method} \alias{names,jarrayRef-method} \alias{names,jrectRef-method} \alias{.DollarNames.jobjRef} \alias{.DollarNames.jclassName} \alias{.DollarNames.jarrayRef} \alias{.DollarNames.jrectRef} \title{ Field/method operator for Java objects } \description{ The \code{$} operator for \code{jobjRef} Java object references provides convenience access to object attributes and calling Java methods. } \usage{ \S3method{.DollarNames}{jobjRef} (x, pattern = "" ) \S3method{.DollarNames}{jarrayRef} (x, pattern = "" ) \S3method{.DollarNames}{jrectRef} (x, pattern = "" ) \S3method{.DollarNames}{jclassName}(x, pattern = "" ) } \arguments{ \item{x}{object to complete} \item{pattern}{pattern} } \section{Methods}{ \describe{ \item{\code{$}}{\code{signature(x = "jobjRef")}: ... } \item{\code{$}}{\code{signature(x = "jclassName")}: ... } \item{\code{$<-}}{\code{signature(x = "jobjRef")}: ... } \item{\code{$<-}}{\code{signature(x = "jclassName")}: ... } \item{\code{names}}{\code{signature(x = "jobjRef")}: ... } \item{\code{names}}{\code{signature(x = "jarrayRef")}: ... } \item{\code{names}}{\code{signature(x = "jrectRef")}: ... } \item{\code{names}}{\code{signature(x = "jclassName")}: ... } } } \details{ rJava provies two levels of API: low-level JNI-API in the form of \code{\link{.jcall}} function and high-level reflection API based on the \code{$} operator. The former is very fast, but inflexible. The latter is a convenient way to use Java-like programming at the cost of performance. The reflection API is build around the \code{$} operator on \code{\link{jobjRef-class}} objects that allows to access Java attributes and call object methods. \code{$} returns either the value of the attribute or calls a method, depending on which name matches first. \code{$<-} assigns a value to the corresponding Java attribute. \code{names} and \code{.DollarNames} returns all fields and methods associated with the object. Method names are followed by \code{(} or \code{()} depending on arity. This use of names is mainly useful for code completion, it is not intended to be used programmatically. This is just a convenience API. Internally all calls are mapped into \code{\link{.jcall}} calls, therefore the calling conventions and returning objects use the same rules. For time-critical Java calls \code{\link{.jcall}} should be used directly. } \seealso{ \code{\link{J}}, \code{\link{.jcall}}, \code{\link{.jnew}}, \code{\link{jobjRef-class}} } \examples{ \dontshow{.jinit()} v <- new(J("java.lang.String"), "Hello World!") v$length() v$indexOf("World") names(v) \dontshow{ stopifnot( v$length() == 12L ) stopifnot( v$indexOf("World") == 6L ) } J("java.lang.String")$valueOf(10) Double <- J("java.lang.Double") # the class pseudo field - instance of Class for the associated class # similar to java Double.class Double$class \dontshow{ stopifnot( Double$class$getName() == "java.lang.Double" ) } } \keyword{interface} rJava/man/Exceptions.Rd0000644000176200001440000000302412256051760014503 0ustar liggesusers\name{Exceptions} \alias{Exceptions} \alias{$.Throwable} \alias{$<-.Throwable} \title{Exception handling} \description{R handling of java exception} \usage{ \S3method{$}{Throwable}(x, name ) \S3method{$}{Throwable}(x, name ) <- value } \arguments{ \item{x}{condition} \item{name}{...} \item{value}{...} } \details{ Java exceptions are mapped to R conditions that are relayed by the \code{\link{stop}} function. The R condition contains the actual exception object as the \code{jobj} item. The class name of the R condition is made of a vector of simple java class names, the class names without their package path. This allows the R code to use direct handlers similar to direct exception handlers in java. See the example below. } \examples{ \dontshow{.jinit()} Integer <- J("java.lang.Integer") tryCatch( Integer$parseInt( "10.." ), NumberFormatException = function(e){ e$jobj$printStackTrace() } ) # the dollar method is also implemented for Throwable conditions, # so that syntactic sugar can be used on condition objects # however, in the example below e is __not__ a jobjRef object reference tryCatch( Integer$parseInt( "10.." ), NumberFormatException = function(e){ e$printStackTrace() } ) \dontshow{ tryCatch( Integer$parseInt( "10.." ), NumberFormatException = function(e){ classes <- class( e ) stopifnot( "NumberFormatException" \%in\% classes ) stopifnot( "Exception" \%in\% classes ) stopifnot( "Object" \%in\% classes ) stopifnot( "error" \%in\% classes ) stopifnot( "condition" \%in\% classes ) } ) } } rJava/man/jfield.Rd0000644000176200001440000000420312256051760013617 0ustar liggesusers\name{jfield} \alias{.jfield} \alias{.jfield<-} \title{ Obtains the value of a field } \description{ \code{.jfield} returns the value of the specified field on an object. } \usage{ .jfield(o, sig = NULL, name, true.class = is.null(sig), convert = TRUE) `.jfield<-`(o, name, value) } \arguments{ \item{o}{Class name or object (Java reference) whose field is to be accessed. Static fields are supported both by specifying the class name or using an instance.} \item{sig}{signature (JNI type) of the field. If set to \code{NULL} rJava attempts to determine the signature using reflection. For efficiency it is recommended to specify the signature, because the reflection lookup is quite expensive.} \item{name}{name of the field to access} \item{true.class}{by default the class of the resulting object matches the siganture of the field. Setting this flag to \code{TRUE} causes \code{.jfield} to use true class name of the resulting object instead. (this flag has no effect on scalar fields)} \item{convert}{when set to \code{TRUE} all references are converted to native types (where possible). Otherwise Java references are returned directly.} \item{value}{value to assign into the field. The field signature is determined from the value in the same way that parameter signatures are determined in \code{\link{.jcall}} - be sure to cast the value as necessary, no automatic conversion is done.} } \value{ \code{.jfield}: contents of the field, \code{.jfield<-}: modified object. } \details{ The detection of a field signature in \code{.jfield} using reflection is considerably expensive (more than 3 additional method calls have to be performed), therefore it is recommended for time-critical code to specify the field signature beforehand. NOTE: The sequence of arguments in \code{.jfield} has been changed since rJava 0.5 to be more consistent and match the sequence in \code{.jcall}. Also \code{.jsimplify} is no longer needed as primitive types are obtained directly. } \seealso{ \code{\link{.jcall}} } \examples{ \dontrun{ .jfield("java/lang/Boolean",, "TYPE") } } \keyword{interface} rJava/man/aslist.Rd0000644000176200001440000000266712256051760013675 0ustar liggesusers\name{aslist} \alias{as.list.jobjRef} \alias{as.list.jarrayRef} \alias{as.list.jrectRef} \title{ Converts java objects or arrays to R lists } \description{ \code{as.list} is implemented for java objects and java arrays to facilitate using \code{lapply} calls over elements of a java array or items of an Iterator associated with an Iterable object For java array references, \code{as.list} is mapped to \code{\link{.jevalArray}} For java objects that implement the Iterable interface, the list is created by iterating over the associated iterator } \usage{ \S3method{as.list}{jobjRef}(x, ...) \S3method{as.list}{jarrayRef}(x, ...) } \arguments{ \item{x}{java array or Iterable java object} \item{\dots}{ignored} } \value{ An R list, or vector. } \note{ The function is not intended to be called directly. It is implemented so that java arrays or Iterable java objects can be used as the first argument of \code{\link{lapply}} } \seealso{ \code{\link{.jevalArray}}, \code{\link{lapply}} } \examples{ \dontshow{.jinit()} # lapplying over a java array a <- .jarray( list( .jnew( "java/awt/Point", 10L, 10L ), .jnew( "java/awt/Point", 30L, 30L ) ) ) lapply( a, function(point){ with(point, { (x + y ) ^ 2 } ) } ) # lapply over a Vector (implements Iterable) v <- .jnew("java/util/Vector") v$add( "foo" ) v$add( .jnew("java/lang/Double", 10.2 ) ) sapply( v, function(item) item$getClass()$getName() ) } \keyword{ programming } rJava/man/jpackage.Rd0000644000176200001440000000505212256051760014132 0ustar liggesusers\name{jpackage} \alias{.jpackage} \title{ Initialize an R package containing Java code } \description{ \code{.jpackage} initializes the Java Virtual Machine (JVM) for an R package. In addition to starting the JVM it also registers Java classes and native code contained in the package with the JVM. function must be called before any rJava functions can be used. } \usage{ .jpackage(name, jars='*', morePaths='', nativeLibrary=FALSE, lib.loc=NULL) } \arguments{ \item{name}{name of the package. It should correspond to the \code{pkgname} parameter of \code{.onLoad} or \code{.First.lib} function.} \item{jars}{Java archives in the \code{java} directory of the package that should be added to the class path. The paths must be relative to package's \code{java} directory. A special value of \code{'*'} adds all \code{.jar} files form the \code{java} the directory.} \item{morePaths}{vector listing any additional entries that should be added to the class path.} \item{nativeLibrary}{a logical determining whether rJava should look for native code in the R package's shared object or not.} \item{lib.loc}{a character vector with path names of R libraries, or \code{NULL} (see \code{\link{system.file}} and examples below).} } \value{ The return value is an invisible TRUE if the initialization was successful. } \details{ \code{.jpackage} initializes a Java R package as follows: first the JVM is initialized via \code{\link{.jinit}} (if it is not running already). Then the \code{java} directory of the package is added to the class path. Then \code{.jpackage} prepends \code{jars} with the path to the \code{java} directory of the package and adds them to the class path (or all \code{.jar} files if \code{'*'} was specified). Finally the \code{morePaths} parameter (if set) is passed to a call to \code{\link{.jaddClassPath}}. Therefore the easiest way to create a Java package is to add \code{.jpackage(pkgname, lib.loc=libname)} in \code{.onLoad} or \code{.First.lib}, and copy all necessary classes to a JAR file(s) which is placed in the \code{inst/java/} directory of the source package. If a package needs special Java parameters, \code{"java.parameters"} option can be used to set them on initialization. Note, however, that Java parameters can only be used during JVM initialization and other package may have intialized JVM already. } \seealso{ \code{\link{.jinit}} } \examples{ \dontrun{ .onLoad <- function(libname, pkgname) { .jpackage(pkgname, lib.loc=libname) } } } \keyword{interface} rJava/man/with.Rd0000644000176200001440000000523112256051760013337 0ustar liggesusers\name{with.jobjRef} \alias{with.jobjRef} \alias{within.jobjRef} \alias{with.jarrayRef} \alias{within.jarrayRef} \alias{with.jclassName} \alias{within.jclassName} \title{ with and within methods for Java objects and class names } \description{ Convenience wrapper that allow calling methods of Java object and classes from within the object (or class). } \usage{ \S3method{with}{jobjRef}(data, expr, ...) \S3method{within}{jobjRef}(data, expr, ...) \S3method{with}{jarrayRef}(data, expr, ...) \S3method{within}{jarrayRef}(data, expr, ...) \S3method{with}{jclassName}(data, expr, ...) \S3method{within}{jclassName}(data, expr, ...) } \arguments{ \item{data}{ A Java object reference or a java class name. See \code{\link{J}} } \item{expr}{ R expression to evaluate } \item{\dots}{ ignored } } \details{ The expression is evaluated in an environment that contains a mapping between the public fields and methods of the object. The methods of the object are mapped to standard R functions in the environment. In case of classes, only static methods are used. The fields of the object are mapped to active bindings (see \link{makeActiveBinding}) so that they can be accessed and modified from within the environment. For classes, only static fields are used. } \value{ \code{with} returns the value of the expression and \code{within} returns the \code{data} argument } \author{ Romain Francois } \references{ the \code{java.lang.reflect} package: \url{http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/package-summary.html} } \examples{ \dontshow{.jinit()} if (!nzchar(Sys.getenv("NOAWT"))) { p <- .jnew( "java/awt/Point", 0L, 0L ) with( p, { # x and y and now 0 move( 10L, 10L ) # x and y are now 10 x <- x + y } ) f <- within( .jnew( "javax/swing/JFrame" ) , { layout <- .jnew( "java/awt/BorderLayout" ) setLayout( layout ) add( .jnew( "javax/swing/JLabel", "north" ), layout$NORTH ) add( .jnew( "javax/swing/JLabel", "south" ), layout$SOUTH ) add( .jnew( "javax/swing/JLabel", "west" ), layout$WEST ) add( .jnew( "javax/swing/JLabel", "east" ), layout$EAST ) setSize( .jnew( "java/awt/Dimension", 400L, 400L ) ) setVisible( TRUE ) } ) } Double <- J("java.lang.Double") with( Double, MIN_VALUE ) with( Double, parseDouble( "10.2" ) ) \dontrun{ # inner class example % TODO: find a better example HashMap <- J("java.util.HashMap") with( HashMap, new( SimpleEntry, "key", "value" ) ) with( HashMap, SimpleEntry ) } with( J("java.lang.System"), getProperty("java.home") ) \dontshow{ stopifnot( with( Double, parseDouble("10.0") ) == 10.0 ) d <- new( Double, "10.0") stopifnot( with( d, doubleValue() ) == 10.0 ) } } \keyword{ classes } rJava/man/toJava.Rd0000644000176200001440000000261112256051760013607 0ustar liggesusers\name{toJava} \alias{toJava} \title{ Convert R objects to REXP references in Java } \description{ \code{toJava} takes an R object and creates a reference to that object in Java. This reference can then be passed to Java methods such taht they can refer to it back in R. This is commonly used to pass functions to Java such that Java code can call those functions later. } \usage{ toJava(x, engine = NULL) } \arguments{ \item{x}{R object to reference. It can be any R object and it will be retained at least for the duration of the reference on the Java side.} \item{engine}{REngine in which the reference is to be created. If null then the last created engine is used. This must be a Java object and a subclass of org.rosuda.REngine (and NOT the old org.rosuda.JRI.Rengine!). } } %\details{ %} \value{ There result is a Java reference (\code{jobjRef}) of the Java class \code{REXPReference}. } \examples{ \dontrun{ .jinit() # requires JRI and REngine classes .jengine(TRUE) f <- function() { cat("Hello!\n"); 1 } fref <- toJava(f) # to use this in Java you would use something like: # public static REXP call(REXPReference fn) throws REngineException, REXPMismatchException { # return fn.getEngine().eval(new REXPLanguage(new RList(new REXP[] { fn })), null, false); # } # .jcall("Call","Lorg/rosuda/REngine/REXP;","call", fref) } } \keyword{interface} rJava/man/jnull.Rd0000644000176200001440000000342212256051760013510 0ustar liggesusers\name{jnull} \alias{.jnull} \alias{is.jnull} \title{ Java null object reference } \description{ \code{.jnull} returns a \code{null} reference of a specified class type. The resulting object is of the class \code{jobjRef}. \code{is.jnull} is an extension of \code{is.null} that also returns \code{TRUE} if the supplied object is a \code{null} Java reference. } \usage{ .jnull(class = "java/lang/Object") is.jnull(x) } \arguments{ \item{class}{fully qualified target class name in JNI notation (e.g. \code{"java/lang/String"}).} \item{x}{object to check} } \value{ \code{.jnull} returns a Java object reference (\code{jobjRef}) of a \code{null} object having the specified object class. \code{is.jnull} returns \code{TRUE} if \code{is.null(x)} is \code{TRUE} or if \code{x} is a Java \code{null} reference. } \details{ \code{.jnull} is necesary if \code{null} is to be passed as an argument of \code{\link{.jcall}} or \code{\link{.jnew}}, in order to be able to find the correct method/constructor. Example: given the following method definitions of the class \code{A}: \itemize{ \item{o}{public static void run(String a);} \item{o}{public static void run(Double n);} } Calling \code{.jcall("A",,"run",NULL)} is ambiguous, because it is unclear which method is to be used. Therefore rJava requires class information with each argument to \code{\link{.jcall}}. If we wanted to run the String-version, we could use \code{.jcall("A",,"run",.jnull("java/lang/String"))}. \code{is.jnull} is a test that should be used to determine whether a given Java reference is a \code{null} reference. } \seealso{ \code{\link{.jcall}}, \code{\link{.jcast}} } \examples{ \dontrun{ .jcall("java/lang/System","I","identityHashCode",.jnull()) } } \keyword{interface} rJava/man/jcast.Rd0000644000176200001440000000305612256051760013473 0ustar liggesusers\name{jcast} \alias{.jcast} \title{ Cast a Java object to another class } \description{ \code{.jcast} returns a Java object reference cast to another Java class. } \usage{ .jcast(obj, new.class = "java/lang/Object", check = FALSE, convert.array = FALSE) } \arguments{ \item{obj}{a Java object reference} \item{new.class}{fully qualified class name in JNI notation (e.g. \code{"java/lang/String"}). } \item{check}{logical. If \code{TRUE}, it is checked that the object effectively is an instance of the new class. See \code{\link{\%instanceof\%}}. Using FALSE (the default) for this argument, rJava does not perform type check and this will cause an error on the first use if the cast is illegal.} \item{convert.array}{logical. If \code{TRUE} and the object is an array, it is converted into a \code{jarrayRef} reference. } } \value{ Returns a Java object reference (\code{jobjRef}) to the object \code{obj}, changing the object class. } \details{ This function is necessary if a argument of \code{\link{.jcall}} or \code{\link{.jnew}} is defined as the superclass of the object to be passed (see \code{\link{.jcall}}). The original object is not modified. The default values for the arguments \code{check} and \code{convert.array} is \code{FALSE} in order to guarantee backwards compatibility, but it is recommended to set the arguments to \code{TRUE} } \seealso{ \code{\link{.jcall}} } \examples{ \dontrun{ v <- .jnew("java/util/Vector") .jcall("java/lang/System","I","identityHashCode",.jcast(v, "java/lang/Object")) } } \keyword{interface} rJava/man/jnew.Rd0000644000176200001440000000271512256051760013333 0ustar liggesusers\name{jnew} \alias{.jnew} \title{ Create a Java object } \description{ \code{.jnew} create a new Java object. } \usage{ .jnew(class, ..., check=TRUE, silent=!check) } \arguments{ \item{class}{fully qualified class name in JNI notation (e.g. \code{"java/lang/String"}).} \item{...}{ Any parameters that will be passed to the corresponding constructor. The parameter types are determined automatically and/or taken from the \code{jobjRef} object. For details see \code{\link{.jcall}}. Note that all named parameters are discarded.} \item{check}{ If set to \code{TRUE} then \code{\link{.jcheck}} is invoked before and after the call to the constructor to clear any pending Java exceptions.} \item{silent}{ If set to \code{FALSE} then \code{.jnew} will fail with an error if the object cannot be created, otherwise a null-reference is returned instead. In addition, this flag is also passed to final \code{.jcheck} if \code{check} above is set to \code{TRUE}. Note that the error handling also clears exceptions, so \code{check=FALSE, silent=FALSE} is usually not a meaningful combination. } } \value{ Returns the reference (\code{jobjRef}) to the newly created object or \code{null}-reference (see \code{\link{.jnull}}) if something went wrong. } \seealso{ \code{\link{.jcall}}, \code{\link{.jnull}} } \examples{ \dontrun{ f <- .jnew("java/awt/Frame","Hello") .jcall(f,,"setVisible",TRUE) } } \keyword{interface} rJava/man/jmemprof.Rd0000644000176200001440000000270012256051760014201 0ustar liggesusers\name{jmemprof} \alias{.jmemprof} \title{ rJava memory profiler } \description{ \code{.jmemprof} enables or disables rJava memory profiling. If rJava was compiled without memory profiling support, then a call to this function always causes an error. } \usage{ .jmemprof(file = "-") } \arguments{ \item{file}{file to write profiling information to or \code{NULL} to disable profiling} } \value{ Returns \code{NULL}. } \details{ The \code{file} parameter must be either a filename (which will be opened in append-mode) or "-" to use standard output or \code{NULL} to disable profiling. An empty string "" is equivalent to \code{NULL} in this context. Note that lots of finalizers are run only when R exists, so usually you want to enable profiling early and let R exit to get a sensible profile. Runninng gc may be helpful to get rid of references that can be collected in R. A simple perl script is provided to analyze the result of the profiler. Due to its simple text format, it is possible to capture entire stdout including the profiler information to have both the console context for the allocations and the profile. Memory profiling is also helful if rJava debug is enabled. Note that memory profiling support must be compiled in rJava and it is by default compiled only if debug mode is enabled (which is not the case by default). } \examples{ \donttest{ .jmemprof("rJava.mem.profile.txt") } } \keyword{interface} rJava/man/jarrayRef-class.Rd0000644000176200001440000000510312256051760015412 0ustar liggesusers\name{jarrayRef-class} \docType{class} \alias{jarrayRef-class} \alias{[,jarrayRef-method} \alias{[[,jarrayRef-method} \alias{[[<-,jarrayRef-method} \alias{head,jarrayRef-method} \alias{tail,jarrayRef-method} \alias{length,jarrayRef-method} \alias{str,jarrayRef-method} \alias{unique,jarrayRef-method} \alias{duplicated,jarrayRef-method} \alias{anyDuplicated,jarrayRef-method} \alias{sort,jarrayRef-method} \alias{rev,jarrayRef-method} \alias{min,jarrayRef-method} \alias{max,jarrayRef-method} \alias{range,jarrayRef-method} \title{Class "jarrayRef" Reference to an array Java object } \description{ This class is a subclass of \link{jobjRef-class} and represents a reference to an array Java object. } \section{Objects from the Class}{ Objects cannot be created directly, but only as the return value of \code{\link{.jcall}} function. } \section{Slots}{ \describe{ \item{\code{jsig}:}{JNI signature of the array type} \item{\code{jobj}:}{Internal identifier of the object} \item{\code{jclass}:}{Inherited from \code{jobjRef}, but unspecified} } } \section{Methods}{ \describe{ \item{[}{\code{signature(x = "jarrayRef")}: \emph{not yet implemented} } \item{[[}{\code{signature(x = "jarrayRef")}: R indexing of java arrays } \item{[[<-}{\code{signature(x = "jarrayRef")}: replacement method } \item{\code{head}}{\code{signature(x = "jarrayRef")}: head of the java array } \item{\code{tail}}{\code{signature(x = "jarrayRef")}: tail of the java array } \item{length}{\code{signature(object = "jarrayRef")}: Number of java objects in the java array } \item{str}{\code{signature(object = "jarrayRef")}: ... } \item{unique}{\code{signature(x = "jarrayRef")}: \emph{not yet implemented} } \item{duplicated}{\code{signature(x = "jarrayRef")}: \emph{not yet implemented} } \item{anyDuplicated}{\code{signature(x = "jarrayRef")}: \emph{not yet implemented} } \item{sort}{\code{signature(x = "jarrayRef")}: \emph{not yet implemented} } \item{rev}{\code{signature(x = "jarrayRef")}: \emph{not yet implemented} } \item{min}{\code{signature(x = "jarrayRef")}: \emph{not yet implemented} } \item{max}{\code{signature(x = "jarrayRef")}: \emph{not yet implemented} } \item{range}{\code{signature(x = "jarrayRef")}: \emph{not yet implemented} } } } \section{Extends}{ Class \code{"\linkS4class{jobjRef}"}, directly. } \author{ Simon Urbanek } \seealso{ \code{\link{.jcall}} or \code{\linkS4class{jobjRef}} \code{\linkS4class{jrectRef}} for rectangular arrays } % need to find examples of rugged arrays % \examples{ % \dontshow{.jinit()} % } \keyword{classes} rJava/man/java-tools.Rd0000644000176200001440000000132212256051760014440 0ustar liggesusers\name{java-tools} \alias{java-tools} \title{java tools used internally in rJava} \description{java tools used internally in rJava} \examples{ \dontshow{ # running the java unit tests from the R examples .jinit() J("RJavaTools_Test")$runtests() J("RJavaArrayTools_Test")$runtests() J("ArrayWrapper_Test")$runtests() J("RectangularArrayBuilder_Test")$runtests() p <- .jnew( "java/awt/Point" ) classes <- .Call( "RgetSimpleClassNames", p@jobj, TRUE, PACKAGE = "rJava" ) stopifnot( all( c( "Point", "Point2D", "Object", "error", "condition" ) \%in\% classes ) ) classes <- .Call( "RgetSimpleClassNames", p@jobj, FALSE, PACKAGE = "rJava" ) stopifnot( all( c( "Point", "Point2D", "Object" ) \%in\% classes ) ) } } rJava/man/jcall.Rd0000644000176200001440000001170312256051760013452 0ustar liggesusers\name{jcall} \alias{.jcall} \title{ Call a Java method } \description{ \code{.jcall} calls a Java method with the supplied arguments. } \usage{ .jcall(obj, returnSig = "V", method, ..., evalArray = TRUE, evalString = TRUE, check = TRUE, interface = "RcallMethod", simplify = FALSE, use.true.class = FALSE) } \arguments{ \item{obj}{Java object (\code{jobjRef} as returned by \code{\link{.jcall}} or \code{\link{.jnew}}) or fully qualified class name in JNI notation (e.g. \code{"java/lang/String"}).} \item{returnSig}{Return signature in JNI notation (e.g. "V" for void, "[I" for \code{int[]} etc.). For convenience additional type \code{"S"} is supported and expanded to \code{"Ljava/lang/String;"}, re-mapping \code{"T"} to represent the type \code{short}.} \item{method}{The name of the method to be called} \item{...}{ Any parametes that will be passed to the Java method. The parameter types are determined automatically and/or taken from the \code{jobjRef} object. All named parameters are discarded.} \item{evalArray}{This flag determines whether the array return value is evaluated (\code{TRUE}) or passed back as Java object reference (\code{FALSE}).} \item{simplify}{If \code{evalArray} is \code{TRUE} then this argument is passed to \code{\link{.jevalArray}()}.} \item{evalString}{This flag determines whether string result is returned as characters or as Java object reference.} \item{check}{If set to \code{TRUE} then checks for exceptions are performed before and after the call using \code{\link{.jcheck}(silent=FALSE)}. This is usually the desired behavior, because all calls fail until an expection is cleared.} \item{interface}{This option is experimental and specifies the interface used for calling the Java method; the current implementation supports two interfaces: \itemize{ \item{\code{"RcallMethod"}}{the default interface.} \item{\code{"RcallSyncMethod"}}{synchronized call of a method. This has simmilar effect as using \code{synchronize} in Java.} } } \item{use.true.class}{logical. If set to \code{TRUE}, the true class of the returned object will be used instead of the declared signature. \code{TRUE} allows for example to grab the actual class of an object when the return type is an interface, or allows to grab an array when the declared type is Object and the returned object is an array. Use \code{FALSE} for efficiency when you are sure about the return type. } } \value{ Returns the result of the method. } \details{ \code{.jcall} requires exact match of argument and return types. For higher efficiency \code{.jcall} doesn't perform any lookup in the reflection tables. This means that passing subclasses of the classes present in the method definition requires explicit casting using \code{\link{.jcast}}. Passing \code{null} arguments also needs a proper class specification with \code{\link{.jnull}}. Java types \code{long} and \code{float} have no corresponding types in R and therefore any such parameters must be flagged as such using \code{\link{.jfloat}} and \code{\link{.jlong}} functions respectively. Java also distinguishes scalar and array types whereas R doesn't have the concept of a scalar. In R a scalar is basically a vector (called array in Java-speak) of the length 1. Therefore passing vectors of the length 1 is ambiguous. \code{.jcall} assumes that any vector of the length 1 that corresponds to a native Java type is a scalar. All other vectors are passed as arrays. Therefore it is important to use \code{\link{.jarray}} if an arbitrary vector (including those of the length 1) is to be passed as an array parameter. \emph{Important note about encoding of character vectors:} Java interface always works with strings in UTF-8 encoding, therefore the safest way is to run R in a UTF-8 locale. If that is not possible for some reason, rJava can be used in non-UTF-8 locales, but care must be taken. Since R 2.7.0 it is possible to associate encoding with strings and rJava will flag all strings it produces with the appropriate UTF-8 tag. R will then perform corresponding appropriate conversions where possible (at a cost of speed and memory usage), but 3rd party code may not (e.g. older packages). Also rJava relies on correct encoding flags for strings passed to it and will attempt to perform conversions where necessary. If some 3rd party code produces strings incorreclty flagged, all bets are off. Finally, for performance reasons class, method and field names as well as signatures are not always converted and should not contain non-ASCII characters. } \seealso{ \code{\link{.jnew}}, \code{\link{.jcast}}, \code{\link{.jnull}}, \code{\link{.jarray}} } \examples{ \dontshow{.jinit()} .jcall("java/lang/System","S","getProperty","os.name") if (!nzchar(Sys.getenv("NOAWT"))) { f <- .jnew("java/awt/Frame","Hello") .jcall(f,,"setVisible",TRUE) } } \keyword{interface} rJava/man/jarray.Rd0000644000176200001440000000777312256051760013671 0ustar liggesusers\name{jarray} \alias{.jarray} \alias{.jevalArray} \title{ Java array handling functions } \description{ \code{.jarray} takes a vector (or a list of Java references) as its argument, creates a Java array containing the elements of the vector (or list) and returns a reference to such newly created array. \code{.jevalArray} takes a reference to a Java array and returns its contents (if possible). } \usage{ .jarray(x, contents.class = NULL, dispatch = FALSE) .jevalArray(obj, rawJNIRefSignature = NULL, silent = FALSE, simplify = FALSE) } \arguments{ \item{x}{vector or a list of Java references} \item{contents.class}{common class of the contained objects, see details} \item{obj}{Java object reference to an array that is to be evaluated} \item{rawJNIRefSignature}{JNI signature that whould be used for conversion. If set to \code{NULL}, the signature is detected automatically.} \item{silent}{if set to true, warnings are suppressed} \item{dispatch}{logical. If \code{TRUE} the code attemps to dispatch to either a \code{jarrayRef} object for rugged arrays and \code{jrectRef} objects for rectangular arrays, creating possibly a multi-dimensional object in Java (e.g., when used with a matrix).} \item{simplify}{if set to \code{TRUE} more than two-dimensional arrays are converted to native obejcts (e.g., matrices) if their type and size matches (essentially the inverse for objects created with \code{dispatch=TRUE}).} } \value{ \code{.jarray} returns a Java array reference (\code{jarrayRef} or \code{jrectRef}) to an array created with the supplied contents. \code{.jevalArray} returns the contents of the array object. } \details{ \code{.jarray}: The input can be either a vector of some sort (such as numeric, integer, logical, ...) or a list of Java references. The contents is pushed to the Java side and a corresponding array is created. The type of the array depends on the input vector type. For example numeric vector creates \code{double[]} array, integer vector creates \code{int[]} array, character vector \code{String[]} array and so on. If \code{x} is a list, it must contain Java references only (or \code{NULL}s which will be treated as \code{NULL} references). The \code{contents.class} parameter is used only if \code{x} is a list of Java object references and it can specify the class that will be used for all objects in the array. If set to \code{NULL} no assumption is made and \code{java/lang/Object} will be used. Use with care and only if you know what you're doing - you can always use \code{\link{.jcast}} to cast the entire array to another type even if you use a more general object type. One typical use is to construct multi-dimensional arrays which mandates passing the array type as \code{contents.class}. The result is a reference to the newly created array. The inverse function which fetches the elements of an array reference is \code{.jevalArray}. \code{.jevalArray} currently supports only a subset of all possible array types. Recursive arrays are handled by returning a list of references which can then be evaluated separately. The only exception is \code{simplify=TRUE} in which case \code{.jevalArray} arrempts to convert multi-dimensional arrays into native R type if there is a such. This only works for rectangular arrays of the same basic type (i.e. the length and type of each referenced array is the same - sometimes matrices are represented that way in Java). } \examples{ \dontshow{.jinit()} a <- .jarray(1:10) print(a) .jevalArray(a) b <- .jarray(c("hello","world")) print(b) c <- .jarray(list(a,b)) print(c) # simple .jevalArray will return a list of references print(l <- .jevalArray(c)) # to convert it back, use lapply lapply(l, .jevalArray) # two-dimensional array resulting in int[2][10] d <- .jarray(list(a,a),"[I") print(d) # use dispatch to convert a matrix to [[D e <- .jarray(matrix(1:12/2, 3), dispatch=TRUE) print(e) # simplify it back to a matrix .jevalArray(e, simplify=TRUE) } \keyword{interface} rJava/configure.win0000644000176200001440000000265012256051760014024 0ustar liggesusers#!/bin/sh echo "Generate Windows-specific files (src/jvm-w32) ..." make -C src/jvm-w32 if [ $? != 0 ]; then exit 1 fi echo "Find Java..." # findjava honors JAVA_HOME environment variable, so we can safely overwite it if [ -e src/jvm-w32/findjava.exe ]; then JAVA_HOME=`src/jvm-w32/findjava -s -f` fi if [ x$JAVA_HOME = x ]; then echo "ERROR: cannot find Java Development Kit." >&2 echo " Please set JAVA_HOME to specify its location manually" >&2 exit 1 fi echo " JAVA_HOME=$JAVA_HOME" echo "JAVA_HOME:=$JAVA_HOME" > src/Makevars.java if [ -e jri/configure.win ]; then echo "=== Building JRI ===" CONFIGURED=1 export CONFIGURED if [ -z "${RHOME}" ]; then RHOME="${R_HOME}" fi R_HOME=${RHOME} export R_HOME export RHOME export JAVA_HOME cd jri sh configure.win make BR=$? cd .. if [ $BR = 0 ]; then echo "=== JRI built ===" mkdir -p inst/jri # also copy into R_ARCH is present to avoid overwriting different archs if [ -n "${R_ARCH}" ]; then mkdir -p inst/jri${R_ARCH} cp jri/src/jri.dll inst/jri${R_ARCH}/ fi # yet still install into JRI in case users get confused cp -r jri/run.bat jri/src/jri.dll jri/src/JRI.jar jri/examples inst/jri/ else echo "**** WARNING: JRI could NOT be built" >&2 if [ -z "$INGORE" ]; then echo "Set IGNORE=1 if you want to build rJava anyway." exit 1 fi fi fi echo "Configuration done."