001: /**************************************************************************************
002: * Copyright (c) Jonas BonŽr, Alexandre Vasseur. All rights reserved. *
003: * http://aspectwerkz.codehaus.org *
004: * ---------------------------------------------------------------------------------- *
005: * The software in this package is published under the terms of the LGPL license *
006: * a copy of which has been included with this distribution in the license.txt file. *
007: **************************************************************************************/package org.codehaus.aspectwerkz.reflect.impl.asm;
008:
009: import org.codehaus.aspectwerkz.annotation.instrumentation.asm.CustomAttribute;
010: import org.codehaus.aspectwerkz.annotation.instrumentation.asm.CustomAttributeHelper;
011: import org.codehaus.aspectwerkz.annotation.AnnotationInfo;
012: import org.codehaus.aspectwerkz.reflect.ClassInfo;
013: import org.codehaus.aspectwerkz.reflect.MemberInfo;
014: import org.codehaus.aspectwerkz.transform.inlining.AsmHelper;
015: import org.objectweb.asm.Attribute;
016: import org.objectweb.asm.attrs.RuntimeInvisibleAnnotations;
017: import org.objectweb.asm.attrs.Annotation;
018: import org.objectweb.asm.attrs.RuntimeVisibleAnnotations;
019:
020: import java.lang.ref.WeakReference;
021: import java.util.*;
022:
023: /**
024: * ASM implementation of the MemberInfo interface.
025: *
026: * @author <a href="mailto:jboner@codehaus.org">Jonas BonŽr </a>
027: */
028: public abstract class AsmMemberInfo implements MemberInfo {
029:
030: /**
031: * The member info.
032: */
033: protected final MemberStruct m_member;
034:
035: /**
036: * The class loader wrapped in a weak ref.
037: */
038: protected final WeakReference m_loaderRef;
039:
040: /**
041: * The declaring type name.
042: */
043: protected final String m_declaringTypeName;
044:
045: /**
046: * The declaring type.
047: */
048: protected ClassInfo m_declaringType;
049:
050: /**
051: * The annotations.
052: */
053: protected List m_annotations = null;
054:
055: /**
056: * The class info repository.
057: */
058: protected final AsmClassInfoRepository m_classInfoRepository;
059:
060: /**
061: * Creates a new member meta data instance.
062: *
063: * @param member
064: * @param declaringType
065: * @param loader
066: */
067: AsmMemberInfo(final MemberStruct member,
068: final String declaringType, final ClassLoader loader) {
069: if (member == null) {
070: throw new IllegalArgumentException("member can not be null");
071: }
072: if (declaringType == null) {
073: throw new IllegalArgumentException(
074: "declaring type can not be null");
075: }
076: m_member = member;
077: m_loaderRef = new WeakReference(loader);
078: m_declaringTypeName = declaringType.replace('/', '.');
079: m_classInfoRepository = AsmClassInfoRepository
080: .getRepository(loader);
081: }
082:
083: /**
084: * Returns the name.
085: *
086: * @return the name
087: */
088: public String getName() {
089: return m_member.name;
090: }
091:
092: /**
093: * Returns the modifiers.
094: *
095: * @return the modifiers
096: */
097: public int getModifiers() {
098: return m_member.modifiers;
099: }
100:
101: /**
102: * Returns the declaring type.
103: *
104: * @return the declaring type
105: */
106: public ClassInfo getDeclaringType() {
107: if (m_declaringType == null) {
108: m_declaringType = m_classInfoRepository
109: .getClassInfo(m_declaringTypeName);
110: }
111: return m_declaringType;
112: }
113: }
|