/[classpath]/classpath/java/lang/Class.java
ViewVC logotype

Diff of /classpath/java/lang/Class.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.22.2.8 by gnu_andrew, Sat Jan 15 17:01:52 2005 UTC revision 1.22.2.9 by gnu_andrew, Sun Jan 16 15:15:12 2005 UTC
# Line 38  exception statement from your version. * Line 38  exception statement from your version. *
38    
39  package java.lang;  package java.lang;
40    
41    import gnu.classpath.VMStackWalker;
42    
43  import java.io.InputStream;  import java.io.InputStream;
44  import java.io.Serializable;  import java.io.Serializable;
45  import java.lang.reflect.Constructor;  import java.lang.reflect.Constructor;
# Line 130  public final class Class<T> implements S Line 132  public final class Class<T> implements S
132    Class(Object vmdata, ProtectionDomain pd)    Class(Object vmdata, ProtectionDomain pd)
133    {    {
134      this.vmdata = vmdata;      this.vmdata = vmdata;
135      this.pd = pd;      // If the VM didn't supply a protection domain and the class is an array,
136        // we "inherit" the protection domain from the component type class. This
137        // saves the VM from having to worry about protection domains for array
138        // classes.
139        if (pd == null && isArray())
140          this.pd = getComponentType().pd;
141        else
142          this.pd = pd;
143    }    }
144    
145    /**    /**
# Line 151  public final class Class<T> implements S Line 160  public final class Class<T> implements S
160      Class<?> result = VMClass.forName (name);      Class<?> result = VMClass.forName (name);
161      if (result == null)      if (result == null)
162        result = Class.forName(name, true,        result = Class.forName(name, true,
163                               VMSecurityManager.getClassContext()[1].getClassLoader());          VMStackWalker.getCallingClassLoader());
164      return result;      return result;
165    }    }
166    
# Line 189  public final class Class<T> implements S Line 198  public final class Class<T> implements S
198      if (classloader == null)      if (classloader == null)
199        {        {
200          // Check if we may access the bootstrap classloader          // Check if we may access the bootstrap classloader
201          SecurityManager sm = System.getSecurityManager();          SecurityManager sm = SecurityManager.current;
202          if (sm != null)          if (sm != null)
203            {            {
204              // Get the calling class and classloader              // Get the calling classloader
205              Class<?> c = VMSecurityManager.getClassContext()[1];              ClassLoader cl = VMStackWalker.getCallingClassLoader();
             ClassLoader cl = c.getClassLoader();  
206              if (cl != null)              if (cl != null)
207                sm.checkPermission(new RuntimePermission("getClassLoader"));                sm.checkPermission(new RuntimePermission("getClassLoader"));
208            }            }
# Line 269  public final class Class<T> implements S Line 277  public final class Class<T> implements S
277    
278      ClassLoader loader = VMClass.getClassLoader(this);      ClassLoader loader = VMClass.getClassLoader(this);
279      // Check if we may get the classloader      // Check if we may get the classloader
280      SecurityManager sm = System.getSecurityManager();      SecurityManager sm = SecurityManager.current;
281      if (sm != null)      if (sm != null)
282        {        {
283          // Get the calling class and classloader          // Get the calling classloader
284          Class c = VMSecurityManager.getClassContext()[1];          ClassLoader cl = VMStackWalker.getCallingClassLoader();
         ClassLoader cl = VMClass.getClassLoader(c);  
285          if (cl != null && !cl.isAncestorOf(loader))          if (cl != null && !cl.isAncestorOf(loader))
286            sm.checkPermission(new RuntimePermission("getClassLoader"));            sm.checkPermission(new RuntimePermission("getClassLoader"));
287        }        }
# Line 1126  public final class Class<T> implements S Line 1133  public final class Class<T> implements S
1133      int modifiers = constructor.getModifiers();      int modifiers = constructor.getModifiers();
1134      if (!Modifier.isPublic(modifiers))      if (!Modifier.isPublic(modifiers))
1135        {        {
1136          Class caller = VMSecurityManager.getClassContext()[1];          Class caller = VMStackWalker.getCallingClass();
1137          if (caller != this &&          if (caller != null &&
1138                caller != this &&
1139              (Modifier.isPrivate(modifiers)              (Modifier.isPrivate(modifiers)
1140               || getClassLoader() != caller.getClassLoader()               || getClassLoader() != caller.getClassLoader()
1141               || !getPackagePortion(getName())               || !getPackagePortion(getName())
# Line 1162  public final class Class<T> implements S Line 1170  public final class Class<T> implements S
1170     */     */
1171    public ProtectionDomain getProtectionDomain()    public ProtectionDomain getProtectionDomain()
1172    {    {
1173      SecurityManager sm = System.getSecurityManager();      SecurityManager sm = SecurityManager.current;
1174      if (sm != null)      if (sm != null)
1175        sm.checkPermission(new RuntimePermission("getProtectionDomain"));        sm.checkPermission(new RuntimePermission("getProtectionDomain"));
1176    
# Line 1214  public final class Class<T> implements S Line 1222  public final class Class<T> implements S
1222          }          }
1223      else      else
1224        {        {
1225          status = ClassLoader.systemClassAssertionStatus.get(getName());          status = ClassLoader.StaticData.
1226                        systemClassAssertionStatus.get(getName());
1227          if (status != null)          if (status != null)
1228            return status.equals(Boolean.TRUE);            return status.equals(Boolean.TRUE);
1229        }        }
# Line 1238  public final class Class<T> implements S Line 1247  public final class Class<T> implements S
1247        {        {
1248          String name = getPackagePortion(getName());          String name = getPackagePortion(getName());
1249          if ("".equals(name))          if ("".equals(name))
1250            status = ClassLoader.systemPackageAssertionStatus.get(null);            status = ClassLoader.StaticData.
1251                        systemPackageAssertionStatus.get(null);
1252          else          else
1253            do            do
1254              {              {
1255                status = ClassLoader.systemPackageAssertionStatus.get(name);                status = ClassLoader.StaticData.
1256                            systemPackageAssertionStatus.get(name);
1257                name = getPackagePortion(name);                name = getPackagePortion(name);
1258              }              }
1259            while (! "".equals(name) && status == null);            while (! "".equals(name) && status == null);
# Line 1321  public final class Class<T> implements S Line 1332  public final class Class<T> implements S
1332     */     */
1333    private void memberAccessCheck(int which)    private void memberAccessCheck(int which)
1334    {    {
1335      SecurityManager sm = System.getSecurityManager();      SecurityManager sm = SecurityManager.current;
1336      if (sm != null)      if (sm != null)
1337        {        {
1338          sm.checkMemberAccess(this, which);          sm.checkMemberAccess(this, which);

Legend:
Removed from v.1.22.2.8  
changed lines
  Added in v.1.22.2.9

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26