Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 20502 Details for
Bug 92933
Add support for CLDC
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Patch against CVS HEAD 29/4/2005 to make the AspectJ runtime CLDC compatible.
aspectjrtcldc.patch (text/plain), 63.39 KB, created by
Chris January
on 2005-04-29 05:36:49 EDT
(
hide
)
Description:
Patch against CVS HEAD 29/4/2005 to make the AspectJ runtime CLDC compatible.
Filename:
MIME Type:
Creator:
Chris January
Created:
2005-04-29 05:36:49 EDT
Size:
63.39 KB
patch
obsolete
>Index: org/aspectj/lang/Aspects.java >=================================================================== >RCS file: org/aspectj/lang/Aspects.java >diff -N org/aspectj/lang/Aspects.java >--- org/aspectj/lang/Aspects.java 22 Apr 2005 10:12:14 -0000 1.5 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,93 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2005 Contributors. >- * All rights reserved. >- * This program and the accompanying materials are made available >- * under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution and is available at >- * http://eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * initial implementation Alexandre Vasseur >- *******************************************************************************/ >-package org.aspectj.lang; >- >-import java.lang.reflect.Method; >-import java.lang.reflect.Modifier; >- >-/** >- * Handles generic aspectOf method when those are not available in the aspects but added later on >- * thru load time weaving. >- * <p/> >- * Aspects.aspectOf(..) is doing reflective calls to the aspect aspectOf, so for better performance >- * consider using preparation of the aspects. >- * >- * @author <a href="mailto:alex AT gnilux DOT com">Alexandre Vasseur</a> >- */ >-public class Aspects { >- >- private final static Class[] EMPTY_CLASS_ARRAY = new Class[0]; >- private final static Class[] PEROBJECT_CLASS_ARRAY = new Class[]{Object.class}; >- private final static Object[] EMPTY_OBJECT_ARRAY = new Object[0]; >- private final static String ASPECTOF = "aspectOf"; >- >- /** >- * Returns the singleton aspect >- * >- * @param aspectClass >- * @return >- * @throws NoAspectBoundException if no such aspect >- */ >- public static Object aspectOf(Class aspectClass) throws NoAspectBoundException { >- try { >- return getSingletonAspectOf(aspectClass).invoke(null, EMPTY_OBJECT_ARRAY); >- } catch (Exception e) { >- throw new NoAspectBoundException(aspectClass.getName(), e); >- } >- } >- >- /** >- * Returns the perthis / pertarget aspect >- * @param aspectClass >- * @param perObject >- * @return >- * @throws NoAspectBoundException if no such aspect, or no aspect bound >- */ >- public static Object aspectOf(Class aspectClass, Object perObject) throws NoAspectBoundException { >- try { >- return getPerObjectAspectOf(aspectClass).invoke(null, new Object[]{perObject}); >- } catch (Exception e) { >- throw new NoAspectBoundException(aspectClass.getName(), e); >- } >- } >- >- public static Object aspectOf(Class aspectClass, Thread perThread) throws NoAspectBoundException { >- //TODO - how to know it s a real per Thread ? >- // if it is actually a singleton one, we will have it as well... >- try { >- return getSingletonAspectOf(aspectClass).invoke(null, EMPTY_OBJECT_ARRAY); >- } catch (Exception e) { >- throw new NoAspectBoundException(aspectClass.getName(), e); >- } >- } >- >- private static Method getSingletonAspectOf(Class aspectClass) throws NoSuchMethodException { >- Method method = aspectClass.getDeclaredMethod(ASPECTOF, EMPTY_CLASS_ARRAY); >- return checkAspectOf(method, aspectClass); >- } >- >- private static Method getPerObjectAspectOf(Class aspectClass) throws NoSuchMethodException { >- Method method = aspectClass.getDeclaredMethod(ASPECTOF, PEROBJECT_CLASS_ARRAY); >- return checkAspectOf(method, aspectClass); >- } >- >- private static Method checkAspectOf(Method method, Class aspectClass) >- throws NoSuchMethodException { >- method.setAccessible(true); >- if (!method.isAccessible() >- || !Modifier.isPublic(method.getModifiers()) >- || !Modifier.isStatic(method.getModifiers())) { >- throw new NoSuchMethodException(aspectClass.getName() + ".aspectOf(..) is not accessible public static"); >- } >- return method; >- } >-} >Index: org/aspectj/lang/SoftException.java >=================================================================== >RCS file: /home/technology/org.aspectj/modules/runtime/src/org/aspectj/lang/SoftException.java,v >retrieving revision 1.3 >diff -u -r1.3 SoftException.java >--- org/aspectj/lang/SoftException.java 15 Jan 2004 05:21:33 -0000 1.3 >+++ org/aspectj/lang/SoftException.java 29 Apr 2005 08:44:45 -0000 >@@ -15,9 +15,6 @@ > > package org.aspectj.lang; > >-import java.io.PrintStream; >-import java.io.PrintWriter; >- > /** > * Wrapper for checked exceptions matched by a 'declare soft'. > * You can soften checked exceptions at join points by using >@@ -57,24 +54,11 @@ > public Throwable getCause() { return inner; } > > public void printStackTrace() { >- printStackTrace(System.err); >- } >- >- public void printStackTrace(PrintStream stream) { >- super.printStackTrace(stream); >- final Throwable _inner = this.inner; >- if (!HAVE_JAVA_14 && (null != _inner)) { >- stream.print("Caused by: "); >- _inner.printStackTrace(stream); >- } >- } >- >- public void printStackTrace(PrintWriter stream) { >- super.printStackTrace(stream); >+ super.printStackTrace (); > final Throwable _inner = this.inner; > if (!HAVE_JAVA_14 && (null != _inner)) { >- stream.print("Caused by: "); >- _inner.printStackTrace(stream); >- } >- } >+ System.err.println("Caused by: "); >+ _inner.printStackTrace(); >+ } >+ } > } >Index: org/aspectj/lang/reflect/AdviceSignature.java >=================================================================== >RCS file: /home/technology/org.aspectj/modules/runtime/src/org/aspectj/lang/reflect/AdviceSignature.java,v >retrieving revision 1.2 >diff -u -r1.2 AdviceSignature.java >--- org/aspectj/lang/reflect/AdviceSignature.java 10 Mar 2005 10:55:05 -0000 1.2 >+++ org/aspectj/lang/reflect/AdviceSignature.java 29 Apr 2005 08:44:45 -0000 >@@ -13,11 +13,10 @@ > > > package org.aspectj.lang.reflect; >-import java.lang.reflect.Method; >+import org.aspectj.runtime.reflect.ClassOrPrimitive; > > public interface AdviceSignature extends CodeSignature { >- Class getReturnType(); /* name is consistent with reflection API */ >- /* before and after always return Void.TYPE */ >- /* (some around also return Void.Type) */ >- Method getAdvice(); >+ ClassOrPrimitive getReturnType(); /* name is consistent with reflection API */ >+ /* before and after always return Void.TYPE */ >+ /* (some around also return Void.Type) */ > } >Index: org/aspectj/lang/reflect/CatchClauseSignature.java >=================================================================== >RCS file: /home/technology/org.aspectj/modules/runtime/src/org/aspectj/lang/reflect/CatchClauseSignature.java,v >retrieving revision 1.1 >diff -u -r1.1 CatchClauseSignature.java >--- org/aspectj/lang/reflect/CatchClauseSignature.java 16 Dec 2002 17:14:48 -0000 1.1 >+++ org/aspectj/lang/reflect/CatchClauseSignature.java 29 Apr 2005 08:44:45 -0000 >@@ -15,8 +15,9 @@ > package org.aspectj.lang.reflect; > > import org.aspectj.lang.Signature; >+import org.aspectj.runtime.reflect.ClassOrPrimitive; > > public interface CatchClauseSignature extends Signature { >- Class getParameterType(); >+ ClassOrPrimitive getParameterType(); > String getParameterName(); > } >Index: org/aspectj/lang/reflect/CodeSignature.java >=================================================================== >RCS file: /home/technology/org.aspectj/modules/runtime/src/org/aspectj/lang/reflect/CodeSignature.java,v >retrieving revision 1.1 >diff -u -r1.1 CodeSignature.java >--- org/aspectj/lang/reflect/CodeSignature.java 16 Dec 2002 17:14:48 -0000 1.1 >+++ org/aspectj/lang/reflect/CodeSignature.java 29 Apr 2005 08:44:45 -0000 >@@ -14,8 +14,10 @@ > > package org.aspectj.lang.reflect; > >+import org.aspectj.runtime.reflect.ClassOrPrimitive; >+ > public interface CodeSignature extends MemberSignature { >- Class[] getParameterTypes(); >+ ClassOrPrimitive[] getParameterTypes(); > String[] getParameterNames(); > Class[] getExceptionTypes(); > } >Index: org/aspectj/lang/reflect/ConstructorSignature.java >=================================================================== >RCS file: /home/technology/org.aspectj/modules/runtime/src/org/aspectj/lang/reflect/ConstructorSignature.java,v >retrieving revision 1.2 >diff -u -r1.2 ConstructorSignature.java >--- org/aspectj/lang/reflect/ConstructorSignature.java 10 Mar 2005 10:55:05 -0000 1.2 >+++ org/aspectj/lang/reflect/ConstructorSignature.java 29 Apr 2005 08:44:45 -0000 >@@ -13,8 +13,6 @@ > > > package org.aspectj.lang.reflect; >-import java.lang.reflect.Constructor; > > public interface ConstructorSignature extends CodeSignature { >- Constructor getConstructor(); > } >Index: org/aspectj/lang/reflect/FieldSignature.java >=================================================================== >RCS file: /home/technology/org.aspectj/modules/runtime/src/org/aspectj/lang/reflect/FieldSignature.java,v >retrieving revision 1.3 >diff -u -r1.3 FieldSignature.java >--- org/aspectj/lang/reflect/FieldSignature.java 10 Mar 2005 10:55:05 -0000 1.3 >+++ org/aspectj/lang/reflect/FieldSignature.java 29 Apr 2005 08:44:45 -0000 >@@ -13,9 +13,8 @@ > > > package org.aspectj.lang.reflect; >-import java.lang.reflect.Field; >+import org.aspectj.runtime.reflect.ClassOrPrimitive; > > public interface FieldSignature extends MemberSignature { >- public Class getFieldType(); >- public Field getField(); >+ public ClassOrPrimitive getFieldType(); > } >Index: org/aspectj/lang/reflect/InitializerSignature.java >=================================================================== >RCS file: /home/technology/org.aspectj/modules/runtime/src/org/aspectj/lang/reflect/InitializerSignature.java,v >retrieving revision 1.2 >diff -u -r1.2 InitializerSignature.java >--- org/aspectj/lang/reflect/InitializerSignature.java 10 Mar 2005 10:55:05 -0000 1.2 >+++ org/aspectj/lang/reflect/InitializerSignature.java 29 Apr 2005 08:44:45 -0000 >@@ -13,8 +13,6 @@ > > > package org.aspectj.lang.reflect; >-import java.lang.reflect.Constructor; > > public interface InitializerSignature extends CodeSignature { >- Constructor getInitializer(); > } >Index: org/aspectj/lang/reflect/MethodSignature.java >=================================================================== >RCS file: /home/technology/org.aspectj/modules/runtime/src/org/aspectj/lang/reflect/MethodSignature.java,v >retrieving revision 1.2 >diff -u -r1.2 MethodSignature.java >--- org/aspectj/lang/reflect/MethodSignature.java 10 Mar 2005 10:55:05 -0000 1.2 >+++ org/aspectj/lang/reflect/MethodSignature.java 29 Apr 2005 08:44:45 -0000 >@@ -13,9 +13,8 @@ > > > package org.aspectj.lang.reflect; >-import java.lang.reflect.Method; >+import org.aspectj.runtime.reflect.ClassOrPrimitive; > > public interface MethodSignature extends CodeSignature { >- Class getReturnType(); /* name is consistent with reflection API */ >- Method getMethod(); >+ ClassOrPrimitive getReturnType(); /* name is consistent with reflection API */ > } >Index: org/aspectj/runtime/internal/CFlowCounter.java >=================================================================== >RCS file: /home/technology/org.aspectj/modules/runtime/src/org/aspectj/runtime/internal/CFlowCounter.java,v >retrieving revision 1.2 >diff -u -r1.2 CFlowCounter.java >--- org/aspectj/runtime/internal/CFlowCounter.java 14 Oct 2004 08:12:12 -0000 1.2 >+++ org/aspectj/runtime/internal/CFlowCounter.java 29 Apr 2005 08:44:45 -0000 >@@ -15,22 +15,14 @@ > package org.aspectj.runtime.internal; > > import org.aspectj.runtime.internal.cflowstack.ThreadCounter; >-import org.aspectj.runtime.internal.cflowstack.ThreadStackFactory; >-import org.aspectj.runtime.internal.cflowstack.ThreadStackFactoryImpl; >-import org.aspectj.runtime.internal.cflowstack.ThreadStackFactoryImpl11; >+import org.aspectj.runtime.internal.cflowstack.ThreadCounterImpl11; > > > public class CFlowCounter { >- >- private static ThreadStackFactory tsFactory; > private ThreadCounter flowHeightHandler; > >- static { >- selectFactoryForVMVersion(); >- } >- > public CFlowCounter() { >- flowHeightHandler = tsFactory.getNewThreadCounter(); >+ flowHeightHandler = new ThreadCounterImpl11(); > } > > public void inc() { >@@ -44,42 +36,4 @@ > public boolean isValid() { > return flowHeightHandler.isNotZero(); > } >- >- >- private static ThreadStackFactory getThreadLocalStackFactory() { return new ThreadStackFactoryImpl(); } >- private static ThreadStackFactory getThreadLocalStackFactoryFor11() { return new ThreadStackFactoryImpl11(); } >- >- private static void selectFactoryForVMVersion() { >- String override = getSystemPropertyWithoutSecurityException("aspectj.runtime.cflowstack.usethreadlocal","unspecified"); >- boolean useThreadLocalImplementation = false; >- if (override.equals("unspecified")) { >- String v = System.getProperty("java.class.version","0.0"); >- // Java 1.2 is version 46.0 and above >- useThreadLocalImplementation = (v.compareTo("46.0") >= 0); >- } else { >- useThreadLocalImplementation = override.equals("yes") || override.equals("true"); >- } >- // System.err.println("Trying to use thread local implementation? "+useThreadLocalImplementation); >- if (useThreadLocalImplementation) { >- tsFactory = getThreadLocalStackFactory(); >- } else { >- tsFactory = getThreadLocalStackFactoryFor11(); >- } >- } >- >- >- private static String getSystemPropertyWithoutSecurityException (String aPropertyName, String aDefaultValue) { >- try { >- return System.getProperty(aPropertyName, aDefaultValue); >- } >- catch (SecurityException ex) { >- return aDefaultValue; >- } >- } >- >- // For debug ... >- public static String getThreadStackFactoryClassName() { >- return tsFactory.getClass().getName(); >- } >- > } >Index: org/aspectj/runtime/internal/CFlowStack.java >=================================================================== >RCS file: /home/technology/org.aspectj/modules/runtime/src/org/aspectj/runtime/internal/CFlowStack.java,v >retrieving revision 1.6 >diff -u -r1.6 CFlowStack.java >--- org/aspectj/runtime/internal/CFlowStack.java 14 Oct 2004 08:12:12 -0000 1.6 >+++ org/aspectj/runtime/internal/CFlowStack.java 29 Apr 2005 08:44:45 -0000 >@@ -19,9 +19,7 @@ > import org.aspectj.lang.NoAspectBoundException; > import org.aspectj.runtime.CFlow; > import org.aspectj.runtime.internal.cflowstack.ThreadStack; >-import org.aspectj.runtime.internal.cflowstack.ThreadStackFactory; >-import org.aspectj.runtime.internal.cflowstack.ThreadStackFactoryImpl; >-import org.aspectj.runtime.internal.cflowstack.ThreadStackFactoryImpl11; >+import org.aspectj.runtime.internal.cflowstack.ThreadStackImpl11; > > /* > * How we benefit from ThreadLocal when it is available at runtime: >@@ -51,16 +49,10 @@ > */ > > public class CFlowStack { >- >- private static ThreadStackFactory tsFactory; > private ThreadStack stackProxy; > >- static { >- selectFactoryForVMVersion(); >- } >- > public CFlowStack() { >- stackProxy = tsFactory.getNewThreadStack(); >+ stackProxy = new ThreadStackImpl11 (); > } > > private Stack getThreadStack() { >@@ -116,41 +108,4 @@ > public boolean isValid() { > return !getThreadStack().isEmpty(); > } >- >- private static ThreadStackFactory getThreadLocalStackFactory() { return new ThreadStackFactoryImpl(); } >- private static ThreadStackFactory getThreadLocalStackFactoryFor11() { return new ThreadStackFactoryImpl11(); } >- >- private static void selectFactoryForVMVersion() { >- String override = getSystemPropertyWithoutSecurityException("aspectj.runtime.cflowstack.usethreadlocal","unspecified"); >- boolean useThreadLocalImplementation = false; >- if (override.equals("unspecified")) { >- String v = System.getProperty("java.class.version","0.0"); >- // Java 1.2 is version 46.0 and above >- useThreadLocalImplementation = (v.compareTo("46.0") >= 0); >- } else { >- useThreadLocalImplementation = override.equals("yes") || override.equals("true"); >- } >- // System.err.println("Trying to use thread local implementation? "+useThreadLocalImplementation); >- if (useThreadLocalImplementation) { >- tsFactory = getThreadLocalStackFactory(); >- } else { >- tsFactory = getThreadLocalStackFactoryFor11(); >- } >- } >- >- private static String getSystemPropertyWithoutSecurityException (String aPropertyName, String aDefaultValue) { >- try { >- return System.getProperty(aPropertyName, aDefaultValue); >- } >- catch (SecurityException ex) { >- return aDefaultValue; >- } >- } >- >- >- // For debug ... >- public static String getThreadStackFactoryClassName() { >- return tsFactory.getClass().getName(); >- } >- > } >Index: org/aspectj/runtime/internal/Conversions.java >=================================================================== >RCS file: /home/technology/org.aspectj/modules/runtime/src/org/aspectj/runtime/internal/Conversions.java,v >retrieving revision 1.1 >diff -u -r1.1 Conversions.java >--- org/aspectj/runtime/internal/Conversions.java 16 Dec 2002 17:14:48 -0000 1.1 >+++ org/aspectj/runtime/internal/Conversions.java 29 Apr 2005 08:44:45 -0000 >@@ -33,13 +33,7 @@ > } > public static Object longObject(long i) { > return new Long(i); >- } >- public static Object floatObject(float i) { >- return new Float(i); >- } >- public static Object doubleObject(double i) { >- return new Double(i); >- } >+ } > public static Object booleanObject(boolean i) { > return new Boolean(i); > } >@@ -51,8 +45,14 @@ > public static int intValue(Object o) { > if (o == null) { > return 0; >- } else if (o instanceof Number) { >- return ((Number)o).intValue(); >+ } else if (o instanceof Byte) { >+ return ((Byte)o).byteValue(); >+ } else if (o instanceof Integer) { >+ return ((Integer)o).intValue(); >+ } else if (o instanceof Long) { >+ return (int) ((Long)o).longValue(); >+ } else if (o instanceof Short) { >+ return ((Short)o).shortValue(); > } else { > throw new ClassCastException(o.getClass().getName() + > " can not be converted to int"); >@@ -61,38 +61,30 @@ > public static long longValue(Object o) { > if (o == null) { > return 0; >- } else if (o instanceof Number) { >- return ((Number)o).longValue(); >+ } else if (o instanceof Byte) { >+ return ((Byte)o).byteValue(); >+ } else if (o instanceof Integer) { >+ return ((Integer)o).intValue(); >+ } else if (o instanceof Long) { >+ return ((Long)o).longValue(); >+ } else if (o instanceof Short) { >+ return ((Short)o).shortValue(); > } else { > throw new ClassCastException(o.getClass().getName() + > " can not be converted to long"); > } > } >- public static float floatValue(Object o) { >- if (o == null) { >- return 0; >- } else if (o instanceof Number) { >- return ((Number)o).floatValue(); >- } else { >- throw new ClassCastException(o.getClass().getName() + >- " can not be converted to float"); >- } >- } >- public static double doubleValue(Object o) { >- if (o == null) { >- return 0; >- } else if (o instanceof Number) { >- return ((Number)o).doubleValue(); >- } else { >- throw new ClassCastException(o.getClass().getName() + >- " can not be converted to double"); >- } >- } > public static byte byteValue(Object o) { > if (o == null) { > return 0; >- } else if (o instanceof Number) { >- return ((Number)o).byteValue(); >+ } else if (o instanceof Byte) { >+ return ((Byte)o).byteValue(); >+ } else if (o instanceof Integer) { >+ return (byte) ((Integer)o).intValue(); >+ } else if (o instanceof Long) { >+ return (byte) ((Long)o).longValue(); >+ } else if (o instanceof Short) { >+ return (byte) ((Short)o).shortValue(); > } else { > throw new ClassCastException(o.getClass().getName() + > " can not be converted to byte"); >@@ -101,8 +93,14 @@ > public static short shortValue(Object o) { > if (o == null) { > return 0; >- } else if (o instanceof Number) { >- return ((Number)o).shortValue(); >+ } else if (o instanceof Byte) { >+ return ((Byte)o).byteValue(); >+ } else if (o instanceof Integer) { >+ return (short) ((Integer)o).intValue(); >+ } else if (o instanceof Long) { >+ return (short) ((Long)o).longValue(); >+ } else if (o instanceof Short) { >+ return ((Short)o).shortValue(); > } else { > throw new ClassCastException(o.getClass().getName() + > " can not be converted to short"); >Index: org/aspectj/runtime/internal/cflowstack/ThreadCounterImpl11.java >=================================================================== >RCS file: /home/technology/org.aspectj/modules/runtime/src/org/aspectj/runtime/internal/cflowstack/ThreadCounterImpl11.java,v >retrieving revision 1.1 >diff -u -r1.1 ThreadCounterImpl11.java >--- org/aspectj/runtime/internal/cflowstack/ThreadCounterImpl11.java 11 Oct 2004 18:39:18 -0000 1.1 >+++ org/aspectj/runtime/internal/cflowstack/ThreadCounterImpl11.java 29 Apr 2005 08:44:45 -0000 >@@ -13,11 +13,9 @@ > * ******************************************************************/ > package org.aspectj.runtime.internal.cflowstack; > >-import java.util.Iterator; >-import java.util.List; >-import java.util.ArrayList; > import java.util.Enumeration; > import java.util.Hashtable; >+import java.util.Vector; > > public class ThreadCounterImpl11 implements ThreadCounter { > private Hashtable counters = new Hashtable(); >@@ -44,13 +42,13 @@ > // Collect more often if there are many threads, but not *too* often > int size = Math.max(1, counters.size()); // should be >1 b/c always live threads, but... > if (change_count > Math.max(MIN_COLLECT_AT, COLLECT_AT/size)) { >- List dead_stacks = new ArrayList(); >+ Vector dead_stacks = new Vector (); > for (Enumeration e = counters.keys(); e.hasMoreElements(); ) { > Thread t = (Thread)e.nextElement(); >- if (!t.isAlive()) dead_stacks.add(t); >+ if (!t.isAlive()) dead_stacks.addElement(t); > } >- for (Iterator e = dead_stacks.iterator(); e.hasNext(); ) { >- Thread t = (Thread)e.next(); >+ for (Enumeration e = dead_stacks.elements(); e.hasMoreElements(); ) { >+ Thread t = (Thread)e.nextElement(); > counters.remove(t); > } > change_count = 0; >Index: org/aspectj/runtime/internal/cflowstack/ThreadStackFactory.java >=================================================================== >RCS file: org/aspectj/runtime/internal/cflowstack/ThreadStackFactory.java >diff -N org/aspectj/runtime/internal/cflowstack/ThreadStackFactory.java >--- org/aspectj/runtime/internal/cflowstack/ThreadStackFactory.java 11 Oct 2004 18:39:18 -0000 1.2 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,20 +0,0 @@ >-/* ******************************************************************* >- * Copyright (c) 2004 IBM Corporation >- * >- * All rights reserved. >- * This program and the accompanying materials are made available >- * under the terms of the Common Public License v1.0 >- * which accompanies this distribution and is available at >- * http://www.eclipse.org/legal/cpl-v10.html >- * >- * Contributors: >- * Andy Clement initial implementation >- * ******************************************************************/ >-package org.aspectj.runtime.internal.cflowstack; >- >-public interface ThreadStackFactory { >- >- public ThreadStack getNewThreadStack(); >- public ThreadCounter getNewThreadCounter(); >- >-} >Index: org/aspectj/runtime/internal/cflowstack/ThreadStackFactoryImpl.java >=================================================================== >RCS file: org/aspectj/runtime/internal/cflowstack/ThreadStackFactoryImpl.java >diff -N org/aspectj/runtime/internal/cflowstack/ThreadStackFactoryImpl.java >--- org/aspectj/runtime/internal/cflowstack/ThreadStackFactoryImpl.java 11 Oct 2004 18:39:18 -0000 1.2 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,54 +0,0 @@ >-/* ******************************************************************* >- * Copyright (c) 2004 IBM Corporation >- * >- * All rights reserved. >- * This program and the accompanying materials are made available >- * under the terms of the Common Public License v1.0 >- * which accompanies this distribution and is available at >- * http://www.eclipse.org/legal/cpl-v10.html >- * >- * Contributors: >- * Andy Clement initial implementation >- * ******************************************************************/ >-package org.aspectj.runtime.internal.cflowstack; >- >-import java.util.Stack; >- >-public class ThreadStackFactoryImpl implements ThreadStackFactory { >- >- private static class ThreadStackImpl extends ThreadLocal implements ThreadStack { >- public Object initialValue() { >- return new Stack(); >- } >- public Stack getThreadStack() { >- return (Stack)get(); >- } >- } >- >- public ThreadStack getNewThreadStack() { >- return new ThreadStackImpl(); >- } >- >- private static class ThreadCounterImpl extends ThreadLocal implements ThreadCounter { >- >- public Object initialValue() { >- return new Counter(); >- } >- public Counter getThreadCounter() { >- return (Counter)get(); >- } >- >- public void inc() { getThreadCounter().value++; } >- public void dec() { getThreadCounter().value--; } >- public boolean isNotZero() { return getThreadCounter().value!= 0; } >- >- static class Counter { >- protected int value = 0; >- } >- } >- >- public ThreadCounter getNewThreadCounter() { >- return new ThreadCounterImpl(); >- } >- >-} >Index: org/aspectj/runtime/internal/cflowstack/ThreadStackFactoryImpl11.java >=================================================================== >RCS file: org/aspectj/runtime/internal/cflowstack/ThreadStackFactoryImpl11.java >diff -N org/aspectj/runtime/internal/cflowstack/ThreadStackFactoryImpl11.java >--- org/aspectj/runtime/internal/cflowstack/ThreadStackFactoryImpl11.java 11 Oct 2004 18:39:18 -0000 1.2 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,26 +0,0 @@ >-/* ******************************************************************* >- * Copyright (c) 2004 IBM Corporation >- * >- * All rights reserved. >- * This program and the accompanying materials are made available >- * under the terms of the Common Public License v1.0 >- * which accompanies this distribution and is available at >- * http://www.eclipse.org/legal/cpl-v10.html >- * >- * Contributors: >- * Andy Clement initial implementation >- * ******************************************************************/ >-package org.aspectj.runtime.internal.cflowstack; >- >- >-public class ThreadStackFactoryImpl11 implements ThreadStackFactory { >- >- public ThreadStack getNewThreadStack() { >- return new ThreadStackImpl11(); >- } >- >- public ThreadCounter getNewThreadCounter() { >- return new ThreadCounterImpl11(); >- } >- >-} >Index: org/aspectj/runtime/reflect/AdviceSignatureImpl.java >=================================================================== >RCS file: /home/technology/org.aspectj/modules/runtime/src/org/aspectj/runtime/reflect/AdviceSignatureImpl.java,v >retrieving revision 1.6 >diff -u -r1.6 AdviceSignatureImpl.java >--- org/aspectj/runtime/reflect/AdviceSignatureImpl.java 10 Mar 2005 10:55:05 -0000 1.6 >+++ org/aspectj/runtime/reflect/AdviceSignatureImpl.java 29 Apr 2005 08:44:45 -0000 >@@ -14,17 +14,14 @@ > > package org.aspectj.runtime.reflect; > >-import java.lang.reflect.Method; >- > import org.aspectj.lang.reflect.AdviceSignature; > > class AdviceSignatureImpl extends CodeSignatureImpl implements AdviceSignature { >- Class returnType; >- private Method adviceMethod = null; >+ ClassOrPrimitive returnType; > > AdviceSignatureImpl(int modifiers, String name, Class declaringType, >- Class[] parameterTypes, String[] parameterNames, Class[] exceptionTypes, >- Class returnType) >+ ClassOrPrimitive[] parameterTypes, String[] parameterNames, Class[] exceptionTypes, >+ ClassOrPrimitive returnType) > { > super(modifiers, name, declaringType, parameterTypes, parameterNames, > exceptionTypes); >@@ -37,7 +34,7 @@ > /* name is consistent with reflection API > before and after always return Void.TYPE > (some around also return Void.Type) */ >- public Class getReturnType() { >+ public ClassOrPrimitive getReturnType() { > if (returnType == null) returnType = extractType(6); > return returnType; > } >@@ -55,18 +52,4 @@ > sm.addThrows(buf, getExceptionTypes()); > return buf.toString(); > } >- >- /* (non-Javadoc) >- * @see org.aspectj.runtime.reflect.MemberSignatureImpl#createAccessibleObject() >- */ >- public Method getAdvice() { >- if (adviceMethod == null) { >- try { >- adviceMethod = declaringType.getDeclaredMethod(getName(),getParameterTypes()); >- } catch (Exception ex) { >- ; // nothing we can do, caller will see null >- } >- } >- return adviceMethod; >- } > } >Index: org/aspectj/runtime/reflect/CatchClauseSignatureImpl.java >=================================================================== >RCS file: /home/technology/org.aspectj/modules/runtime/src/org/aspectj/runtime/reflect/CatchClauseSignatureImpl.java,v >retrieving revision 1.3 >diff -u -r1.3 CatchClauseSignatureImpl.java >--- org/aspectj/runtime/reflect/CatchClauseSignatureImpl.java 1 Sep 2004 10:30:07 -0000 1.3 >+++ org/aspectj/runtime/reflect/CatchClauseSignatureImpl.java 29 Apr 2005 08:44:45 -0000 >@@ -17,11 +17,11 @@ > import org.aspectj.lang.reflect.CatchClauseSignature; > > class CatchClauseSignatureImpl extends SignatureImpl implements CatchClauseSignature { >- Class parameterType; >+ ClassOrPrimitive parameterType; > String parameterName; > > CatchClauseSignatureImpl(Class declaringType, >- Class parameterType, String parameterName) >+ ClassOrPrimitive parameterType, String parameterName) > { > super(0, "catch", declaringType); > this.parameterType = parameterType; >@@ -32,7 +32,7 @@ > super(stringRep); > } > >- public Class getParameterType() { >+ public ClassOrPrimitive getParameterType() { > if (parameterType == null) parameterType = extractType(3); > return parameterType; > } >Index: org/aspectj/runtime/reflect/CodeSignatureImpl.java >=================================================================== >RCS file: /home/technology/org.aspectj/modules/runtime/src/org/aspectj/runtime/reflect/CodeSignatureImpl.java,v >retrieving revision 1.2 >diff -u -r1.2 CodeSignatureImpl.java >--- org/aspectj/runtime/reflect/CodeSignatureImpl.java 13 Feb 2003 06:03:19 -0000 1.2 >+++ org/aspectj/runtime/reflect/CodeSignatureImpl.java 29 Apr 2005 08:44:45 -0000 >@@ -17,12 +17,12 @@ > import org.aspectj.lang.reflect.CodeSignature; > > abstract class CodeSignatureImpl extends MemberSignatureImpl implements CodeSignature { >- Class[] parameterTypes; >+ ClassOrPrimitive[] parameterTypes; > String[] parameterNames; > Class[] exceptionTypes; > > CodeSignatureImpl(int modifiers, String name, Class declaringType, >- Class[] parameterTypes, String[] parameterNames, Class[] exceptionTypes) >+ ClassOrPrimitive[] parameterTypes, String[] parameterNames, Class[] exceptionTypes) > { > super(modifiers, name, declaringType); > this.parameterTypes = parameterTypes; >@@ -33,7 +33,7 @@ > super(stringRep); > } > >- public Class[] getParameterTypes() { >+ public ClassOrPrimitive[] getParameterTypes() { > if (parameterTypes == null) parameterTypes = extractTypes(3); > return parameterTypes; > } >@@ -42,7 +42,12 @@ > return parameterNames; > } > public Class[] getExceptionTypes() { >- if (exceptionTypes == null) exceptionTypes = extractTypes(5); >+ if (exceptionTypes == null) { >+ ClassOrPrimitive[] types = extractTypes (5); >+ exceptionTypes = new Class[types.length]; >+ for (int i=0;i<types.length;i++) >+ exceptionTypes[i] = types[i].getClazz (); >+ } > return exceptionTypes; > } > } >Index: org/aspectj/runtime/reflect/ConstructorSignatureImpl.java >=================================================================== >RCS file: /home/technology/org.aspectj/modules/runtime/src/org/aspectj/runtime/reflect/ConstructorSignatureImpl.java,v >retrieving revision 1.6 >diff -u -r1.6 ConstructorSignatureImpl.java >--- org/aspectj/runtime/reflect/ConstructorSignatureImpl.java 10 Mar 2005 10:55:05 -0000 1.6 >+++ org/aspectj/runtime/reflect/ConstructorSignatureImpl.java 29 Apr 2005 08:44:45 -0000 >@@ -14,15 +14,11 @@ > > package org.aspectj.runtime.reflect; > >-import java.lang.reflect.Constructor; >- > import org.aspectj.lang.reflect.ConstructorSignature; > >-class ConstructorSignatureImpl extends CodeSignatureImpl implements ConstructorSignature { >- private Constructor constructor; >- >+class ConstructorSignatureImpl extends CodeSignatureImpl implements ConstructorSignature { > ConstructorSignatureImpl(int modifiers, Class declaringType, >- Class[] parameterTypes, String[] parameterNames, Class[] exceptionTypes) >+ ClassOrPrimitive[] parameterTypes, String[] parameterNames, Class[] exceptionTypes) > { > super(modifiers, "<init>", declaringType, parameterTypes, parameterNames, exceptionTypes); > } >@@ -41,18 +37,4 @@ > sm.addThrows(buf, getExceptionTypes()); > return buf.toString(); > } >- >- /* (non-Javadoc) >- * @see org.aspectj.runtime.reflect.MemberSignatureImpl#createAccessibleObject() >- */ >- public Constructor getConstructor() { >- if (constructor == null) { >- try { >- constructor = declaringType.getDeclaredConstructor(getParameterTypes()); >- } catch (Exception ex) { >- ; // nothing we can do, caller will see null >- } >- } >- return constructor; >- } > } >Index: org/aspectj/runtime/reflect/Factory.java >=================================================================== >RCS file: /home/technology/org.aspectj/modules/runtime/src/org/aspectj/runtime/reflect/Factory.java,v >retrieving revision 1.6 >diff -u -r1.6 Factory.java >--- org/aspectj/runtime/reflect/Factory.java 19 Apr 2005 11:52:17 -0000 1.6 >+++ org/aspectj/runtime/reflect/Factory.java 29 Apr 2005 08:44:46 -0000 >@@ -15,22 +15,22 @@ > > package org.aspectj.runtime.reflect; > >-import java.lang.reflect.Constructor; >-import java.lang.reflect.Member; >-import java.lang.reflect.Method; >- >-import org.aspectj.lang.*; >-import org.aspectj.lang.reflect.*; >+import org.aspectj.lang.JoinPoint; >+import org.aspectj.lang.Signature; >+import org.aspectj.lang.reflect.AdviceSignature; >+import org.aspectj.lang.reflect.CatchClauseSignature; >+import org.aspectj.lang.reflect.ConstructorSignature; >+import org.aspectj.lang.reflect.FieldSignature; >+import org.aspectj.lang.reflect.InitializerSignature; >+import org.aspectj.lang.reflect.MethodSignature; >+import org.aspectj.lang.reflect.SourceLocation; > > public final class Factory { > Class lexicalClass; >- ClassLoader lookupClassLoader; > String filename; > public Factory(String filename, Class lexicalClass) { >- //System.out.println("making > this.filename = filename; > this.lexicalClass = lexicalClass; >- lookupClassLoader = lexicalClass.getClassLoader(); > } > > public JoinPoint.StaticPart makeSJP(String kind, Signature sig, SourceLocation loc) { >@@ -56,7 +56,7 @@ > public JoinPoint.EnclosingStaticPart makeESJP(String kind, Signature sig, int l) { > return new JoinPointImpl.EnclosingStaticPartImpl(kind, sig, makeSourceLoc(l, -1)); > } >- >+/* > public static JoinPoint.StaticPart makeEncSJP(Member member) { > Signature sig = null; > String kind = null; >@@ -79,7 +79,7 @@ > } > return new JoinPointImpl.EnclosingStaticPartImpl(kind,sig,null); > } >- >+ */ > private static Object[] NO_ARGS = new Object[0]; > public static JoinPoint makeJP(JoinPoint.StaticPart staticPart, > Object _this, Object target) >@@ -108,80 +108,68 @@ > > public MethodSignature makeMethodSig(String stringRep) { > MethodSignatureImpl ret = new MethodSignatureImpl(stringRep); >- ret.setLookupClassLoader(lookupClassLoader); > return ret; > } > > public MethodSignature makeMethodSig(int modifiers, String name, Class declaringType, >- Class[] parameterTypes, String[] parameterNames, Class[] exceptionTypes, >- Class returnType) { >+ ClassOrPrimitive[] parameterTypes, String[] parameterNames, Class[] exceptionTypes, >+ ClassOrPrimitive returnType) { > MethodSignatureImpl ret = new MethodSignatureImpl(modifiers,name,declaringType,parameterTypes,parameterNames,exceptionTypes,returnType); >- ret.setLookupClassLoader(lookupClassLoader); > return ret; > } > > public ConstructorSignature makeConstructorSig(String stringRep) { > ConstructorSignatureImpl ret = new ConstructorSignatureImpl(stringRep); >- ret.setLookupClassLoader(lookupClassLoader); > return ret; > } > > public ConstructorSignature makeConstructorSig(int modifiers, Class declaringType, >- Class[] parameterTypes, String[] parameterNames, Class[] exceptionTypes) { >+ ClassOrPrimitive[] parameterTypes, String[] parameterNames, Class[] exceptionTypes) { > ConstructorSignatureImpl ret = new ConstructorSignatureImpl(modifiers,declaringType,parameterTypes,parameterNames,exceptionTypes); >- ret.setLookupClassLoader(lookupClassLoader); > return ret; > } > > public FieldSignature makeFieldSig(String stringRep) { > FieldSignatureImpl ret = new FieldSignatureImpl(stringRep); >- ret.setLookupClassLoader(lookupClassLoader); > return ret; > } > > public FieldSignature makeFieldSig(int modifiers, String name, Class declaringType, >- Class fieldType) { >+ ClassOrPrimitive fieldType) { > FieldSignatureImpl ret = new FieldSignatureImpl(modifiers,name,declaringType,fieldType); >- ret.setLookupClassLoader(lookupClassLoader); > return ret; > } > > public AdviceSignature makeAdviceSig(String stringRep) { > AdviceSignatureImpl ret = new AdviceSignatureImpl(stringRep); >- ret.setLookupClassLoader(lookupClassLoader); > return ret; > } > > public AdviceSignature makeAdviceSig(int modifiers, String name, Class declaringType, >- Class[] parameterTypes, String[] parameterNames, Class[] exceptionTypes, >- Class returnType) { >+ ClassOrPrimitive[] parameterTypes, String[] parameterNames, Class[] exceptionTypes, >+ ClassOrPrimitive returnType) { > AdviceSignatureImpl ret = new AdviceSignatureImpl(modifiers,name,declaringType,parameterTypes,parameterNames,exceptionTypes,returnType); >- ret.setLookupClassLoader(lookupClassLoader); > return ret; > } > > public InitializerSignature makeInitializerSig(String stringRep) { > InitializerSignatureImpl ret = new InitializerSignatureImpl(stringRep); >- ret.setLookupClassLoader(lookupClassLoader); > return ret; > } > > public InitializerSignature makeInitializerSig(int modifiers, Class declaringType) { > InitializerSignatureImpl ret = new InitializerSignatureImpl(modifiers,declaringType); >- ret.setLookupClassLoader(lookupClassLoader); > return ret; > } > > public CatchClauseSignature makeCatchClauseSig(String stringRep) { > CatchClauseSignatureImpl ret = new CatchClauseSignatureImpl(stringRep); >- ret.setLookupClassLoader(lookupClassLoader); > return ret; > } > > public CatchClauseSignature makeCatchClauseSig(Class declaringType, >- Class parameterType, String parameterName) { >+ ClassOrPrimitive parameterType, String parameterName) { > CatchClauseSignatureImpl ret = new CatchClauseSignatureImpl(declaringType,parameterType,parameterName); >- ret.setLookupClassLoader(lookupClassLoader); > return ret; > } > >Index: org/aspectj/runtime/reflect/FieldSignatureImpl.java >=================================================================== >RCS file: /home/technology/org.aspectj/modules/runtime/src/org/aspectj/runtime/reflect/FieldSignatureImpl.java,v >retrieving revision 1.6 >diff -u -r1.6 FieldSignatureImpl.java >--- org/aspectj/runtime/reflect/FieldSignatureImpl.java 10 Mar 2005 10:55:05 -0000 1.6 >+++ org/aspectj/runtime/reflect/FieldSignatureImpl.java 29 Apr 2005 08:44:46 -0000 >@@ -14,16 +14,13 @@ > > package org.aspectj.runtime.reflect; > >-import java.lang.reflect.Field; >- > import org.aspectj.lang.reflect.FieldSignature; > > public class FieldSignatureImpl extends MemberSignatureImpl implements FieldSignature { >- Class fieldType; >- private Field field; >+ ClassOrPrimitive fieldType; > > FieldSignatureImpl(int modifiers, String name, Class declaringType, >- Class fieldType) >+ ClassOrPrimitive fieldType) > { > super(modifiers, name, declaringType); > this.fieldType = fieldType; >@@ -33,7 +30,7 @@ > super(stringRep); > } > >- public Class getFieldType() { >+ public ClassOrPrimitive getFieldType() { > if (fieldType == null) fieldType = extractType(3); > return fieldType; > } >@@ -48,18 +45,4 @@ > buf.append(getName()); > return buf.toString(); > } >- >- /* (non-Javadoc) >- * @see org.aspectj.runtime.reflect.MemberSignatureImpl#createAccessibleObject() >- */ >- public Field getField() { >- if (field == null) { >- try { >- field = declaringType.getDeclaredField(getName()); >- } catch (Exception ex) { >- ; // nothing we can do, caller will see null >- } >- } >- return field; >- } > } >Index: org/aspectj/runtime/reflect/InitializerSignatureImpl.java >=================================================================== >RCS file: /home/technology/org.aspectj/modules/runtime/src/org/aspectj/runtime/reflect/InitializerSignatureImpl.java,v >retrieving revision 1.6 >diff -u -r1.6 InitializerSignatureImpl.java >--- org/aspectj/runtime/reflect/InitializerSignatureImpl.java 10 Mar 2005 10:55:05 -0000 1.6 >+++ org/aspectj/runtime/reflect/InitializerSignatureImpl.java 29 Apr 2005 08:44:46 -0000 >@@ -16,14 +16,9 @@ > > import org.aspectj.lang.reflect.InitializerSignature; > >-import java.lang.reflect.Constructor; >-import java.lang.reflect.Modifier; >- > class InitializerSignatureImpl extends CodeSignatureImpl implements InitializerSignature { >- private Constructor constructor; >- > InitializerSignatureImpl(int modifiers, Class declaringType) { >- super(modifiers, Modifier.isStatic(modifiers) ? "<clinit>" : "<init>", declaringType, EMPTY_CLASS_ARRAY, >+ super(modifiers, Modifier.isStatic(modifiers) ? "<clinit>" : "<init>", declaringType, EMPTY_CLASS_OR_PRIMITIVE_ARRAY, > EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY); > } > >@@ -43,18 +38,4 @@ > buf.append(getName()); > return buf.toString(); > } >- >- /* (non-Javadoc) >- * @see org.aspectj.runtime.reflect.MemberSignatureImpl#createAccessibleObject() >- */ >- public Constructor getInitializer() { >- if (constructor == null) { >- try { >- constructor = declaringType.getDeclaredConstructor(getParameterTypes()); >- } catch (Exception ex) { >- ; // nothing we can do, caller will see null >- } >- } >- return constructor; >- } > } >Index: org/aspectj/runtime/reflect/MethodSignatureImpl.java >=================================================================== >RCS file: /home/technology/org.aspectj/modules/runtime/src/org/aspectj/runtime/reflect/MethodSignatureImpl.java,v >retrieving revision 1.6 >diff -u -r1.6 MethodSignatureImpl.java >--- org/aspectj/runtime/reflect/MethodSignatureImpl.java 10 Mar 2005 10:55:05 -0000 1.6 >+++ org/aspectj/runtime/reflect/MethodSignatureImpl.java 29 Apr 2005 08:44:46 -0000 >@@ -14,17 +14,14 @@ > > package org.aspectj.runtime.reflect; > >-import java.lang.reflect.Method; >- > import org.aspectj.lang.reflect.MethodSignature; > > class MethodSignatureImpl extends CodeSignatureImpl implements MethodSignature { >- private Method method; >- Class returnType; >+ ClassOrPrimitive returnType; > > MethodSignatureImpl(int modifiers, String name, Class declaringType, >- Class[] parameterTypes, String[] parameterNames, Class[] exceptionTypes, >- Class returnType) >+ ClassOrPrimitive[] parameterTypes, String[] parameterNames, Class[] exceptionTypes, >+ ClassOrPrimitive returnType) > { > super(modifiers, name, declaringType, parameterTypes, parameterNames, > exceptionTypes); >@@ -36,7 +33,7 @@ > } > > /* name is consistent with reflection API */ >- public Class getReturnType() { >+ public ClassOrPrimitive getReturnType() { > if (returnType == null) returnType = extractType(6); > return returnType; > } >@@ -53,18 +50,4 @@ > sm.addThrows(buf, getExceptionTypes()); > return buf.toString(); > } >- >- /* (non-Javadoc) >- * @see org.aspectj.lang.reflect.MemberSignature#getAccessibleObject() >- */ >- public Method getMethod() { >- if (method == null) { >- try { >- method = declaringType.getDeclaredMethod(getName(),getParameterTypes()); >- } catch (NoSuchMethodException nsmEx) { >- ; // nothing we can do, user will see null return >- } >- } >- return method; >- } > } >Index: org/aspectj/runtime/reflect/SignatureImpl.java >=================================================================== >RCS file: /home/technology/org.aspectj/modules/runtime/src/org/aspectj/runtime/reflect/SignatureImpl.java,v >retrieving revision 1.5 >diff -u -r1.5 SignatureImpl.java >--- org/aspectj/runtime/reflect/SignatureImpl.java 1 Sep 2004 10:30:07 -0000 1.5 >+++ org/aspectj/runtime/reflect/SignatureImpl.java 29 Apr 2005 08:44:46 -0000 >@@ -14,21 +14,16 @@ > > package org.aspectj.runtime.reflect; > >-import org.aspectj.lang.Signature; >- >-import java.lang.ref.SoftReference; > import java.util.Hashtable; >-import java.util.StringTokenizer; > >-abstract class SignatureImpl implements Signature { >+import org.aspectj.lang.Signature; > >- private static boolean useCache = true; >- >+abstract class SignatureImpl implements Signature { > int modifiers = -1; > String name; > String declaringTypeName; > Class declaringType; >- SoftReference toStringCacheRef; >+ String[] toStringCache; > > SignatureImpl(int modifiers, String name, Class declaringType) { > this.modifiers = modifiers; >@@ -40,15 +35,8 @@ > > /* Use a soft cache for the short, middle and long String representations */ > String toString (StringMaker sm) { >- String[] toStringCache = null; >- if (toStringCacheRef == null || toStringCacheRef.get() == null) { >+ if (toStringCache == null) > toStringCache = new String[3]; >- if (useCache) toStringCacheRef = new SoftReference(toStringCache); >- } >- else { >- toStringCache = (String[])toStringCacheRef.get(); >- } >- > if (toStringCache[sm.cacheOffset] == null) { > toStringCache[sm.cacheOffset] = createToString(sm); > } >@@ -68,7 +56,7 @@ > return name; > } > public Class getDeclaringType() { >- if (declaringType == null) declaringType = extractType(2); >+ if (declaringType == null) declaringType = extractType(2).getClazz(); > return declaringType; > } > public String getDeclaringTypeName() { >@@ -78,7 +66,7 @@ > return declaringTypeName; > } > >- String fullTypeName(Class type) { >+ String fullTypeName(ClassOrPrimitive type) { > if (type == null) return "ANONYMOUS"; > if (type.isArray()) return fullTypeName(type.getComponentType()) + "[]"; > return type.getName().replace('$', '.'); >@@ -90,41 +78,31 @@ > return name.substring(dot+1); > } > >- String shortTypeName(Class type) { >+ String shortTypeName(ClassOrPrimitive type) { > if (type == null) return "ANONYMOUS"; > if (type.isArray()) return shortTypeName(type.getComponentType()) + "[]"; > return stripPackageName(type.getName()).replace('$', '.'); > } > >- void addFullTypeNames(StringBuffer buf, Class[] types) { >+ void addFullTypeNames(StringBuffer buf, ClassOrPrimitive[] types) { > for (int i = 0; i < types.length; i++) { > if (i > 0) buf.append(", "); > buf.append(fullTypeName(types[i])); > } > } >- void addShortTypeNames(StringBuffer buf, Class[] types) { >+ void addShortTypeNames(StringBuffer buf, ClassOrPrimitive[] types) { > for (int i = 0; i < types.length; i++) { > if (i > 0) buf.append(", "); > buf.append(shortTypeName(types[i])); > } > } > >- void addTypeArray(StringBuffer buf, Class[] types) { >+ void addTypeArray(StringBuffer buf, ClassOrPrimitive[] types) { > addFullTypeNames(buf, types); > } > > // lazy version > private String stringRep; >- ClassLoader lookupClassLoader = null; >- >- public void setLookupClassLoader(ClassLoader loader) { >- this.lookupClassLoader = loader; >- } >- >- private ClassLoader getLookupClassLoader() { >- if (lookupClassLoader == null) lookupClassLoader = this.getClass().getClassLoader(); >- return lookupClassLoader; >- } > > public SignatureImpl(String stringRep) { > this.stringRep = stringRep; >@@ -133,8 +111,6 @@ > static final char SEP = '-'; > > String extractString(int n) { >- //System.out.println(n + ": from " + stringRep); >- > int startIndex = 0; > int endIndex = stringRep.indexOf(SEP); > while (n-- > 0) { >@@ -143,8 +119,6 @@ > } > if (endIndex == -1) endIndex = stringRep.length(); > >- //System.out.println(" " + stringRep.substring(startIndex, endIndex)); >- > return stringRep.substring(startIndex, endIndex); > } > >@@ -153,78 +127,70 @@ > return Integer.parseInt(s, 16); > } > >- Class extractType(int n) { >+ ClassOrPrimitive extractType(int n) { > String s = extractString(n); > return makeClass(s); > } > > static Hashtable prims = new Hashtable(); > static { >- prims.put("void", Void.TYPE); >- prims.put("boolean", Boolean.TYPE); >- prims.put("byte", Byte.TYPE); >- prims.put("char", Character.TYPE); >- prims.put("short", Short.TYPE); >- prims.put("int", Integer.TYPE); >- prims.put("long", Long.TYPE); >- prims.put("float", Float.TYPE); >- prims.put("double", Double.TYPE); >- } >+ prims.put("void", new ClassOrPrimitive ("void")); >+ prims.put("boolean", new ClassOrPrimitive ("boolean")); >+ prims.put("byte", new ClassOrPrimitive ("byte")); >+ prims.put("char", new ClassOrPrimitive ("char")); >+ prims.put("short", new ClassOrPrimitive ("short")); >+ prims.put("int", new ClassOrPrimitive ("int")); >+ prims.put("long", new ClassOrPrimitive ("long")); >+ prims.put("float", new ClassOrPrimitive ("float")); >+ prims.put("double", new ClassOrPrimitive ("double")); >+ } > >- Class makeClass(String s) { >- if (s.equals("*")) return null; >- Class ret = (Class)prims.get(s); >+ ClassOrPrimitive makeClass(String s) { >+ if (s.equals("*")) return null; >+ ClassOrPrimitive ret = (ClassOrPrimitive)prims.get(s); > if (ret != null) return ret; > try { >- /* The documentation of Class.forName explains why this is the right thing >- * better than I could here. >- */ >- ClassLoader loader = getLookupClassLoader(); >- if (loader == null) { >- return Class.forName(s); >- } else { >- // used to be 'return loader.loadClass(s)' but that didn't cause >- // array types to be created and loaded correctly. (pr70404) >- return Class.forName(s,false,loader); >- } >+ return new ClassOrPrimitive (Class.forName (s)); > } catch (ClassNotFoundException e) { >- //System.out.println("null for: " + s); >- //XXX there should be a better return value for this >- return ClassNotFoundException.class; >+ try { >+ // work around a bug in CLDC 1.0 spec >+ return new ClassOrPrimitive (Class.forName ("java.lang.ClassNotFoundException")); >+ } catch (ClassNotFoundException e2) { >+ return null; >+ } > } > } > > static String[] EMPTY_STRING_ARRAY = new String[0]; > static Class[] EMPTY_CLASS_ARRAY = new Class[0]; >+ static ClassOrPrimitive[] EMPTY_CLASS_OR_PRIMITIVE_ARRAY = new ClassOrPrimitive[0]; > > static final String INNER_SEP = ":"; > > String[] extractStrings(int n) { > String s = extractString(n); >- StringTokenizer st = new StringTokenizer(s, INNER_SEP); >- final int N = st.countTokens(); >+ int N = 0; >+ for (int idx = 0; idx != -1; n++) >+ idx = s.indexOf (INNER_SEP, idx + 1); > String[] ret = new String[N]; >- for (int i = 0; i < N; i++) ret[i]= st.nextToken(); >+ for (int i = 0, idx = 0; i < N; i++) { >+ int nextIdx = s.indexOf (INNER_SEP, idx); >+ ret[i] = s.substring (idx, nextIdx - idx); >+ idx = nextIdx + 1; >+ } > return ret; > } >- Class[] extractTypes(int n) { >+ ClassOrPrimitive[] extractTypes(int n) { > String s = extractString(n); >- StringTokenizer st = new StringTokenizer(s, INNER_SEP); >- final int N = st.countTokens(); >- Class[] ret = new Class[N]; >- for (int i = 0; i < N; i++) ret[i]= makeClass(st.nextToken()); >+ int N = 0; >+ for (int idx = 0; idx != -1; n++) >+ idx = s.indexOf (INNER_SEP, idx + 1); >+ ClassOrPrimitive[] ret = new ClassOrPrimitive[N]; >+ for (int i = 0, idx = 0; i < N; i++) { >+ int nextIdx = s.indexOf (INNER_SEP, idx); >+ ret[i] = makeClass (s.substring (idx, nextIdx - idx)); >+ idx = nextIdx + 1; >+ } > return ret; >- } >- >- /* >- * Used for testing >- */ >- static void setUseCache (boolean b) { >- useCache = b; >- } >- >- static boolean getUseCache () { >- return useCache; >- } >- >+ } > } >Index: org/aspectj/runtime/reflect/StringMaker.java >=================================================================== >RCS file: /home/technology/org.aspectj/modules/runtime/src/org/aspectj/runtime/reflect/StringMaker.java,v >retrieving revision 1.4 >diff -u -r1.4 StringMaker.java >--- org/aspectj/runtime/reflect/StringMaker.java 1 Sep 2004 10:30:07 -0000 1.4 >+++ org/aspectj/runtime/reflect/StringMaker.java 29 Apr 2005 08:44:46 -0000 >@@ -14,8 +14,6 @@ > > package org.aspectj.runtime.reflect; > >-import java.lang.reflect.Modifier; >- > class StringMaker { > boolean shortTypeNames = true; > boolean includeArgs = true; >@@ -87,10 +85,10 @@ > return name.substring(dot+1); > } > >- String makeTypeName(Class type, String typeName, boolean shortName) { >+ String makeTypeName(ClassOrPrimitive type, String typeName, boolean shortName) { > if (type == null) return "ANONYMOUS"; > if (type.isArray()) { >- Class componentType = type.getComponentType(); >+ ClassOrPrimitive componentType = type.getComponentType(); > return makeTypeName(componentType, componentType.getName(), shortName) + "[]"; > } > if (shortName) { >@@ -99,23 +97,32 @@ > return typeName.replace('$', '.'); > } > } >+ String makeTypeName(Class type, String typeName, boolean shortName) { >+ return makeTypeName(new ClassOrPrimitive (type), typeName, shortName); >+ } > >- public String makeTypeName(Class type) { >+ public String makeTypeName(ClassOrPrimitive type) { > return makeTypeName(type, type.getName(),shortTypeNames); > } >+ public String makeTypeName(Class type) { >+ return makeTypeName(new ClassOrPrimitive (type)); >+ } > >- public String makePrimaryTypeName(Class type, String typeName) { >+ public String makePrimaryTypeName(ClassOrPrimitive type, String typeName) { > return makeTypeName(type, typeName, shortPrimaryTypeNames); > } >+ public String makePrimaryTypeName(Class type, String typeName) { >+ return makePrimaryTypeName(new ClassOrPrimitive (type), typeName); >+ } > >- public void addTypeNames(StringBuffer buf, Class[] types) { >+ public void addTypeNames(StringBuffer buf, ClassOrPrimitive[] types) { > for (int i = 0; i < types.length; i++) { > if (i > 0) buf.append(", "); > buf.append(makeTypeName(types[i])); > } > } > >- public void addSignature(StringBuffer buf, Class[] types) { >+ public void addSignature(StringBuffer buf, ClassOrPrimitive[] types) { > if (types == null) return; > if (!includeArgs) { > if (types.length == 0) { >@@ -135,6 +142,9 @@ > if (!includeThrows || types == null || types.length == 0) return; > > buf.append(" throws "); >- addTypeNames(buf, types); >+ for (int i = 0; i < types.length; i++) { >+ if (i > 0) buf.append(", "); >+ buf.append(makeTypeName(types[i])); >+ } > } > } >Index: org/aspectj/runtime/reflect/ClassOrPrimitive.java >=================================================================== >RCS file: org/aspectj/runtime/reflect/ClassOrPrimitive.java >diff -N org/aspectj/runtime/reflect/ClassOrPrimitive.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ org/aspectj/runtime/reflect/ClassOrPrimitive.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,98 @@ >+/* ******************************************************************* >+ * Copyright (c) 2005 Chris January >+ * >+ * All rights reserved. >+ * This program and the accompanying materials are made available >+ * under the terms of the Common Public License v1.0 >+ * which accompanies this distribution and is available at >+ * http://www.eclipse.org/legal/cpl-v10.html >+ * >+ * Contributors: >+ * Chris January initial implementation >+ * ******************************************************************/ >+ >+package org.aspectj.runtime.reflect; >+ >+public class ClassOrPrimitive { >+ private Class c; >+ private String prim; >+ >+ public ClassOrPrimitive (Class c) { >+ this.c = c; >+ } >+ public ClassOrPrimitive (String prim) { >+ this.prim = prim; >+ } >+ >+ public Class getClazz () { >+ return c; >+ } >+ public String getName () { >+ if (prim != null) >+ return prim; >+ else >+ return c.getName (); >+ } >+ >+ public boolean isArray () { >+ return c != null && c.isArray (); >+ } >+ public boolean isAssignableFrom (Class cls) { >+ return c != null && c.isAssignableFrom (cls); >+ } >+ public boolean isInstance (Object obj) { >+ return c != null && c.isInstance (obj); >+ } >+ public boolean isInterface () { >+ return c != null && c.isInterface (); >+ } >+ public Object newInstance () throws InstantiationException, IllegalAccessException { >+ if (c == null) >+ throw new InstantiationException (); >+ return c.newInstance (); >+ } >+ public String toString () { >+ if (prim != null) >+ return prim; >+ else >+ return c.toString (); >+ } >+ public ClassOrPrimitive getComponentType () { >+ String name = getName (); >+ if (name == null || >+ name.length () == 0 || >+ name.charAt (0) != '[') { >+ return null; >+ } >+ name = name.substring (1); >+ if (name.length () == 0) >+ return null; >+ char c = name.charAt (0); >+ switch (c) { >+ case 'Z': >+ return new ClassOrPrimitive ("boolean"); >+ case 'B': >+ return new ClassOrPrimitive ("byte"); >+ case 'C': >+ return new ClassOrPrimitive ("char"); >+ case 'D': >+ return new ClassOrPrimitive ("double"); >+ case 'F': >+ return new ClassOrPrimitive ("float"); >+ case 'I': >+ return new ClassOrPrimitive ("int"); >+ case 'J': >+ return new ClassOrPrimitive ("long"); >+ case 'S': >+ return new ClassOrPrimitive ("short"); >+ case 'L': >+ name = name.substring (1, name.length () - 2); >+ default: >+ try { >+ return new ClassOrPrimitive (Class.forName (name)); >+ } catch (ClassNotFoundException e) { >+ return null; >+ } >+ } >+ } >+} >Index: org/aspectj/runtime/reflect/Modifier.java >=================================================================== >RCS file: org/aspectj/runtime/reflect/Modifier.java >diff -N org/aspectj/runtime/reflect/Modifier.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ org/aspectj/runtime/reflect/Modifier.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,59 @@ >+/* ******************************************************************* >+ * Copyright (c) 2005 Chris January >+ * >+ * All rights reserved. >+ * This program and the accompanying materials are made available >+ * under the terms of the Common Public License v1.0 >+ * which accompanies this distribution and is available at >+ * http://www.eclipse.org/legal/cpl-v10.html >+ * >+ * Contributors: >+ * Chris January initial implementation >+ * ******************************************************************/ >+ >+package org.aspectj.runtime.reflect; >+ >+public class Modifier { >+ public static final int ABSTRACT = 1024; >+ public static final int FINAL = 16; >+ public static final int INTERFACE = 512; >+ public static final int NATIVE = 256; >+ public static final int PRIVATE = 2; >+ public static final int PROTECTED = 4; >+ public static final int PUBLIC = 1; >+ public static final int STATIC = 8; >+ public static final int STRICT = 2048; >+ public static final int SYNCHRONIZED = 32; >+ public static final int TRANSIENT = 128; >+ public static final int VOLATILE = 64; >+ >+ public Modifier () {} >+ >+ public static boolean isAbstract (int mod) { return (mod & ABSTRACT) != 0; } >+ public static boolean isFinal (int mod) { return (mod & FINAL) != 0; } >+ public static boolean isInterface (int mod) { return (mod & INTERFACE) != 0; } >+ public static boolean isNative (int mod) { return (mod & NATIVE) != 0; } >+ public static boolean isPrivate (int mod) { return (mod & PRIVATE) != 0; } >+ public static boolean isProtected (int mod) { return (mod & PROTECTED) != 0; } >+ public static boolean isPublic (int mod) { return (mod & PUBLIC) != 0; } >+ public static boolean isStatic (int mod) { return (mod & STATIC) != 0; } >+ public static boolean isStrict (int mod) { return (mod & STRICT) != 0; } >+ public static boolean isSynchronized (int mod) { return (mod & SYNCHRONIZED) != 0; } >+ public static boolean isTransient (int mod) { return (mod & TRANSIENT) != 0; } >+ public static boolean isVolatile (int mod) { return (mod & VOLATILE) != 0; } >+ >+ private static String names[] = new String[] {"public", "protected", "private", "abstract", "static", "fina", "transient", "volatile", "synchronized", "native", "strictfp", "interface"}; >+ private static int values[] = new int[] {PUBLIC, PROTECTED, PRIVATE, ABSTRACT, STATIC, FINAL, TRANSIENT, VOLATILE, SYNCHRONIZED, NATIVE, STRICT, INTERFACE}; >+ >+ public static String toString (int mod) { >+ StringBuffer ret = new StringBuffer (); >+ for (int i=0;i<values.length;i++) { >+ if ((mod & i) != 0) { >+ if (ret.length () > 0) >+ ret.append (" "); >+ ret.append(names[i]); >+ } >+ } >+ return ret.toString (); >+ } >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 92933
: 20502