From d45da121a741668b70692c171623cce460dc62d9 Mon Sep 17 00:00:00 2001 From: aclement Date: Wed, 4 Aug 2010 19:26:13 +0000 Subject: [PATCH] 278496: type demotion, complete! --- .../internal/core/builder/AjBuildManager.java | 7 +++--- .../ajdt/internal/core/builder/AjState.java | 25 ++++++++++++++++++- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java index 743783819..ee6f8dd0a 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java @@ -1063,10 +1063,10 @@ public class AjBuildManager implements IOutputClassFileNameProvider, IBinarySour // this is either a jar file or a file in a directory boolean hasErrors = unitResult.hasErrors(); if (!hasErrors || proceedOnError()) { - Collection classFiles = unitResult.compiledTypes.values(); + Collection classFiles = unitResult.compiledTypes.values(); boolean shouldAddAspectName = (buildConfig.getOutxmlName() != null); - for (Iterator iter = classFiles.iterator(); iter.hasNext();) { - ClassFile classFile = (ClassFile) iter.next(); + for (Iterator iter = classFiles.iterator(); iter.hasNext();) { + ClassFile classFile = iter.next(); String filename = new String(classFile.fileName()); String classname = filename.replace('/', '.'); filename = filename.replace('/', File.separatorChar) + ".class"; @@ -1074,6 +1074,7 @@ public class AjBuildManager implements IOutputClassFileNameProvider, IBinarySour try { if (buildConfig.getOutputJar() == null) { String outfile = writeDirectoryEntry(unitResult, classFile, filename); + getWorld().classWriteEvent(classFile.getCompoundName()); if (environmentSupportsIncrementalCompilation) { if (!classname.endsWith("$ajcMightHaveAspect")) { ResolvedType type = getBcelWorld().resolve(classname); diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjState.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjState.java index ec69a49eb..e143c8aa0 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjState.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjState.java @@ -34,6 +34,7 @@ import java.util.Set; import org.aspectj.ajdt.internal.compiler.CompilationResultDestinationManager; import org.aspectj.ajdt.internal.compiler.InterimCompilationResult; import org.aspectj.ajdt.internal.core.builder.AjBuildConfig.BinarySourceFile; +import org.aspectj.apache.bcel.classfile.ClassParser; import org.aspectj.asm.AsmManager; import org.aspectj.bridge.IMessage; import org.aspectj.bridge.Message; @@ -54,15 +55,18 @@ import org.aspectj.org.eclipse.jdt.internal.core.builder.StringSet; import org.aspectj.util.FileUtil; import org.aspectj.weaver.BCException; import org.aspectj.weaver.CompressingDataOutputStream; +import org.aspectj.weaver.ReferenceType; +import org.aspectj.weaver.ReferenceTypeDelegate; import org.aspectj.weaver.ResolvedType; import org.aspectj.weaver.bcel.BcelWeaver; import org.aspectj.weaver.bcel.BcelWorld; +import org.aspectj.weaver.bcel.TypeDelegateResolver; import org.aspectj.weaver.bcel.UnwovenClassFile; /** * Maintains state needed for incremental compilation */ -public class AjState implements CompilerConfigurationChangeFlags { +public class AjState implements CompilerConfigurationChangeFlags, TypeDelegateResolver { // SECRETAPI configures whether we use state instead of lastModTime - see pr245566 public static boolean CHECK_STATE_FIRST = true; @@ -1935,6 +1939,7 @@ public class AjState implements CompilerConfigurationChangeFlags { public void setWorld(BcelWorld bw) { world = bw; + world.addTypeDelegateResolver(this); } public BcelWorld getBcelWorld() { @@ -2133,4 +2138,22 @@ public class AjState implements CompilerConfigurationChangeFlags { // model // local state } + + /** + * See if we can create a delegate from a CompactTypeStructure - TODO better comment + */ + public ReferenceTypeDelegate getDelegate(ReferenceType referenceType) { + File f = classesFromName.get(referenceType.getName()); + if (f == null) { + return null; // not heard of it + } + try { + ClassParser parser = new ClassParser(f.toString()); + return world.buildBcelDelegate(referenceType, parser.parse(), true, false); + } catch (IOException e) { + System.err.println("Failed to recover "+referenceType); + e.printStackTrace(); + } + return null; + } } -- 2.39.5