List of usage examples for java.lang Class isSynthetic
public boolean isSynthetic()
From source file:fr.exanpe.tapestry.tldgen.taglib.builder.StructureBuilder.java
/** * Builds the output taglib structure/* w w w .java 2 s .c o m*/ * * @param rootPackage the root package to look the components for * @param supportedPackages all sub packages to scan * @param urls the urls used to scan the packages * @return the structure containing the information on the taglib to generate * @throws MojoExecutionException if any unexpected error occurs */ public Taglib build(String rootPackage, String[] supportedPackages, URL[] urls) throws MojoExecutionException { Taglib taglib = new Taglib(); log.debug("Creating taglib object model..."); for (String subPackage : supportedPackages) { String pkgname = rootPackage + "." + subPackage; log.debug("Processing taglib for full package named : " + pkgname); Reflections reflections = new Reflections(new ConfigurationBuilder() .filterInputsBy(new FilterBuilder.Include(FilterBuilder.prefix(pkgname))).setUrls(urls) .setScanners(new TypesScanner())); Store store = reflections.getStore(); // Return classes anaylised by TypeScanner Multimap<String, String> classes = store.getStoreMap().values().iterator().next(); log.debug(String.format("%s classes to analyse for %s package...", classes.keySet().size(), pkgname)); // Loop on found classes for (final String s : classes.keySet()) { Class<?> c; try { log.debug(String.format("Load class %s into classloader", s)); c = Thread.currentThread().getContextClassLoader().loadClass(s); } catch (ClassNotFoundException e) { // should not happen as it has just been parsed by Reflection... log.error(e); throw new MojoExecutionException("Class loader internal error for class :" + s, e); } if (!c.isAnnotation() && !c.isAnonymousClass() && !c.isEnum() && !c.isInterface() && !c.isLocalClass() && !c.isMemberClass() && !c.isSynthetic() && !Modifier.isAbstract(c.getModifiers())) { log.debug("Processing Tag : " + c.getName()); Tag tag = buildTagFromClass(rootPackage, c); taglib.getTags().add(tag); } } } log.debug("Taglib object model completed"); return taglib; }
From source file:com.feilong.commons.core.lang.ClassUtil.java
/** * class info map for log./*from w w w. j a v a2 s. c o m*/ * * @param klass * the clz * @return the map for log */ public static Map<String, Object> getClassInfoMapForLog(Class<?> klass) { Map<String, Object> map = new LinkedHashMap<String, Object>(); //"clz.getCanonicalName()": "com.feilong.commons.core.date.DatePattern", //"clz.getName()": "com.feilong.commons.core.date.DatePattern", //"clz.getSimpleName()": "DatePattern", // getCanonicalName ( Java Language Specification ??) && getName //??class?array? // getName[[Ljava.lang.String?getCanonicalName? map.put("clz.getCanonicalName()", klass.getCanonicalName()); map.put("clz.getName()", klass.getName()); map.put("clz.getSimpleName()", klass.getSimpleName()); map.put("clz.getComponentType()", klass.getComponentType()); // ?? voidboolean?byte?char?short?int?long?float double? map.put("clz.isPrimitive()", klass.isPrimitive()); // ??, map.put("clz.isLocalClass()", klass.isLocalClass()); // ????,?????? map.put("clz.isMemberClass()", klass.isMemberClass()); //isSynthetic()?Class????java??false?trueJVM???java?????? map.put("clz.isSynthetic()", klass.isSynthetic()); map.put("clz.isArray()", klass.isArray()); map.put("clz.isAnnotation()", klass.isAnnotation()); //??true map.put("clz.isAnonymousClass()", klass.isAnonymousClass()); map.put("clz.isEnum()", klass.isEnum()); return map; // Class<?> klass = this.getClass(); // // TypeVariable<?>[] typeParameters = klass.getTypeParameters(); // TypeVariable<?> typeVariable = typeParameters[0]; // // Type[] bounds = typeVariable.getBounds(); // // Type bound = bounds[0]; // // if (log.isDebugEnabled()){ // log.debug("" + (bound instanceof ParameterizedType)); // } // // Class<T> modelClass = ReflectUtil.getGenericModelClass(klass); // return modelClass; }
From source file:com.github.wshackle.java4cpp.J4CppMain.java
public static boolean isAddableClass(Class<?> clss, Set<Class> excludedClasses) { if (clss.isArray() || clss.isSynthetic() || clss.isAnnotation() || clss.isPrimitive()) { return false; }//from w ww . j a va 2 s . c o m // if(clss.getCanonicalName().contains("Dialog") || clss.getName().contains("ModalExlusionType")) { // if(verbose) System.out.println("clss = " + clss); // } // if (clss.getEnclosingClass() != null) { // return false; // } String canonicalName = null; try { canonicalName = clss.getCanonicalName(); } catch (Throwable t) { // leaving canonicalName null is enough } if (null == canonicalName) { return false; } if (canonicalName.indexOf('$') >= 0) { return false; } String pkgNames[] = clss.getCanonicalName().split("\\."); for (int i = 0; i < pkgNames.length; i++) { String pkgName = pkgNames[i]; if (badNames.contains(pkgName)) { return false; } } Method ma[] = null; try { ma = clss.getDeclaredMethods(); } catch (Throwable t) { // leaving canonicalName null is enough } if (null == ma) { return false; } return !excludedClasses.contains(clss); }
From source file:ca.oson.json.Oson.java
private boolean ignoreClass(Class valueType) { Set<MODIFIER> set = getIncludeFieldsWithModifiers(); if (valueType.isSynthetic() && (set == null || !set.contains(MODIFIER.Synthetic))) { return true; }/* ww w . java 2s. co m*/ Map<Class, ClassMapper> classMappers = getClassMappers(); if (classMappers != null) { ClassMapper mapper = classMappers.get(valueType); if (mapper != null) { return mapper.ignore; } } return false; }