-構成(複雑なタイプ) -タイプ -単純型(simpletypetype-文字列/ long / int / enum、enumクラス) -ComplexType(属性、一部のプロパティ) -属性(名前、タイプ、一部のプロパティ、一部のJPAプロパティ)
<? xml version ="1.0" encoding ="utf-8" ? > < xs:schema xmlns:xs ="http://www.w3.org/2001/XMLSchema" xmlns:meta ="http://www.arptek.ru/core/meta" targetNamespace ="http://www.arptek.ru/core/meta/test" > < xs:complexType name ="Test" > < xs:annotation > < xs:appinfo > < meta:java.interface > ru.arptek.meta.SomeInterface </ meta:java.interface > </ xs:appinfo > </ xs:annotation > < xs:sequence > < xs:element name ="id" type ="xs:int" meta:jpa . Id ="true" /> < xs:element name ="string" type ="xs:string" /> < xs:element name ="boolean" type ="xs:boolean" /> < xs:element name ="integer" type ="xs:int" /> < xs:element name ="long" type ="xs:long" /> </ xs:sequence > </ xs:complexType > </ xs:schema > * This source code was highlighted with Source Code Highlighter .
<? xml version ="1.0" encoding ="utf-8" ? > < xs:schema xmlns:xs ="http://www.w3.org/2001/XMLSchema" xmlns:meta ="http://www.arptek.ru/core/meta" targetNamespace ="http://www.arptek.ru/core/meta/test" > < xs:complexType name ="Test" > < xs:annotation > < xs:appinfo > < meta:java.interface > ru.arptek.meta.SomeInterface </ meta:java.interface > </ xs:appinfo > </ xs:annotation > < xs:sequence > < xs:element name ="id" type ="xs:int" meta:jpa . Id ="true" /> < xs:element name ="string" type ="xs:string" /> < xs:element name ="boolean" type ="xs:boolean" /> < xs:element name ="integer" type ="xs:int" /> < xs:element name ="long" type ="xs:long" /> </ xs:sequence > </ xs:complexType > </ xs:schema > * This source code was highlighted with Source Code Highlighter .<? xml version ="1.0" encoding ="utf-8" ? > < xs:schema xmlns:xs ="http://www.w3.org/2001/XMLSchema" xmlns:meta ="http://www.arptek.ru/core/meta" targetNamespace ="http://www.arptek.ru/core/meta/test" > < xs:complexType name ="Test" > < xs:annotation > < xs:appinfo > < meta:java.interface > ru.arptek.meta.SomeInterface </ meta:java.interface > </ xs:appinfo > </ xs:annotation > < xs:sequence > < xs:element name ="id" type ="xs:int" meta:jpa . Id ="true" /> < xs:element name ="string" type ="xs:string" /> < xs:element name ="boolean" type ="xs:boolean" /> < xs:element name ="integer" type ="xs:int" /> < xs:element name ="long" type ="xs:long" /> </ xs:sequence > </ xs:complexType > </ xs:schema > * This source code was highlighted with Source Code Highlighter .<? xml version ="1.0" encoding ="utf-8" ? > < xs:schema xmlns:xs ="http://www.w3.org/2001/XMLSchema" xmlns:meta ="http://www.arptek.ru/core/meta" targetNamespace ="http://www.arptek.ru/core/meta/test" > < xs:complexType name ="Test" > < xs:annotation > < xs:appinfo > < meta:java.interface > ru.arptek.meta.SomeInterface </ meta:java.interface > </ xs:appinfo > </ xs:annotation > < xs:sequence > < xs:element name ="id" type ="xs:int" meta:jpa . Id ="true" /> < xs:element name ="string" type ="xs:string" /> < xs:element name ="boolean" type ="xs:boolean" /> < xs:element name ="integer" type ="xs:int" /> < xs:element name ="long" type ="xs:long" /> </ xs:sequence > </ xs:complexType > </ xs:schema > * This source code was highlighted with Source Code Highlighter .<? xml version ="1.0" encoding ="utf-8" ? > < xs:schema xmlns:xs ="http://www.w3.org/2001/XMLSchema" xmlns:meta ="http://www.arptek.ru/core/meta" targetNamespace ="http://www.arptek.ru/core/meta/test" > < xs:complexType name ="Test" > < xs:annotation > < xs:appinfo > < meta:java.interface > ru.arptek.meta.SomeInterface </ meta:java.interface > </ xs:appinfo > </ xs:annotation > < xs:sequence > < xs:element name ="id" type ="xs:int" meta:jpa . Id ="true" /> < xs:element name ="string" type ="xs:string" /> < xs:element name ="boolean" type ="xs:boolean" /> < xs:element name ="integer" type ="xs:int" /> < xs:element name ="long" type ="xs:long" /> </ xs:sequence > </ xs:complexType > </ xs:schema > * This source code was highlighted with Source Code Highlighter .<? xml version ="1.0" encoding ="utf-8" ? > < xs:schema xmlns:xs ="http://www.w3.org/2001/XMLSchema" xmlns:meta ="http://www.arptek.ru/core/meta" targetNamespace ="http://www.arptek.ru/core/meta/test" > < xs:complexType name ="Test" > < xs:annotation > < xs:appinfo > < meta:java.interface > ru.arptek.meta.SomeInterface </ meta:java.interface > </ xs:appinfo > </ xs:annotation > < xs:sequence > < xs:element name ="id" type ="xs:int" meta:jpa . Id ="true" /> < xs:element name ="string" type ="xs:string" /> < xs:element name ="boolean" type ="xs:boolean" /> < xs:element name ="integer" type ="xs:int" /> < xs:element name ="long" type ="xs:long" /> </ xs:sequence > </ xs:complexType > </ xs:schema > * This source code was highlighted with Source Code Highlighter .<? xml version ="1.0" encoding ="utf-8" ? > < xs:schema xmlns:xs ="http://www.w3.org/2001/XMLSchema" xmlns:meta ="http://www.arptek.ru/core/meta" targetNamespace ="http://www.arptek.ru/core/meta/test" > < xs:complexType name ="Test" > < xs:annotation > < xs:appinfo > < meta:java.interface > ru.arptek.meta.SomeInterface </ meta:java.interface > </ xs:appinfo > </ xs:annotation > < xs:sequence > < xs:element name ="id" type ="xs:int" meta:jpa . Id ="true" /> < xs:element name ="string" type ="xs:string" /> < xs:element name ="boolean" type ="xs:boolean" /> < xs:element name ="integer" type ="xs:int" /> < xs:element name ="long" type ="xs:long" /> </ xs:sequence > </ xs:complexType > </ xs:schema > * This source code was highlighted with Source Code Highlighter .<? xml version ="1.0" encoding ="utf-8" ? > < xs:schema xmlns:xs ="http://www.w3.org/2001/XMLSchema" xmlns:meta ="http://www.arptek.ru/core/meta" targetNamespace ="http://www.arptek.ru/core/meta/test" > < xs:complexType name ="Test" > < xs:annotation > < xs:appinfo > < meta:java.interface > ru.arptek.meta.SomeInterface </ meta:java.interface > </ xs:appinfo > </ xs:annotation > < xs:sequence > < xs:element name ="id" type ="xs:int" meta:jpa . Id ="true" /> < xs:element name ="string" type ="xs:string" /> < xs:element name ="boolean" type ="xs:boolean" /> < xs:element name ="integer" type ="xs:int" /> < xs:element name ="long" type ="xs:long" /> </ xs:sequence > </ xs:complexType > </ xs:schema > * This source code was highlighted with Source Code Highlighter .<? xml version ="1.0" encoding ="utf-8" ? > < xs:schema xmlns:xs ="http://www.w3.org/2001/XMLSchema" xmlns:meta ="http://www.arptek.ru/core/meta" targetNamespace ="http://www.arptek.ru/core/meta/test" > < xs:complexType name ="Test" > < xs:annotation > < xs:appinfo > < meta:java.interface > ru.arptek.meta.SomeInterface </ meta:java.interface > </ xs:appinfo > </ xs:annotation > < xs:sequence > < xs:element name ="id" type ="xs:int" meta:jpa . Id ="true" /> < xs:element name ="string" type ="xs:string" /> < xs:element name ="boolean" type ="xs:boolean" /> < xs:element name ="integer" type ="xs:int" /> < xs:element name ="long" type ="xs:long" /> </ xs:sequence > </ xs:complexType > </ xs:schema > * This source code was highlighted with Source Code Highlighter .<? xml version ="1.0" encoding ="utf-8" ? > < xs:schema xmlns:xs ="http://www.w3.org/2001/XMLSchema" xmlns:meta ="http://www.arptek.ru/core/meta" targetNamespace ="http://www.arptek.ru/core/meta/test" > < xs:complexType name ="Test" > < xs:annotation > < xs:appinfo > < meta:java.interface > ru.arptek.meta.SomeInterface </ meta:java.interface > </ xs:appinfo > </ xs:annotation > < xs:sequence > < xs:element name ="id" type ="xs:int" meta:jpa . Id ="true" /> < xs:element name ="string" type ="xs:string" /> < xs:element name ="boolean" type ="xs:boolean" /> < xs:element name ="integer" type ="xs:int" /> < xs:element name ="long" type ="xs:long" /> </ xs:sequence > </ xs:complexType > </ xs:schema > * This source code was highlighted with Source Code Highlighter .<? xml version ="1.0" encoding ="utf-8" ? > < xs:schema xmlns:xs ="http://www.w3.org/2001/XMLSchema" xmlns:meta ="http://www.arptek.ru/core/meta" targetNamespace ="http://www.arptek.ru/core/meta/test" > < xs:complexType name ="Test" > < xs:annotation > < xs:appinfo > < meta:java.interface > ru.arptek.meta.SomeInterface </ meta:java.interface > </ xs:appinfo > </ xs:annotation > < xs:sequence > < xs:element name ="id" type ="xs:int" meta:jpa . Id ="true" /> < xs:element name ="string" type ="xs:string" /> < xs:element name ="boolean" type ="xs:boolean" /> < xs:element name ="integer" type ="xs:int" /> < xs:element name ="long" type ="xs:long" /> </ xs:sequence > </ xs:complexType > </ xs:schema > * This source code was highlighted with Source Code Highlighter .<? xml version ="1.0" encoding ="utf-8" ? > < xs:schema xmlns:xs ="http://www.w3.org/2001/XMLSchema" xmlns:meta ="http://www.arptek.ru/core/meta" targetNamespace ="http://www.arptek.ru/core/meta/test" > < xs:complexType name ="Test" > < xs:annotation > < xs:appinfo > < meta:java.interface > ru.arptek.meta.SomeInterface </ meta:java.interface > </ xs:appinfo > </ xs:annotation > < xs:sequence > < xs:element name ="id" type ="xs:int" meta:jpa . Id ="true" /> < xs:element name ="string" type ="xs:string" /> < xs:element name ="boolean" type ="xs:boolean" /> < xs:element name ="integer" type ="xs:int" /> < xs:element name ="long" type ="xs:long" /> </ xs:sequence > </ xs:complexType > </ xs:schema > * This source code was highlighted with Source Code Highlighter .<? xml version ="1.0" encoding ="utf-8" ? > < xs:schema xmlns:xs ="http://www.w3.org/2001/XMLSchema" xmlns:meta ="http://www.arptek.ru/core/meta" targetNamespace ="http://www.arptek.ru/core/meta/test" > < xs:complexType name ="Test" > < xs:annotation > < xs:appinfo > < meta:java.interface > ru.arptek.meta.SomeInterface </ meta:java.interface > </ xs:appinfo > </ xs:annotation > < xs:sequence > < xs:element name ="id" type ="xs:int" meta:jpa . Id ="true" /> < xs:element name ="string" type ="xs:string" /> < xs:element name ="boolean" type ="xs:boolean" /> < xs:element name ="integer" type ="xs:int" /> < xs:element name ="long" type ="xs:long" /> </ xs:sequence > </ xs:complexType > </ xs:schema > * This source code was highlighted with Source Code Highlighter .<? xml version ="1.0" encoding ="utf-8" ? > < xs:schema xmlns:xs ="http://www.w3.org/2001/XMLSchema" xmlns:meta ="http://www.arptek.ru/core/meta" targetNamespace ="http://www.arptek.ru/core/meta/test" > < xs:complexType name ="Test" > < xs:annotation > < xs:appinfo > < meta:java.interface > ru.arptek.meta.SomeInterface </ meta:java.interface > </ xs:appinfo > </ xs:annotation > < xs:sequence > < xs:element name ="id" type ="xs:int" meta:jpa . Id ="true" /> < xs:element name ="string" type ="xs:string" /> < xs:element name ="boolean" type ="xs:boolean" /> < xs:element name ="integer" type ="xs:int" /> < xs:element name ="long" type ="xs:long" /> </ xs:sequence > </ xs:complexType > </ xs:schema > * This source code was highlighted with Source Code Highlighter .<? xml version ="1.0" encoding ="utf-8" ? > < xs:schema xmlns:xs ="http://www.w3.org/2001/XMLSchema" xmlns:meta ="http://www.arptek.ru/core/meta" targetNamespace ="http://www.arptek.ru/core/meta/test" > < xs:complexType name ="Test" > < xs:annotation > < xs:appinfo > < meta:java.interface > ru.arptek.meta.SomeInterface </ meta:java.interface > </ xs:appinfo > </ xs:annotation > < xs:sequence > < xs:element name ="id" type ="xs:int" meta:jpa . Id ="true" /> < xs:element name ="string" type ="xs:string" /> < xs:element name ="boolean" type ="xs:boolean" /> < xs:element name ="integer" type ="xs:int" /> < xs:element name ="long" type ="xs:long" /> </ xs:sequence > </ xs:complexType > </ xs:schema > * This source code was highlighted with Source Code Highlighter .<? xml version ="1.0" encoding ="utf-8" ? > < xs:schema xmlns:xs ="http://www.w3.org/2001/XMLSchema" xmlns:meta ="http://www.arptek.ru/core/meta" targetNamespace ="http://www.arptek.ru/core/meta/test" > < xs:complexType name ="Test" > < xs:annotation > < xs:appinfo > < meta:java.interface > ru.arptek.meta.SomeInterface </ meta:java.interface > </ xs:appinfo > </ xs:annotation > < xs:sequence > < xs:element name ="id" type ="xs:int" meta:jpa . Id ="true" /> < xs:element name ="string" type ="xs:string" /> < xs:element name ="boolean" type ="xs:boolean" /> < xs:element name ="integer" type ="xs:int" /> < xs:element name ="long" type ="xs:long" /> </ xs:sequence > </ xs:complexType > </ xs:schema > * This source code was highlighted with Source Code Highlighter .<? xml version ="1.0" encoding ="utf-8" ? > < xs:schema xmlns:xs ="http://www.w3.org/2001/XMLSchema" xmlns:meta ="http://www.arptek.ru/core/meta" targetNamespace ="http://www.arptek.ru/core/meta/test" > < xs:complexType name ="Test" > < xs:annotation > < xs:appinfo > < meta:java.interface > ru.arptek.meta.SomeInterface </ meta:java.interface > </ xs:appinfo > </ xs:annotation > < xs:sequence > < xs:element name ="id" type ="xs:int" meta:jpa . Id ="true" /> < xs:element name ="string" type ="xs:string" /> < xs:element name ="boolean" type ="xs:boolean" /> < xs:element name ="integer" type ="xs:int" /> < xs:element name ="long" type ="xs:long" /> </ xs:sequence > </ xs:complexType > </ xs:schema > * This source code was highlighted with Source Code Highlighter .<? xml version ="1.0" encoding ="utf-8" ? > < xs:schema xmlns:xs ="http://www.w3.org/2001/XMLSchema" xmlns:meta ="http://www.arptek.ru/core/meta" targetNamespace ="http://www.arptek.ru/core/meta/test" > < xs:complexType name ="Test" > < xs:annotation > < xs:appinfo > < meta:java.interface > ru.arptek.meta.SomeInterface </ meta:java.interface > </ xs:appinfo > </ xs:annotation > < xs:sequence > < xs:element name ="id" type ="xs:int" meta:jpa . Id ="true" /> < xs:element name ="string" type ="xs:string" /> < xs:element name ="boolean" type ="xs:boolean" /> < xs:element name ="integer" type ="xs:int" /> < xs:element name ="long" type ="xs:long" /> </ xs:sequence > </ xs:complexType > </ xs:schema > * This source code was highlighted with Source Code Highlighter .<? xml version ="1.0" encoding ="utf-8" ? > < xs:schema xmlns:xs ="http://www.w3.org/2001/XMLSchema" xmlns:meta ="http://www.arptek.ru/core/meta" targetNamespace ="http://www.arptek.ru/core/meta/test" > < xs:complexType name ="Test" > < xs:annotation > < xs:appinfo > < meta:java.interface > ru.arptek.meta.SomeInterface </ meta:java.interface > </ xs:appinfo > </ xs:annotation > < xs:sequence > < xs:element name ="id" type ="xs:int" meta:jpa . Id ="true" /> < xs:element name ="string" type ="xs:string" /> < xs:element name ="boolean" type ="xs:boolean" /> < xs:element name ="integer" type ="xs:int" /> < xs:element name ="long" type ="xs:long" /> </ xs:sequence > </ xs:complexType > </ xs:schema > * This source code was highlighted with Source Code Highlighter .<? xml version ="1.0" encoding ="utf-8" ? > < xs:schema xmlns:xs ="http://www.w3.org/2001/XMLSchema" xmlns:meta ="http://www.arptek.ru/core/meta" targetNamespace ="http://www.arptek.ru/core/meta/test" > < xs:complexType name ="Test" > < xs:annotation > < xs:appinfo > < meta:java.interface > ru.arptek.meta.SomeInterface </ meta:java.interface > </ xs:appinfo > </ xs:annotation > < xs:sequence > < xs:element name ="id" type ="xs:int" meta:jpa . Id ="true" /> < xs:element name ="string" type ="xs:string" /> < xs:element name ="boolean" type ="xs:boolean" /> < xs:element name ="integer" type ="xs:int" /> < xs:element name ="long" type ="xs:long" /> </ xs:sequence > </ xs:complexType > </ xs:schema > * This source code was highlighted with Source Code Highlighter .
this.aを返します。
0 aload_0 1 getfield classname.a 4 lreturn
ce.declare_field(Constants.ACC_PROTECTED、fieldName、type、null);
codeEmitter.load_this(); codeEmitter.getfield(constantName); codeEmitter.return_value();
codeEmitter.load_this(); codeEmitter.getfield(constantName);
codeEmitter.return_value();
codeEmitter.load_arg(0);
codeEmitter.load_this(); codeEmitter.load_arg(0); codeEmitter.putfield(fieldName); codeEmitter.return_value();
codeEmitter.invoke_virtual(parentClass、新しい署名( getterName、fieldValueType、TYPES_EMPTY));
ローカルローカル= e.make_local(TYPE_LINKED_HASH_MAP); e.new_instance(TYPE_LINKED_HASH_MAP); e.dup(); e.push(fieldClasses.size()); e.push(10); e.push(1f); e.invoke_constructor(TYPE_LINKED_HASH_MAP、SIG_MAP_INIT_INT_FLOAT); e.store_local(ローカル);
ClassWriter cw = 新しい DebuggingClassWriter(ClassWriter.COMPUTE_FRAMES);ClassEmitter ce = 新しい ClassEmitter(cw);Type [] interfaces = getInterfacesTypes(complexType);ce.begin_class(Constants.V1_6、Constants.ACC_PUBLIC、className、Type.getType(complexType.getSuperClass())、インターフェース、Constants.SOURCE_FILE);if (complexType.isJpaEntity()){ce.visitAnnotation(ANNOTATION_DESCRIPTOR_ENTITY、 true ).visitEnd();}if (StringUtils.isNotEmpty(complexType.getJpaTableName())){final AnnotationVisitor av = ce.visitAnnotation(ANNOTATION_DESCRIPTOR_TABLE、 true );av.visit( "name" 、complexType.getJpaTableName());av.visitEnd();}{if (options.generateFieldAccessors){final String fieldsMapFieldName = "$ fields $" ;ce.declare_field(Constants.ACC_PRIVATE| Constants.ACC_FINAL、fieldsMapFieldName、TYPE_MAP、 null );generateConstructorWithFieldsInit(mainClass、ce、fieldClasses、fieldsMapFieldName);generateGetFieldsMethod(ce、fieldsMapFieldName);generateGetFieldMethod(ce、fieldsMapFieldName);} else {EmitUtils.null_constructor(ce);}for (属性属性:complexType.getAttributes()){processAttribute(ce、属性);}}ce.end_class();{バイト [] bs = cw.toByteArray();log.info( "生成されたクラス '" + className + "' of" + bs.length+ "bytes" );result.put(className、bs);}*このソースコードは、 ソースコードハイライターで強調表示されました。
if (attribute.getType()instanceof EmptyType)帰るString fieldName = attribute.getFieldName();文字列getterName = attribute.getGetterName();文字列setterName = attribute.getSetterName();final String javaMethodNamePart = WordUtils.capitalize(attribute.getAttrName()、 new char [] { '_' })。replace( "_" 、 "" );final Type type = getTypeFromXmlSchemaTypeName(attribute.getType());if (fieldName == null )fieldName = "m $" + StringUtils.uncapitalize(javaMethodNamePart);if (getterName == null )getterName = "get" + javaMethodNamePart;if (setterName == null )setterName = "set" + javaMethodNamePart;最後のブール値jpaId = attribute.isJpaId();final String strDefaultValue;if (!jpaId){strDefaultValue = attribute.getStrDefaultValue();} else {strDefaultValue = null ;}if (strDefaultValue == null ){ce.declare_field(Constants.ACC_PRIVATE、fieldName、type、 null );{//ゲッターを作成しますCodeEmitter codeEmitter = ce.begin_method(Constants.ACC_PUBLIC、新しい署名(getterName、type、TYPES_EMPTY)、TYPES_EMPTY);continueAttributeJpaColumnName(属性、codeEmitter);continueAttributeJpaLob(属性、codeEmitter);continueAttributeJpaId(属性、codeEmitter);codeEmitter.load_this();codeEmitter.getfield(fieldName);codeEmitter.return_value();codeEmitter.end_method();}{// nullセーフセッターを作成しますCodeEmitter codeEmitter = ce.begin_method(Constants.ACC_PUBLIC、新しい署名(setterName、Type.VOID_TYPE、新しいタイプ[] {type})、TYPES_EMPTY);codeEmitter.load_this();codeEmitter.load_arg(0);codeEmitter.putfield(fieldName);codeEmitter.return_value();codeEmitter.end_method();}} else {final Object defaultValue = toValue(type、strDefaultValue);final String constantName = "DEFAULT_" + fieldName;ce.declare_field(Constants.ACC_PROTECTED | Constants.ACC_FINAL| Constants.ACC_STATIC、constantName、type、 null );{CodeEmitter staticHook = ce.getStaticHook();EmitUtils.push_object(staticHook、defaultValue);staticHook.putfield(constantName);}ce.declare_field(Constants.ACC_PROTECTED、fieldName、type、 null );{//ゲッターを作成します最終署名署名= 新しい署名(getterName、type、TYPES_EMPTY);最終的なCodeEmitter codeEmitter = ce.begin_method(Constants.ACC_PUBLIC、署名、TYPES_EMPTY);continueAttributeJpaColumnName(属性、codeEmitter);continueAttributeJpaLob(属性、codeEmitter);codeEmitter.load_this();codeEmitter.getfield(fieldName);ラベルifNull = codeEmitter.make_label();codeEmitter.ifnull(ifNull);{codeEmitter.load_this();codeEmitter.getfield(fieldName);codeEmitter.return_value();}codeEmitter.mark(ifNull);{codeEmitter.load_this();codeEmitter.getfield(constantName);codeEmitter.return_value();}codeEmitter.end_method();}{//セッターを作成します最終署名署名= 新しい署名(setterName、Type.VOID_TYPE、 新しいタイプ[] {type});最終的なCodeEmitter codeEmitter = ce.begin_method(Constants.ACC_PUBLIC、署名、TYPES_EMPTY);codeEmitter.load_this();codeEmitter.load_arg(0);codeEmitter.putfield(fieldName);codeEmitter.return_value();codeEmitter.end_method();}}*このソースコードは、 ソースコードハイライターで強調表示されました。
final String holderFieldName = "$ parent $" ;ce.declare_field(Constants.ACC_PRIVATE | Constants.ACC_FINAL、HolderFieldName、parentClass、 null );{CodeEmitter e = ce.begin_method(Constants.ACC_PUBLIC、新しい署名( "<init>" 、Type.VOID_TYPE、新しいタイプ[] {parentClass})、 null );e.load_this();e.super_invoke_constructor();e.load_this();e.load_arg(0);e.putfield(holderFieldName);e.return_value();e.end_method();}*このソースコードは、 ソースコードハイライターで強調表示されました。
{//ゲッターを作成しますCodeEmitter codeEmitter = ce.begin_method(Constants.ACC_PUBLIC、新しい署名( "getValue" 、fieldValueType、TYPES_EMPTY)、TYPES_EMPTY);codeEmitter.load_this();codeEmitter.getfield(holderFieldName);codeEmitter.invoke_virtual(parentClass、 新しい署名(getterName、fieldValueType、TYPES_EMPTY));codeEmitter.return_value();codeEmitter.end_method();}{// nullセーフセッターを作成しますCodeEmitter codeEmitter = ce.begin_method(Constants.ACC_PUBLIC、新しい署名( "setValue" 、Type.VOID_TYPE、新しいタイプ[] {fieldValueType})、TYPES_EMPTY);codeEmitter.load_this();codeEmitter.getfield(holderFieldName);codeEmitter.load_arg(0);codeEmitter.invoke_virtual(parentClass、 新しい署名(setterName、Type.VOID_TYPE、新しいタイプ[] {fieldValueType}));codeEmitter.return_value();codeEmitter.end_method();}*このソースコードは、 ソースコードハイライターで強調表示されました。
ClassWriter cw = 新しい DebuggingClassWriter(ClassWriter.COMPUTE_FRAMES);ClassEmitter ce = 新しい ClassEmitter(cw);文字列fieldClassName = processAttributeField(className、mainClass、ce、属性);fieldClasses.put(属性、ce.getClassType());*このソースコードは、 ソースコードハイライターで強調表示されました。
public void generateConstructorWithFieldsInit(最終タイプmainClass、ClassEmitter ce、Map <Attribute、Type> fieldClasses、final String fieldsMapFieldName){CodeEmitter e = ce.begin_method(Constants.ACC_PUBLIC、TypeUtils.parseConstructor( "" )、 null );e.load_this();e.super_invoke_constructor();ローカルローカル= e.make_local(TYPE_LINKED_HASH_MAP);e.new_instance(TYPE_LINKED_HASH_MAP);e.dup();e.push(fieldClasses.size());e.push(1f);e.invoke_constructor(TYPE_LINKED_HASH_MAP、SIG_MAP_INIT_INT_FLOAT);e.store_local(ローカル);for (エントリ<属性、タイプ> fieldTypes:fieldClasses.entrySet()){e.load_local(ローカル);e.push(fieldTypes.getKey()。getAttrName());// = new <...> Field(this);e.new_instance(fieldTypes.getValue());e.dup();e.load_this();e.invoke_constructor(fieldTypes.getValue()、 新しい署名( "<init>" 、Type.VOID_TYPE、 新しいタイプ[] {mainClass}));// $ fields $ .put(fieldName、field);e.invoke_virtual(TYPE_LINKED_HASH_MAP、SIG_MAP_PUT);}e.load_this();e.load_local(ローカル);e.invoke_static(TYPE_COLLECTIONS、SIG_COLLECTIONS_UNMODIFIABLEMAP);e.putfield(fieldsMapFieldName);e.return_value();e.end_method();}*このソースコードは、 ソースコードハイライターで強調表示されました。
public void generateGetFieldMethod(ClassEmitter ce、final String fieldsMapFieldName){CodeEmitter e = ce.begin_method(Constants.ACC_PUBLIC、SIG_FIELDSHOLDER_GETFIELD、 null );e.visitAnnotation(ANNOTATION_DESCRIPTOR_TRANSIENT、 true ).visitEnd();e.load_this();e.getfield(fieldsMapFieldName);e.load_arg(0);e.checkcast(TYPE_OBJECT);e.invoke_interface(TYPE_MAP、SIG_MAP_GET);e.checkcast(TYPE_FIELD);e.return_value();e.end_method();}public void generateGetFieldsMethod(ClassEmitter ce、final String fieldsMapFieldName){CodeEmitter e = ce.begin_method(Constants.ACC_PUBLIC、SIG_FIELDSHOLDER_GETFIELDS、 null );e.visitAnnotation(ANNOTATION_DESCRIPTOR_TRANSIENT、 true ).visitEnd();e.load_this();e.getfield(fieldsMapFieldName);e.return_value();e.end_method();}*このソースコードは、 ソースコードハイライターで強調表示されました。
保護された Map <String、Class <?>> loadClasses(最終マップ<String、 バイト []>生成){最終スレッドcurrentThread = Thread.currentThread();final ClassLoader classLoader = currentThread.getContextClassLoader();final Map <String、Class <?>> classes = new ClassLoader(classLoader){保護された Map <String、Class <?>> loadClasses(){Map <String、Class <?>> result = new LinkedHashMap <String、Class <?>>(generated.size());for (エントリ<String、 バイト []>エントリ:generated.entrySet()){final String className = entry.getKey();最終バイト [] byteCode = entry.getValue();log.info( "Defining class" + className + "..." );final Class <?> cls = defineClass(className、byteCode、0、byteCode.length);result.put(cls.getName()、cls);}結果を返す ;}} .loadClasses();クラスを返す ;}*このソースコードは、 ソースコードハイライターで強調表示されました。
Source: https://habr.com/ru/post/J91239/More articles:HTML検証-神話HabraLogoを描画します壊れたプロセッサ脚をはんだ付けする方法なぜMagentoなのか?ウィキペディアでの10億の編集SleepPyパターン(N900用)-いつも考えていたように、夜はよく眠れますか?データモデルをJavaScriptビューにバインドするトリミノコードウォームを使用したサイトアクティビティの視覚化シンクライアント:購入方法All Articles