From: Daniel R. <dl...@fi...> - 2003-03-26 18:27:31
|
Jeff, I don't know of any reason why this wouldn't work in a "standard" Java application, but are you aware of any issues with using Class.forName() from an applet? It's been ages since I touched one of those things. - Dan Jeff Emanuel <JEm...@lg...> writes: > Cool! You beat me to it. I was out today and couldn't get > to it until after you had finished. > > I didn't do anything rash like try to test this, but here's a first > cut (against today's CVS): > > Index: org/python/core/PyString.java > =================================================================== > RCS file: /cvsroot/jython/jython/org/python/core/PyString.java,v > retrieving revision 2.60 > diff -u -r2.60 PyString.java > --- org/python/core/PyString.java 6 Nov 2002 08:15:21 -0000 > 2.60 > +++ org/python/core/PyString.java 25 Mar 2003 17:06:02 -0000 > @@ -236,6 +236,15 @@ > */ > public class PyString extends PySequence implements ClassDictInit > { > + private static Class charSequence = null; > + static { > + try { > + charSequence = Class.forName("java.lang.CharSequence"); > + } > + catch (Throwable jdkLessThanOneDotFour) { > + } > + } > + > private String string; > private transient int cached_hashcode=0; > private transient boolean interned=false; > @@ -661,7 +670,8 @@ > > public Object __tojava__(Class c) { > //This is a hack to make almost all Java calls happy > - if (c == String.class || c == Object.class || c == > Serializable.class) > + if (c == String.class || c == Object.class || c == > Serializable.class > + || (charSequence != null && > charSequence.isAssignableFrom(c))) > return string; > if (c == Character.TYPE || c == Character.class) > if (string.length() == 1) |