From: Finn B. <bc...@us...> - 2001-12-16 11:22:25
|
Update of /cvsroot/jython/jython/org/python/core In directory usw-pr-cvs1:/tmp/cvs-serv25039 Modified Files: PyFile.java Log Message: RFileWrapper.truncate(): Use reflection when calling setLength(). Fix for "[ #490961 ] PyFile.java requires JDK 1.2". Index: PyFile.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/PyFile.java,v retrieving revision 2.24 retrieving revision 2.25 diff -C2 -d -r2.24 -r2.25 *** PyFile.java 2001/12/10 20:40:48 2.24 --- PyFile.java 2001/12/16 11:22:22 2.25 *************** *** 477,481 **** public void truncate(long position) throws java.io.IOException { flush(); ! file.setLength(position); } --- 477,496 ---- public void truncate(long position) throws java.io.IOException { flush(); ! try { ! // file.setLength(position); ! java.lang.reflect.Method m = file.getClass().getMethod( ! "setLength", new Class[] { Long.TYPE }); ! m.invoke(file, new Object[] { new Long(position) }); ! } catch (NoSuchMethodException exc) { ! super.truncate(position); ! } catch (SecurityException exc) { ! super.truncate(position); ! } catch (IllegalAccessException exc) { ! super.truncate(position); ! } catch (java.lang.reflect.InvocationTargetException exc) { ! if (exc.getTargetException() instanceof IOException) ! throw (IOException) exc.getTargetException(); ! super.truncate(position); ! } } |