public ASMFieldAccessorFactory() { this.fieldAccessorCache = CacheBuilder.newBuilder().build(new FieldAccessorLoader()); }
@Override public FieldAccessor load(FieldEntry key) throws Exception { // See if are able to use the "defineClass" method in the ClassLoader of the field class. Method defineClass = null; try { defineClass = ClassLoader.class.getDeclaredMethod("defineClass", String.class, byte[].class, int.class, int.class); defineClass.setAccessible(true); } catch (Exception e) { // ok to ignore this exception, it will resort to the slow reflection way. } // Generate the FieldAccessor class bytecode. ClassDefinition classDef = new FieldAccessorGenerator() .generate(key.getType().getRawType(), Fields.findField(key.getType().getType(), key.getFieldName()), defineClass == null); return createAccessor(key.getType(), classDef); }
@Override public FieldAccessor load(FieldEntry key) throws Exception { // See if are able to use the "defineClass" method in the ClassLoader of the field class. Method defineClass = null; try { defineClass = ClassLoader.class.getDeclaredMethod("defineClass", String.class, byte[].class, int.class, int.class); defineClass.setAccessible(true); } catch (Exception e) { // ok to ignore this exception, it will resort to the slow reflection way. } // Generate the FieldAccessor class bytecode. ClassDefinition classDef = new FieldAccessorGenerator() .generate(key.getType().getRawType(), Fields.findField(key.getType().getType(), key.getFieldName()), defineClass == null); return createAccessor(key.getType(), classDef); }
public ASMFieldAccessorFactory() { this.fieldAccessorCache = CacheBuilder.newBuilder().build(new FieldAccessorLoader()); }