]> source.dussan.org Git - aspectj.git/commitdiff
278496: type demotion, complete!
authoraclement <aclement>
Wed, 4 Aug 2010 19:26:13 +0000 (19:26 +0000)
committeraclement <aclement>
Wed, 4 Aug 2010 19:26:13 +0000 (19:26 +0000)
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjState.java

index 7437838197c3262a4be3be1274dc0a21782f1b35..ee6f8dd0a2e76eeb923ee76d5e35798647ec6db5 100644 (file)
@@ -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<ClassFile> classFiles = unitResult.compiledTypes.values();
                                        boolean shouldAddAspectName = (buildConfig.getOutxmlName() != null);
-                                       for (Iterator iter = classFiles.iterator(); iter.hasNext();) {
-                                               ClassFile classFile = (ClassFile) iter.next();
+                                       for (Iterator<ClassFile> 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);
index ec69a49eb3bac61354732b798c469804b98b7786..e143c8aa070c0503f0d12c2ef393855ba450d1e7 100644 (file)
@@ -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;
+       }
 }