/[classpath]/classpath/java/io/ObjectStreamClass.java
ViewVC logotype

Diff of /classpath/java/io/ObjectStreamClass.java

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

revision 1.35 by mkoch, Sat Oct 2 08:44:39 2004 UTC revision 1.36 by jfrijters, Wed Dec 1 10:13:33 2004 UTC
# Line 452  public class ObjectStreamClass implement Line 452  public class ObjectStreamClass implement
452    }    }
453    
454    private Method findMethod(Method[] methods, String name, Class[] params,    private Method findMethod(Method[] methods, String name, Class[] params,
455                              Class returnType)                              Class returnType, boolean mustBePrivate)
456    {    {
457  outer:  outer:
458      for(int i = 0; i < methods.length; i++)      for (int i = 0; i < methods.length; i++)
459      {      {
460          if(methods[i].getName().equals(name) &&          final Method m = methods[i];
461             methods[i].getReturnType() == returnType)          int mods = m.getModifiers();
462            if (Modifier.isStatic(mods)
463                || (mustBePrivate && !Modifier.isPrivate(mods)))
464            {
465                continue;
466            }
467    
468            if (m.getName().equals(name)
469               && m.getReturnType() == returnType)
470          {          {
471              Class[] mp = methods[i].getParameterTypes();              Class[] mp = m.getParameterTypes();
472              if(mp.length == params.length)              if (mp.length == params.length)
473              {              {
474                  for(int j = 0; j < mp.length; j++)                  for (int j = 0; j < mp.length; j++)
475                  {                  {
476                      if(mp[j] != params[j])                      if (mp[j] != params[j])
477                      {                      {
478                          continue outer;                          continue outer;
479                      }                      }
480                  }                  }
481                  final Method m = methods[i];                  AccessController.doPrivileged(new SetAccessibleAction(m));
                 SetAccessibleAction setAccessible = new SetAccessibleAction(m);  
                 AccessController.doPrivileged(setAccessible);  
482                  return m;                  return m;
483              }              }
484          }          }
# Line 485  outer: Line 491  outer:
491      Method[] methods = forClass().getDeclaredMethods();      Method[] methods = forClass().getDeclaredMethods();
492      readObjectMethod = findMethod(methods, "readObject",      readObjectMethod = findMethod(methods, "readObject",
493                                    new Class[] { ObjectInputStream.class },                                    new Class[] { ObjectInputStream.class },
494                                    Void.TYPE);                                    Void.TYPE, true);
495        writeObjectMethod = findMethod(methods, "writeObject",
496                                       new Class[] { ObjectOutputStream.class },
497                                       Void.TYPE, true);
498      readResolveMethod = findMethod(methods, "readResolve",      readResolveMethod = findMethod(methods, "readResolve",
499                                     new Class[0], Object.class);                                     new Class[0], Object.class, false);
500        writeReplaceMethod = findMethod(methods, "writeReplace",
501                                        new Class[0], Object.class, false);
502    }    }
503    
504    private ObjectStreamClass(Class cl)    private ObjectStreamClass(Class cl)
# Line 517  outer: Line 528  outer:
528        // only set this bit if CL is NOT Externalizable        // only set this bit if CL is NOT Externalizable
529        flags |= ObjectStreamConstants.SC_SERIALIZABLE;        flags |= ObjectStreamConstants.SC_SERIALIZABLE;
530    
531      try      if (writeObjectMethod != null)
532        {        flags |= ObjectStreamConstants.SC_WRITE_METHOD;
         Method writeMethod = cl.getDeclaredMethod("writeObject",  
                                                   writeMethodArgTypes);  
         int modifiers = writeMethod.getModifiers();  
   
         if (writeMethod.getReturnType() == Void.TYPE  
             && Modifier.isPrivate(modifiers)  
             && !Modifier.isStatic(modifiers))  
           flags |= ObjectStreamConstants.SC_WRITE_METHOD;  
       }  
     catch(NoSuchMethodException oh_well)  
       {  
       }  
533    }    }
534    
535    
# Line 884  outer: Line 883  outer:
883    
884    Method readObjectMethod;    Method readObjectMethod;
885    Method readResolveMethod;    Method readResolveMethod;
886      Method writeReplaceMethod;
887      Method writeObjectMethod;
888    boolean realClassIsSerializable;    boolean realClassIsSerializable;
889    boolean realClassIsExternalizable;    boolean realClassIsExternalizable;
890    ObjectStreamField[] fieldMapping;    ObjectStreamField[] fieldMapping;

Legend:
Removed from v.1.35  
changed lines
  Added in v.1.36

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