private boolean isVisible (JType type) { if (type == null) return false; if (type instanceof JClassType) { if (type instanceof JArrayType) { JType componentType = ((JArrayType)type).getComponentType(); while (componentType instanceof JArrayType) { componentType = ((JArrayType)componentType).getComponentType(); } if (componentType instanceof JClassType) { return ((JClassType)componentType).isPublic(); } } else { return ((JClassType)type).isPublic(); } } return true; }
private boolean isVisible (JType type) { if (type == null) return false; if (type instanceof JClassType) { if (type instanceof JArrayType) { JType componentType = ((JArrayType)type).getComponentType(); while (componentType instanceof JArrayType) { componentType = ((JArrayType)componentType).getComponentType(); } if (componentType instanceof JClassType) { return ((JClassType)componentType).isPublic(); } } else { return ((JClassType)type).isPublic(); } } return true; }
if (c.isPublic() && !c.isAbstract() && (c.getEnclosingType() == null || c.isStatic())) { createTypeInvokables(c, varName, "Constructor", c.getConstructors()); } else {
if (c.isPublic() && !c.isAbstract() && (c.getEnclosingType() == null || c.isStatic())) { createTypeInvokables(c, varName, "Constructor", c.getConstructors()); } else {
private boolean isVisible (JType type) { if (type == null) return false; if (type instanceof JClassType) { if (type instanceof JArrayType) { JType componentType = ((JArrayType)type).getComponentType(); while (componentType instanceof JArrayType) { componentType = ((JArrayType)componentType).getComponentType(); } if (componentType instanceof JClassType) { return ((JClassType)componentType).isPublic(); } } else { return ((JClassType)type).isPublic(); } } return true; }
private boolean isVisible (JType type) { if (type == null) return false; if (type instanceof JClassType) { if (type instanceof JArrayType) { JType componentType = ((JArrayType)type).getComponentType(); while (componentType instanceof JArrayType) { componentType = ((JArrayType)componentType).getComponentType(); } if (componentType instanceof JClassType) { return ((JClassType)componentType).isPublic(); } } else { return ((JClassType)type).isPublic(); } } return true; }
private boolean classIsAccessible() { JClassType testClass = serializableClass; while (testClass != null) { if (testClass.isPrivate() || (isJRE && !testClass.isPublic())) { return false; } testClass = testClass.getEnclosingType(); } return true; }
private boolean classIsAccessible() { JClassType testClass = serializableClass; while (testClass != null) { if (testClass.isPrivate() || (isJRE && !testClass.isPublic())) { return false; } testClass = testClass.getEnclosingType(); } return true; }
@Override public boolean isPublic() { return getEnclosedMetaObject().isClassOrInterface() != null && getEnclosedMetaObject().isClassOrInterface().isPublic(); }
private static boolean extractClasses(TreeLogger logger, ReflectionStrategy strategy, MemberFilter<JClassType> keepClass, JClassType injectionType, ReflectionManifest manifest) { Set<String> seen = new HashSet<String>(); Set<? extends JClassType> allTypes = injectionType.getFlattenedSupertypeHierarchy(); for(JClassType nextClass : allTypes) { for (JClassType cls : nextClass.getNestedTypes()) { if (keepClass.keepMember(cls, cls.getEnclosingType() == injectionType, cls.isPublic(), strategy)){ // do not include overridden methods // TODO check for covariance? if (seen.add(cls.getQualifiedSourceName())) { final Annotation[] annos; // only keep annotations annotated with KeepAnnotation. final List<Annotation> keepers = new ArrayList<Annotation>(); for (Annotation anno : cls.getAnnotations()) { if (keepClass.keepAnnotation(cls, anno, strategy)) keepers.add(anno); } annos = keepers.toArray(new Annotation[keepers.size()]); manifest.innerClasses.put(cls, annos); } } } nextClass = nextClass.getSuperclass(); } return true; }
@Override public boolean isPublic() { return getEnclosedMetaObject().isClassOrInterface() != null && getEnclosedMetaObject().isClassOrInterface().isPublic(); }
private static boolean extractClasses(final TreeLogger logger, final ReflectionStrategy strategy, final MemberFilter<JClassType> keepClass, final JClassType injectionType, final ReflectionManifest manifest) { final Set<String> seen = new HashSet<String>(); final Set<? extends JClassType> allTypes = injectionType.getFlattenedSupertypeHierarchy(); for(JClassType nextClass : allTypes) { for (final JClassType cls : nextClass.getNestedTypes()) { if (keepClass.keepMember(cls, cls.getEnclosingType() == injectionType, cls.isPublic(), strategy)){ // do not include overridden methods // TODO check for covariance? if (seen.add(cls.getQualifiedSourceName())) { final Annotation[] annos; // only keep annotations annotated with KeepAnnotation. final List<Annotation> keepers = new ArrayList<Annotation>(); for (final Annotation anno : cls.getAnnotations()) { if (keepClass.keepAnnotation(cls, anno, strategy)) { keepers.add(anno); } } annos = keepers.toArray(new Annotation[keepers.size()]); manifest.innerClasses.put(cls, annos); } } } nextClass = nextClass.getSuperclass(); } return true; }
private void processClassArrayAnnotation(Class<?>[] classes, Collection<JClassType> accumulator) { for (Class<?> clazz : classes) { JClassType category = oracle.findType(clazz.getCanonicalName()); if (category == null) { poison("Could not find @%s type %s in the TypeOracle", Category.class.getSimpleName(), clazz.getCanonicalName()); continue; } else if (!category.isPublic()) { poison("Category type %s is not public", category.getQualifiedSourceName()); continue; } else if (!category.isStatic() && category.isMemberType()) { poison("Category type %s must be static", category.getQualifiedSourceName()); continue; } accumulator.add(category); } } }
private void processClassArrayAnnotation(Class<?>[] classes, Collection<JClassType> accumulator) { for (Class<?> clazz : classes) { JClassType category = oracle.findType(clazz.getCanonicalName()); if (category == null) { poison("Could not find @%s type %s in the TypeOracle", Category.class.getSimpleName(), clazz.getCanonicalName()); continue; } else if (!category.isPublic()) { poison("Category type %s is not public", category.getQualifiedSourceName()); continue; } else if (!category.isStatic() && category.isMemberType()) { poison("Category type %s must be static", category.getQualifiedSourceName()); continue; } accumulator.add(category); } } }
private void processClassArrayAnnotation(Class<?>[] classes, Collection<JClassType> accumulator) { for (Class<?> clazz : classes) { JClassType category = oracle.findType(clazz.getCanonicalName()); if (category == null) { poison("Could not find @%s type %s in the TypeOracle", AutoBeanFactory.Category.class.getSimpleName(), clazz.getCanonicalName()); continue; } else if (!category.isPublic()) { poison("Category type %s is not public", category.getQualifiedSourceName()); continue; } else if (!category.isStatic() && category.isMemberType()) { poison("Category type %s must be static", category.getQualifiedSourceName()); continue; } accumulator.add(category); } } }
/** * Returns <code>true</code> if a serializer class could access this type. */ private static boolean isAccessibleToSerializer(JClassType type) { if (type.isPrivate()) { return false; } if (isInStandardJavaPackage(type.getQualifiedSourceName())) { if (!type.isPublic()) { return false; } } if (type.isMemberType()) { return isAccessibleToSerializer(type.getEnclosingType()); } return true; }
/** * Returns <code>true</code> if a serializer class could access this type. */ private static boolean isAccessibleToSerializer(JClassType type) { if (type.isPrivate()) { return false; } if (isInStandardJavaPackage(type.getQualifiedSourceName())) { if (!type.isPublic()) { return false; } } if (type.isMemberType()) { return isAccessibleToSerializer(type.getEnclosingType()); } return true; }
for (JClassType t : oracle.getTypes()) { if (t.isInterface() != null && t.isAssignableTo(jsonBuilderType)) { if (t.isPublic()) { sw.println("if (clz == " + t.getQualifiedSourceName() + ".class) return GWT.<T>create(" + t.getQualifiedSourceName() + ".class);");
/** * <p>filterSubtypesForDeserialization</p> * * @param logger a {@link com.google.gwt.core.ext.TreeLogger} object. * @param configuration a {@link com.github.nmorel.gwtjackson.rebind.RebindConfiguration} object. * @param type a {@link com.google.gwt.core.ext.typeinfo.JClassType} object. * @return a {@link com.google.gwt.thirdparty.guava.common.collect.ImmutableList} object. */ public static ImmutableList<JClassType> filterSubtypesForDeserialization( TreeLogger logger, RebindConfiguration configuration, JClassType type ) { boolean filterOnlySupportedType = isObjectOrSerializable( type ); ImmutableList.Builder<JClassType> builder = ImmutableList.builder(); if ( type.getSubtypes().length > 0 ) { for ( JClassType subtype : type.getSubtypes() ) { if ( (null == subtype.isInterface() && !subtype.isAbstract() && (!subtype.isMemberType() || subtype.isStatic())) && null == subtype.isAnnotation() && subtype.isPublic() && (!filterOnlySupportedType || (configuration.isTypeSupportedForDeserialization( logger, subtype ) // EnumSet and EnumMap are not supported in subtype deserialization because we can't know the enum to use. && !EnumSet.class.getCanonicalName().equals( subtype.getQualifiedSourceName() ) && !EnumMap.class.getCanonicalName().equals( subtype.getQualifiedSourceName() ))) && !findFirstEncounteredAnnotationsOnAllHierarchy( configuration, subtype.isClassOrInterface(), JsonIgnoreType.class, Optional.of( type ) ).isPresent() ) { builder.add( subtype ); } } } return builder.build(); }
/** * <p>filterSubtypesForSerialization</p> * * @param logger a {@link com.google.gwt.core.ext.TreeLogger} object. * @param configuration a {@link com.github.nmorel.gwtjackson.rebind.RebindConfiguration} object. * @param type a {@link com.google.gwt.core.ext.typeinfo.JClassType} object. * @return a {@link com.google.gwt.thirdparty.guava.common.collect.ImmutableList} object. */ public static ImmutableList<JClassType> filterSubtypesForSerialization( TreeLogger logger, RebindConfiguration configuration, JClassType type ) { boolean filterOnlySupportedType = isObjectOrSerializable( type ); ImmutableList.Builder<JClassType> builder = ImmutableList.builder(); if ( type.getSubtypes().length > 0 ) { for ( JClassType subtype : type.getSubtypes() ) { if ( null == subtype.isAnnotation() && subtype.isPublic() && (!filterOnlySupportedType || configuration.isTypeSupportedForSerialization( logger, subtype )) && !findFirstEncounteredAnnotationsOnAllHierarchy( configuration, subtype.isClassOrInterface(), JsonIgnoreType.class, Optional.of( type ) ).isPresent()) { builder.add( subtype ); } } } return builder.build(); }