Example #1
0
func newField(class *Class, fieldInfo *cf.MemberInfo) *Field {
	field := &Field{}
	field.class = class
	field.accessFlags = fieldInfo.AccessFlags()
	field.name = fieldInfo.Name()
	field.descriptor = fieldInfo.Descriptor()
	field.signature = fieldInfo.Signature()
	field.IsLongOrDouble = (field.descriptor == "J" || field.descriptor == "D")
	if kValAttr := fieldInfo.ConstantValueAttribute(); kValAttr != nil {
		field.constValueIndex = kValAttr.ConstantValueIndex()
	}
	return field
}
Example #2
0
func newMethod(class *Class, methodInfo *cf.MemberInfo) *Method {
	method := &Method{}
	method.class = class
	method.accessFlags = methodInfo.AccessFlags()
	method.name = methodInfo.Name()
	method.descriptor = methodInfo.Descriptor()
	method.md = parseMethodDescriptor(method.descriptor)
	method.calcArgSlotCount()
	method.copyAttributes(methodInfo)
	return method
}
Example #3
0
func (self *Method) copyAttributes(methodInfo *cf.MemberInfo) {
	if codeAttr := methodInfo.CodeAttribute(); codeAttr != nil {
		self.exceptions = methodInfo.ExceptionsAttribute()
		self.signature = methodInfo.Signature()
		self.code = codeAttr.Code()
		self.maxStack = codeAttr.MaxStack()
		self.maxLocals = codeAttr.MaxLocals()
		self.lineNumberTable = codeAttr.LineNumberTableAttribute()
		if len(codeAttr.ExceptionTable()) > 0 {
			rtCp := self.class.constantPool
			self.copyExceptionTable(codeAttr.ExceptionTable(), rtCp)
		}
	}
	self.annotationData = methodInfo.RuntimeVisibleAnnotationsAttributeData()
	self.parameterAnnotationData = methodInfo.RuntimeVisibleParameterAnnotationsAttributeData()
	self.annotationDefaultData = methodInfo.AnnotationDefaultAttributeData()
}