private void readObject(java.io.ObjectInputStream in) 
                 throws IOException, ClassNotFoundException
    {
        in.defaultReadObject();

        if (_elemDesc == null)  // element is a Class
            _annotElem = _elemClass;
        else
        {
            int argsIndex = _elemDesc.indexOf('(');
            if (argsIndex < 0)  // element is a Field
            {
                try
                {
                    _annotElem = _elemClass.getDeclaredField(_elemDesc);
                }
                catch (NoSuchFieldException nsfe)
                {
                    throw new IOException("Unable to locate field " + nsfe);
                }
            }
            else // element is a method
            {
                String methodName = _elemDesc.substring(0, argsIndex);
                if (_elemDesc.charAt(argsIndex+1) == ')')
                {
                    // At least handle the null args case quickly
                    try
                    {
                        _annotElem = _elemClass.getDeclaredMethod(methodName, new Class [] {});
                    }
                    catch (NoSuchMethodException nsme)
                    {
                        throw new IOException("Unable to locate method " +_elemDesc);
                    }
                }
                else
                {
                    // Linear search for the rest :(
                    String methodArgs = _elemDesc.substring(argsIndex+1, _elemDesc.length()-1);
                    Method [] methods = _elemClass.getDeclaredMethods();
                    for (int i = 0; i < methods.length; i++)
                    {
                        if (methods[i].getName().equals(methodName) &&
                            getMethodArgs(methods[i]).equals(methodArgs))
                        {
                            _annotElem = methods[i];
                            break;
                        }
                    }

                    if (_annotElem == null)
                    {
                        throw new IOException("Unable to locate method " +  _elemDesc);
                    }
                }
            }
        }
    }
private void readObject ( java . io . ObjectInputStream in ) throws IOException , ClassNotFoundException { in . defaultReadObject ( ) ; if ( _elemDesc == null ) _annotElem = _elemClass ; else { int argsIndex = _elemDesc . indexOf ( '(' ) ; if ( argsIndex < 0 ) { try { _annotElem = _elemClass . getDeclaredField ( _elemDesc ) ; } catch ( NoSuchFieldException nsfe ) { throw new IOException ( "Unable to locate field " + nsfe ) ; } } else { String methodName = _elemDesc . substring ( 0 , argsIndex ) ; if ( _elemDesc . charAt ( argsIndex + 1 ) == ')' ) { try { _annotElem = _elemClass . getDeclaredMethod ( methodName , new Class [ ] { } ) ; } catch ( NoSuchMethodException nsme ) { throw new IOException ( "Unable to locate method " + _elemDesc ) ; } } else { String methodArgs = _elemDesc . substring ( argsIndex + 1 , _elemDesc . length ( ) - 1 ) ; Method [ ] methods = _elemClass . getDeclaredMethods ( ) ; for ( int i = 0 ; i < methods . length ; i ++ ) { if ( methods [ i ] . getName ( ) . equals ( methodName ) && getMethodArgs ( methods [ i ] ) . equals ( methodArgs ) ) { _annotElem = methods [ i ] ; break ; } } if ( _annotElem == null ) { throw new IOException ( "Unable to locate method " + _elemDesc ) ; } } } } }
Overrides the standard Serialization readObject implementation to reassociated with the
target AnnotatedElement after deserialization.