From 71a7cba384b8ae7f4578fb9ab1f725d5ce616074 Mon Sep 17 00:00:00 2001 From: rfeng Date: Mon, 26 Oct 2009 23:44:59 +0000 Subject: Merge all changes from 1.5.2 branch into trunk git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@830026 13f79535-47bb-0310-9956-ffa450edef68 --- .../implementation/java/impl/JavaElementImpl.java | 27 +++++++++++----------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'branches/sca-java-1.x/modules/implementation-java/src/main') diff --git a/branches/sca-java-1.x/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaElementImpl.java b/branches/sca-java-1.x/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaElementImpl.java index 2365298f71..e5fa399bf6 100644 --- a/branches/sca-java-1.x/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaElementImpl.java +++ b/branches/sca-java-1.x/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaElementImpl.java @@ -21,6 +21,7 @@ package org.apache.tuscany.sca.implementation.java.impl; import java.lang.annotation.Annotation; import java.lang.annotation.ElementType; +import java.lang.ref.WeakReference; import java.lang.reflect.AnnotatedElement; import java.lang.reflect.Constructor; import java.lang.reflect.Field; @@ -36,8 +37,8 @@ import java.lang.reflect.Type; public class JavaElementImpl { private AnnotatedElement anchor; private ElementType elementType; - private Class type; - private Type genericType; + private WeakReference> type; + private WeakReference genericType; private int index = -1; private String name; private Class classifer; @@ -51,24 +52,24 @@ public class JavaElementImpl { public JavaElementImpl(Class cls) { this.anchor = cls; this.elementType = ElementType.TYPE; - this.type = cls; - this.genericType = cls; + this.type = new WeakReference>(cls); + this.genericType = new WeakReference(cls); this.name = cls.getName(); } public JavaElementImpl(Field field) { this.anchor = field; this.elementType = ElementType.FIELD; - this.type = field.getType(); - this.genericType = field.getGenericType(); + this.type = new WeakReference>(field.getType()); + this.genericType = new WeakReference(field.getGenericType()); this.name = field.getName(); } public JavaElementImpl(Constructor constructor, int index) { this.anchor = constructor; this.elementType = ElementType.PARAMETER; - this.type = constructor.getParameterTypes()[index]; - this.genericType = constructor.getGenericParameterTypes()[index]; + this.type = new WeakReference>(constructor.getParameterTypes()[index]); + this.genericType = new WeakReference(constructor.getGenericParameterTypes()[index]); this.index = index; this.name = ""; } @@ -76,8 +77,8 @@ public class JavaElementImpl { public JavaElementImpl(Method method, int index) { this.anchor = method; this.elementType = ElementType.PARAMETER; - this.type = method.getParameterTypes()[index]; - this.genericType = method.getGenericParameterTypes()[index]; + this.type = new WeakReference>(method.getParameterTypes()[index]); + this.genericType = new WeakReference(method.getGenericParameterTypes()[index]); this.index = index; this.name = ""; } @@ -92,7 +93,7 @@ public class JavaElementImpl { */ public JavaElementImpl(String name, Class type, Class classifer) { super(); - this.type = type; + this.type = new WeakReference>(type); this.name = name; this.classifer = classifer; } @@ -115,7 +116,7 @@ public class JavaElementImpl { * @return the genericType */ public Type getGenericType() { - return genericType; + return genericType.get(); } /** @@ -129,7 +130,7 @@ public class JavaElementImpl { * @return the type */ public Class getType() { - return type; + return type.get(); } public Annotation[] getAnnotations() { -- cgit v1.2.3