From f30275711ef5d5a4d452aab2959c5d27e1f11e90 Mon Sep 17 00:00:00 2001 From: aclement Date: Wed, 14 Jul 2010 23:20:00 +0000 Subject: [PATCH] generics --- .../context/CompilationAndWeavingContext.java | 37 ++++++++++--------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/bridge/src/org/aspectj/bridge/context/CompilationAndWeavingContext.java b/bridge/src/org/aspectj/bridge/context/CompilationAndWeavingContext.java index 1df076b11..f011572d9 100644 --- a/bridge/src/org/aspectj/bridge/context/CompilationAndWeavingContext.java +++ b/bridge/src/org/aspectj/bridge/context/CompilationAndWeavingContext.java @@ -14,7 +14,6 @@ package org.aspectj.bridge.context; import java.lang.ref.WeakReference; import java.util.Collections; import java.util.HashMap; -import java.util.Iterator; import java.util.Map; import java.util.Stack; @@ -89,13 +88,14 @@ public class CompilationAndWeavingContext { "type munging for @AspectJ aspectOf" }; // context stacks, one per thread - private static Map contextMap = Collections.synchronizedMap(new HashMap()); + private static Map> contextMap = Collections + .synchronizedMap(new HashMap>()); // single thread mode stack - private static Stack contextStack = new Stack(); + private static Stack contextStack = new Stack(); // formatters, by phase id - private static Map formatterMap = new HashMap(); + private static Map formatterMap = new HashMap(); private static ContextFormatter defaultFormatter = new DefaultFormatter(); @@ -132,10 +132,9 @@ public class CompilationAndWeavingContext { * Returns a string description of what the compiler/weaver is currently doing */ public static String getCurrentContext() { - Stack contextStack = getContextStack(); - Stack explanationStack = new Stack(); - for (Iterator iter = contextStack.iterator(); iter.hasNext();) { - ContextStackEntry entry = (ContextStackEntry) iter.next(); + Stack contextStack = getContextStack(); + Stack explanationStack = new Stack(); + for (ContextStackEntry entry : contextStack) { Object data = entry.getData(); if (data != null) { explanationStack.push(getFormatter(entry).formatEntry(entry.phaseId, data)); @@ -151,9 +150,9 @@ public class CompilationAndWeavingContext { } public static ContextToken enteringPhase(int phaseId, Object data) { - Stack contextStack = getContextStack(); + Stack contextStack = getContextStack(); ContextTokenImpl nextToken = nextToken(); - contextStack.push(new ContextStackEntry(nextToken, phaseId, new WeakReference(data))); + contextStack.push(new ContextStackEntry(nextToken, phaseId, new WeakReference(data))); return nextToken; } @@ -164,8 +163,9 @@ public class CompilationAndWeavingContext { Stack contextStack = getContextStack(); while (!contextStack.isEmpty()) { ContextStackEntry entry = (ContextStackEntry) contextStack.pop(); - if (entry.contextToken == aToken) + if (entry.contextToken == aToken) { break; + } } } @@ -173,18 +173,19 @@ public class CompilationAndWeavingContext { * Forget about the context for the current thread */ public static void resetForThread() { - if (!multiThreaded) + if (!multiThreaded) { return; + } contextMap.remove(Thread.currentThread()); } - private static Stack getContextStack() { + private static Stack getContextStack() { if (!multiThreaded) { return contextStack; } else { - Stack contextStack = (Stack) contextMap.get(Thread.currentThread()); + Stack contextStack = contextMap.get(Thread.currentThread()); if (contextStack == null) { - contextStack = new Stack(); + contextStack = new Stack(); contextMap.put(Thread.currentThread(), contextStack); } return contextStack; @@ -198,7 +199,7 @@ public class CompilationAndWeavingContext { private static ContextFormatter getFormatter(ContextStackEntry entry) { Integer key = new Integer(entry.phaseId); if (formatterMap.containsKey(key)) { - return (ContextFormatter) formatterMap.get(key); + return formatterMap.get(key); } else { return defaultFormatter; } @@ -216,9 +217,9 @@ public class CompilationAndWeavingContext { private static class ContextStackEntry { public ContextTokenImpl contextToken; public int phaseId; - private WeakReference dataRef; + private WeakReference dataRef; - public ContextStackEntry(ContextTokenImpl ct, int phase, WeakReference data) { + public ContextStackEntry(ContextTokenImpl ct, int phase, WeakReference data) { this.contextToken = ct; this.phaseId = phase; this.dataRef = data; -- 2.39.5