From: aclement Date: Tue, 13 May 2008 17:40:13 +0000 (+0000) Subject: 231396: refactoring: removed WeaverMetrics/LTWeaver, changed UnwovenClassFile to... X-Git-Tag: V1_6_1x~37 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=73f8338a1cc6a329b3e3a1738cda25bc07723197;p=aspectj.git 231396: refactoring: removed WeaverMetrics/LTWeaver, changed UnwovenClassFile to have a char array name and use that when possible --- diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/InterimCompilationResult.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/InterimCompilationResult.java index 0319a240c..8111238c7 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/InterimCompilationResult.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/InterimCompilationResult.java @@ -40,7 +40,7 @@ public class InterimCompilationResult { for (int i=0; i < ucfList.size(); i++) { UnwovenClassFile element = (UnwovenClassFile) ucfList.get(i); unwovenClassFiles[i] = element; - AjClassFile ajcf = new AjClassFile(element.getClassName().replace('.', '/').toCharArray(), + AjClassFile ajcf = new AjClassFile(element.getClassNameAsChars(), element.getBytes()); result.record(ajcf.fileName(),ajcf); } diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/WeaverAdapter.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/WeaverAdapter.java index 6ec34ab77..6d1e267d6 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/WeaverAdapter.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/WeaverAdapter.java @@ -13,6 +13,8 @@ package org.aspectj.ajdt.internal.compiler; import java.util.Iterator; import java.util.Map; +import org.aspectj.asm.internal.CharOperation; +import org.aspectj.bridge.IMessage; import org.aspectj.bridge.IProgressListener; import org.aspectj.bridge.MessageUtil; import org.aspectj.org.eclipse.jdt.internal.compiler.problem.AbortCompilation; @@ -170,6 +172,7 @@ public class WeaverAdapter implements IClassFileProvider, IWeaveRequestor, Itera if ((lastReturnedResult != null) && (!lastReturnedResult.result().hasBeenAccepted)) { finishedWith(lastReturnedResult); } + lastReturnedResult=null; } @@ -178,30 +181,29 @@ public class WeaverAdapter implements IClassFileProvider, IWeaveRequestor, Itera * @see org.aspectj.weaver.IWeaveRequestor#acceptResult(org.aspectj.weaver.bcel.UnwovenClassFile) */ public void acceptResult(UnwovenClassFile result) { - char[] key = result.getClassName().replace('.','/').toCharArray(); - removeFromMap(lastReturnedResult.result().compiledTypes,key); - String className = result.getClassName().replace('.', '/'); - AjClassFile ajcf = new AjClassFile(className.toCharArray(), - result.getBytes()); + char[] key = result.getClassNameAsChars(); + removeFromMap(lastReturnedResult.result().compiledTypes, key); + AjClassFile ajcf = new AjClassFile(key, result.getBytes()); lastReturnedResult.result().record(ajcf.fileName(),ajcf); - //System.err.println(progressPhasePrefix+result.getClassName()+" (from "+nowProcessing.fileName()+")"); - StringBuffer msg = new StringBuffer(); - msg.append(progressPhasePrefix).append(result.getClassName()).append(" (from ").append(nowProcessing.fileName()).append(")"); - weaverMessageHandler.handleMessage(MessageUtil.info(msg.toString())); - if (progressListener != null) { - progressCompletionCount++; - - // Smoothly take progress from 'fromPercent' to 'toPercent' - recordProgress( - fromPercent - +((progressCompletionCount/(double)progressMaxTypes)*(toPercent-fromPercent)), - msg.toString()); - // progressPhasePrefix+result.getClassName()+" (from "+nowProcessing.fileName()+")"); - - if (progressListener.isCancelledRequested()) { - throw new AbortCompilation(true,new OperationCanceledException("Weaving cancelled as requested")); + if (!weaverMessageHandler.isIgnoring(IMessage.INFO) || progressListener!=null) { + StringBuffer msg = new StringBuffer(); + msg.append(progressPhasePrefix).append(result.getClassName()).append(" (from ").append(nowProcessing.fileName()).append(")"); + weaverMessageHandler.handleMessage(MessageUtil.info(msg.toString())); + if (progressListener != null) { + progressCompletionCount++; + + // Smoothly take progress from 'fromPercent' to 'toPercent' + recordProgress( + fromPercent + +((progressCompletionCount/(double)progressMaxTypes)*(toPercent-fromPercent)), + msg.toString()); + // progressPhasePrefix+result.getClassName()+" (from "+nowProcessing.fileName()+")"); + + if (progressListener.isCancelledRequested()) { + throw new AbortCompilation(true,new OperationCanceledException("Weaving cancelled as requested")); + } } - } + } } // helpers... @@ -211,21 +213,28 @@ public class WeaverAdapter implements IClassFileProvider, IWeaveRequestor, Itera compilerAdapter.acceptResult(result.result()); } - private void removeFromMap(Map aMap, char[] key) { + private boolean removeFromMap(Map aMap, char[] key) { // jdt uses char[] as a key in the hashtable, which is not very useful as equality is based on being // the same array, not having the same content. - String skey = new String(key); +// String skey = new String(key); + // OPTIMIZE what is this code for? + if (aMap.remove(key)!=null) { + return true; + } char[] victim = null; for (Iterator iter = aMap.keySet().iterator(); iter.hasNext();) { char[] thisKey = (char[]) iter.next(); - if (skey.equals(new String(thisKey))) { + if (CharOperation.equals(thisKey,key)) { +// if (skey.equals(new String(thisKey))) { victim = thisKey; break; } } if (victim != null) { aMap.remove(victim); + return true; } + return false; } private void recordProgress(String message) {