Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
ASM tests Copyright (c) 2002-2005 France Telecom All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 package com.facebook.presto.byteCode;
 
 
 import java.util.List;
 
 import static com.facebook.presto.byteCode.ParameterizedType.type;
 import static com.facebook.presto.byteCode.ParameterizedType.typeFromPathName;
 import static com.google.common.collect.Iterables.transform;
 import static java.util.Arrays.asList;

Author(s):
Eugene Kuleshov
 
 public class ClassInfo
 {
     private final ClassInfoLoader loader;
     private final ParameterizedType type;
     private final int access;
     private final ParameterizedType superClass;
     private final List<ParameterizedTypeinterfaces;
     private final List<MethodNodemethods;
 
     public ClassInfo(ClassInfoLoader loaderClassNode classNode)
     {
         this(loader,
                 typeFromPathName(classNode.name),
                 classNode.access,
                 classNode.superName == null ? null : typeFromPathName(classNode.superName),
                 transform((List<String>) classNode.interfaces, ParameterizedType::typeFromPathName),
                 (List<MethodNode>) classNode.methods);
     }
 
     public ClassInfo(ClassInfoLoader loaderClass<?> aClass)
     {
         this(loader,
                 type(aClass),
                 aClass.getModifiers(),
                 aClass.getSuperclass() == null ? null : type(aClass.getSuperclass()),
                 transform(asList(aClass.getInterfaces()), ParameterizedType::type),
                 null);
     }
 
     public ClassInfo(ClassInfoLoader loaderParameterizedType typeint accessParameterizedType superClassIterable<ParameterizedTypeinterfacesIterable<MethodNodemethods)
     {
         Preconditions.checkNotNull(loader"loader is null");
         Preconditions.checkNotNull(type"type is null");
         Preconditions.checkNotNull(interfaces"interfaces is null");
 
         this. = loader;
         this. = type;
         this. = access;
         this. = superClass;
         this. = ImmutableList.copyOf(interfaces);
         if (methods != null) {
             this. = ImmutableList.copyOf(methods);
         }
         else {
             this. = null;
         }
     }
 
     public ParameterizedType getType()
     {
         return ;
     }
    public int getModifiers()
    {
        return ;
    }
    public ClassInfo getSuperclass()
    {
        if ( == null) {
            return null;
        }
        return .loadClassInfo();
    }
    public List<ClassInfogetInterfaces()
    {
        if ( == null) {
            return ImmutableList.of();
        }
        ImmutableList.Builder<ClassInfobuilder = ImmutableList.builder();
        for (ParameterizedType anInterface : ) {
            builder.add(.loadClassInfo(anInterface));
        }
        return builder.build();
    }
    public List<MethodNodegetMethods()
    {
        Preconditions.checkState( != null"Methods were not loaded for type %s");
        return ;
    }
    boolean isInterface()
    {
        return (getModifiers() & .) > 0;
    }
    private boolean implementsInterface(ClassInfo that)
    {
        for (ClassInfo classInfo = thisclassInfo != nullclassInfo = classInfo.getSuperclass()) {
            for (ClassInfo anInterface : classInfo.getInterfaces()) {
                if (anInterface.type.equals(that.type) || anInterface.implementsInterface(that)) {
                    return true;
                }
            }
        }
        return false;
    }
    private boolean isSubclassOf(ClassInfo that)
    {
        for (ClassInfo classInfo = thisclassInfo != nullclassInfo = classInfo.getSuperclass()) {
            if (classInfo.getSuperclass() != null &&
                    classInfo.getSuperclass()..equals(that.type)) {
                return true;
            }
        }
        return false;
    }
    public boolean isAssignableFrom(ClassInfo that)
    {
        if (this == that) {
            return true;
        }
        if (that.isSubclassOf(this)) {
            return true;
        }
        if (that.implementsInterface(this)) {
            return true;
        }
        if (that.isInterface() && getType().equals(type(Object.class))) {
            return true;
        }
        return false;
    }
    @Override
    public String toString()
    {
        return .toString();
    }
New to GrepCode? Check out our FAQ X