From: Jeff E. <JEm...@lg...> - 2003-03-26 18:37:16
|
Here's a quote from the javadoc for the Class.forName method that takes 3 arguments. Unsigned applets have a security manager that denies almost everything. If the loader is null, and a security manager is present, and the caller's class loader is not null, then this method calls the security manager's checkPermission method with a RuntimePermission("getClassLoader") permission to ensure it's ok to access the bootstrap class loader. > -----Original Message----- > From: Daniel Rall [mailto:dl...@fi...] > Sent: Wednesday, March 26, 2003 11:28 AM > To: Jeff Emanuel > Cc: ''Finn Bock ' '; '''Mike GARCIA' ' '; > '''jyt...@li...' ' ' > Subject: Re: [Jython-dev] [PATCH] Cross JDK support for > java.lang.CharSequ ence > > > 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) > |