Gets the descriptor.

@param cls the cls
@return the descriptor
@throws IOException Signals that an I/O exception has occurred.
509074
public static Descriptor getDescriptor(Class<?> cls) throws IOException {

        String idl = ProtobufIDLGenerator.getIDL(cls);
        ProtoFile file = ProtoParser.parse(ProtobufIDLProxy.DEFAULT_FILE_NAME, idl);

        FileDescriptorProtoPOJO fileDescriptorProto = new FileDescriptorProtoPOJO();

        fileDescriptorProto.name = ProtobufIDLProxy.DEFAULT_FILE_NAME;
        fileDescriptorProto.pkg = file.packageName();
        fileDescriptorProto.dependencies = file.dependencies();
        fileDescriptorProto.publicDependency = convertList(file.publicDependencies());
        fileDescriptorProto.weakDependency = null; // XXX

        fileDescriptorProto.messageTypes = new ArrayList<DescriptorProtoPOJO>();
        fileDescriptorProto.enumTypes = new ArrayList<EnumDescriptorProtoPOJO>();
        fileDescriptorProto.services = new ArrayList<ServiceDescriptorProtoPOJO>();

        Set<String> messageSet = new HashSet<String>();
        Set<String> enumSet = new HashSet<String>();

        List<TypeElement> typeElements = file.typeElements();
        if (typeElements != null) {

            for (TypeElement typeElement : typeElements) {
                if (typeElement instanceof MessageElement) {
                    messageSet.add(typeElement.name());
                } else if (typeElement instanceof EnumElement) {
                    enumSet.add(typeElement.name());
                }
            }

            for (TypeElement typeElement : typeElements) {
                if (typeElement instanceof MessageElement) {
                    fileDescriptorProto.messageTypes.add(getDescritorProtoPOJO(fileDescriptorProto,
                            (MessageElement) typeElement, messageSet, enumSet));
                } else if (typeElement instanceof EnumElement) {
                    fileDescriptorProto.enumTypes.add(
                            getDescritorProtoPOJO(fileDescriptorProto, (EnumElement) typeElement, messageSet, enumSet));
                }

            }
        }

        FileDescriptorProto fileproto;
        try {
            byte[] bs = descriptorCodec.encode(fileDescriptorProto);
            fileproto = FileDescriptorProto.parseFrom(bs);
        } catch (InvalidProtocolBufferException e) {
            throw new IOException("Failed to parse protocol buffer descriptor for generated code.", e);
        }

        FileDescriptor fileDescriptor;
        try {
            fileDescriptor =
                    FileDescriptor.buildFrom(fileproto, new com.google.protobuf.Descriptors.FileDescriptor[] {});
        } catch (DescriptorValidationException e) {
            throw new IOException(e.getMessage(), e);
        }

        return fileDescriptor.getMessageTypes().get(0);
    }
1328852
public static Class<?> getTypeByDescriptor(TypeDescriptor type) {
		if (type == null)
			throw new NullPointerException("Type descriptor cannot be null");

		return getType(type.getName(), type.getLibrary());
	}
429958
public IJsonMarshaller getIJsonMarshallerInstance(Class<? extends IJsonMarshaller> cls) throws JsonMarshallerException {
		if(logger.isDebugEnabled()) {
			logger.debug("Try to get {} by CDI.select Unsatisfied: {}", cls.getName(), CDI.current().select(cls).isUnsatisfied());
		}
		if(CDI.current().select(cls).isUnsatisfied()) {
			throw new JsonMarshallerException(cls.getName()+" is Unsatisfied");
		}
		return CDI.current().select(cls).get();
	}
773253
public static String descriptorMethodSource(Class cls) {
        String descriptorClsName = ClassHelper.getInternalName(Descriptor.class.getCanonicalName());
        
        String code = "if (this.descriptor != null) {" + ClassCode.LINE_BREAK  +
                            "return this.descriptor;" + ClassCode.LINE_BREAK  +
                       "}" + ClassCode.LINE_BREAK +
                       "%s descriptor = CodedConstant.getDescriptor(%s);" + ClassCode.LINE_BREAK  +
                       "return (this.descriptor = descriptor);"; 
        
        return String.format(code, descriptorClsName, 
                ClassHelper.getInternalName(cls.getCanonicalName()) + CodeGenerator.JAVA_CLASS_FILE_SUFFIX);
        
    }
1058005
public Serializer getSerializer(Class cls) {
    SerializerWrapper w = getSerializerWrapper(cls);
    if (w != null) {
      return w.serializer;
    }
    return null;
  }
607779
ClassFields get(final Class<?> cls) {
        ClassFields classFields = classToClassFields.get(cls);
        if (classFields == null) {
            classToClassFields.put(cls,
                    classFields = new ClassFields(cls, resolveTypes, onlySerializePublicFields, this));
        }
        return classFields;
    }
14860
public static <T extends SerializableObject> T deserialize(File file, Class<T> cls) throws IOException {
		FileInputStream stream = null;
		try {
			stream = new FileInputStream(file);
			DataInputStream in = new DataInputStream(stream);

			try {
				Constructor<T> constructor = cls.getDeclaredConstructor(DataInput.class);
				constructor.setAccessible(true);
				return constructor.newInstance(in);
			} catch (Exception e) {
				throw new IOException("Unable to instantiate class: " + cls, e);
			}
		} finally {
			Util.ensureClosed(stream);
		}
	}
786181
public static ClassDescriptorCache getInstance() {
    if (INSTANCE == null) {
      synchronized (ClassDescriptorCache.class) {
        if (INSTANCE == null) {
          INSTANCE = new ClassDescriptorCache();
        }
      }
    }
    return INSTANCE;
  }
1339893
public static Object loadGenInstance(Class<?> cls) throws ParserException
    {
        try
        {
            Class<?> parserClass;
            try
            {
                parserClass = loadGenClass(cls);
            }
            catch (ClassNotFoundException ex)
            {
                return null;
            }
            return parserClass.newInstance();
        }
        catch (InstantiationException | IllegalAccessException ex)
        {
            throw new ParserException(ex);
        }
    }
402493
public static Class<?> unwrap(final Class<?> cls) {
        N.checkArgNotNull(cls, "cls");

        Class<?> unwrapped = PRIMITIVE_2_WRAPPER.getByValue(cls);

        return unwrapped == null ? cls : unwrapped;
    }
657103
protected ClassDescriptor getClassDescriptor()
    {
        ClassDescriptor cld = (ClassDescriptor) m_classDescriptor.get();
        if(cld == null)
        {
            throw new OJBRuntimeException("Requested ClassDescriptor instance was already GC by JVM");
        }
        return cld;
    }
171808
private List<PropertyDescriptor> getPropertyDescriptorsForClass(Class<?> clasz) {
        try {
            BeanInfo beanInfo = Introspector.getBeanInfo(clasz);
            return Arrays.asList(beanInfo.getPropertyDescriptors());
        } catch (IntrospectionException e) {
            LOGGER.error("instantiation exception while trying to create instance of class {}", clasz.getName());
        }
        return Lists.newArrayList();
    }
1199782
private ContractImpl getContractImpl(final Class<?> cls) throws InitializationError {
        final ContractImpl impl = cls.getAnnotation( ContractImpl.class );
        if (impl == null) {

            throw new InitializationError( "Classes annotated as @RunWith( ContractSuite ) [" + cls
                    + "] must also be annotated with @ContractImpl" );
        }
        return impl;
    }
1165633
static public Object deserialize(InputStream in, Class<?> cls)
		throws IOException
	{
		if (cls==null)
			throw new NullPointerException("cls");
		
		Object obj = deserialize(in);
		if (!cls.isInstance(obj))
		{
			throw new InvalidObjectException("type of deserialized instance not of required class.");
		}
		
		return obj;
	}
754432
public EditorDescriptor getEditorDescriptor(Object editorObject) {
		Class editorClass = editorObject.getClass();
		EditorDescriptor descriptor = (EditorDescriptor)editorMap.get(editorClass);
		if(descriptor == null){
			Iterator it = editorMap.keySet().iterator();
			while(it.hasNext()){
				Class klass = (Class)it.next();
				if(klass.isAssignableFrom(editorClass)){
					descriptor = (EditorDescriptor)editorMap.get(klass);
				}
			}
		}
		return descriptor;
	}
79703
@SafeVarargs
    public static <T> Constructor<T> getDeclaredConstructor(final Class<T> cls, final Class<?>... parameterTypes) {
        Map<Class<?>[], Constructor<?>> constructorPool = classDeclaredConstructorPool.get(cls);
        Constructor<T> constructor = null;

        if (constructorPool != null) {
            constructor = (Constructor<T>) constructorPool.get(parameterTypes);
        }

        if (constructor == null) {
            try {
                constructor = cls.getDeclaredConstructor(parameterTypes);

                // SHOULD NOT set it true here.
                // constructor.setAccessible(true);
            } catch (NoSuchMethodException e) {
                // ignore.
            }

            if (constructor != null) {
                if (constructorPool == null) {
                    constructorPool = new ArrayHashMap<>(ConcurrentHashMap.class);
                    classDeclaredConstructorPool.put(cls, constructorPool);
                }

                constructorPool.put(parameterTypes.clone(), constructor);
            }
        }

        return constructor;
    }
1023032
public static String getDescriptor(final Class c) {
        StringBuffer buf = new StringBuffer();
        getDescriptor(buf, c);
        return buf.toString();
    }