aboutsummaryrefslogtreecommitdiffstats
path: root/org.aspectj.ajdt.core
diff options
context:
space:
mode:
authorAndy Clement <aclement@pivotal.io>2018-02-14 13:03:24 -0800
committerAndy Clement <aclement@pivotal.io>2018-02-14 13:03:24 -0800
commit53262b4d0ba9b01de0979fca222838dd846396e9 (patch)
tree509001274b3c0c86f22ff303554e6be576e3614d /org.aspectj.ajdt.core
parenta5495d637c74706d61e42d64db9c09cd474ba729 (diff)
downloadaspectj-53262b4d0ba9b01de0979fca222838dd846396e9.tar.gz
aspectj-53262b4d0ba9b01de0979fca222838dd846396e9.zip
better handling of modules
Diffstat (limited to 'org.aspectj.ajdt.core')
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildConfig.java17
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java42
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjState.java21
3 files changed, 67 insertions, 13 deletions
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildConfig.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildConfig.java
index 0587c4462..be8f54adb 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildConfig.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildConfig.java
@@ -1,5 +1,5 @@
/* *******************************************************************
- * Copyright (c) 2002 - 2014 Contributors
+ * Copyright (c) 2002 - 2018 Contributors
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Eclipse Public License v1.0
@@ -30,19 +30,10 @@ import java.util.StringTokenizer;
import org.aspectj.ajdt.ajc.BuildArgParser;
import org.aspectj.ajdt.internal.compiler.CompilationResultDestinationManager;
-import org.aspectj.org.eclipse.jdt.internal.compiler.IErrorHandlingPolicy;
-import org.aspectj.org.eclipse.jdt.internal.compiler.batch.ClasspathJar;
-import org.aspectj.org.eclipse.jdt.internal.compiler.batch.ClasspathJrt;
import org.aspectj.org.eclipse.jdt.internal.compiler.batch.ClasspathLocation;
import org.aspectj.org.eclipse.jdt.internal.compiler.batch.FileSystem;
-import org.aspectj.org.eclipse.jdt.internal.compiler.batch.Main;
-import org.aspectj.org.eclipse.jdt.internal.compiler.batch.ModuleFinder;
import org.aspectj.org.eclipse.jdt.internal.compiler.batch.FileSystem.Classpath;
-import org.aspectj.org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
import org.aspectj.org.eclipse.jdt.internal.compiler.env.IModule;
-import org.aspectj.org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
-import org.aspectj.org.eclipse.jdt.internal.compiler.parser.Parser;
-import org.aspectj.org.eclipse.jdt.internal.compiler.problem.ProblemReporter;
import org.aspectj.util.FileUtil;
/**
@@ -102,6 +93,7 @@ public class AjBuildConfig implements CompilerConfigurationChangeFlags {
private boolean incrementalMode;
private File incrementalFile;
+ @Override
public String toString() {
StringBuffer sb = new StringBuffer();
sb.append("BuildConfig[" + (configFile == null ? "null" : configFile.getAbsoluteFile().toString()) + "] #Files="
@@ -118,6 +110,7 @@ public class AjBuildConfig implements CompilerConfigurationChangeFlags {
public File fromInPathDirectory;
public File binSrc;
+ @Override
public boolean equals(Object obj) {
if (obj != null && (obj instanceof BinarySourceFile)) {
BinarySourceFile other = (BinarySourceFile) obj;
@@ -126,6 +119,7 @@ public class AjBuildConfig implements CompilerConfigurationChangeFlags {
return false;
}
+ @Override
public int hashCode() {
return binSrc != null ? binSrc.hashCode() : 0;
}
@@ -325,6 +319,7 @@ public class AjBuildConfig implements CompilerConfigurationChangeFlags {
// remember all the class files in directories on the inpath
binaryFiles = new ArrayList<BinarySourceFile>();
FileFilter filter = new FileFilter() {
+ @Override
public boolean accept(File pathname) {
return pathname.getPath().endsWith(".class");
}
@@ -927,7 +922,7 @@ public class AjBuildConfig implements CompilerConfigurationChangeFlags {
// This is similar to the calculation done in Main.setPaths() but it isn't as sophisticated
- // as that one (doesn't need to be) and it also considers the additional paths for an
+ // as that one (doesn't need to be) and it also considers the additional paths for an
// AspectJ project (aspectpath/inpath/injars)
private void computeCheckedClasspath() {
// Follow what we do in getFullClasspath():
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 b81e8ed4b..975235918 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
@@ -61,6 +61,7 @@ import org.aspectj.bridge.ILifecycleAware;
import org.aspectj.bridge.IMessage;
import org.aspectj.bridge.IMessageHandler;
import org.aspectj.bridge.IProgressListener;
+import org.aspectj.bridge.ISourceLocation;
import org.aspectj.bridge.Message;
import org.aspectj.bridge.MessageUtil;
import org.aspectj.bridge.SourceLocation;
@@ -78,6 +79,7 @@ import org.aspectj.org.eclipse.jdt.internal.compiler.IProblemFactory;
import org.aspectj.org.eclipse.jdt.internal.compiler.batch.ClasspathLocation;
import org.aspectj.org.eclipse.jdt.internal.compiler.batch.CompilationUnit;
import org.aspectj.org.eclipse.jdt.internal.compiler.batch.FileSystem;
+import org.aspectj.org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
import org.aspectj.org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
import org.aspectj.org.eclipse.jdt.internal.compiler.env.IModule;
import org.aspectj.org.eclipse.jdt.internal.compiler.env.INameEnvironment;
@@ -107,6 +109,7 @@ public class AjBuildManager implements IOutputClassFileNameProvider, IBinarySour
static final boolean FAIL_IF_RUNTIME_NOT_FOUND = false;
private static final FileFilter binarySourceFilter = new FileFilter() {
+ @Override
public boolean accept(File f) {
return f.getName().endsWith(".class");
}
@@ -509,6 +512,7 @@ public class AjBuildManager implements IOutputClassFileNameProvider, IBinarySour
}
// Get a list of all files (i.e. everything that isnt a directory)
File[] files = FileUtil.listFiles(dir, new FileFilter() {
+ @Override
public boolean accept(File f) {
boolean accept = !(f.isDirectory() || f.getName().endsWith(".class"));
return accept;
@@ -1046,7 +1050,9 @@ public class AjBuildManager implements IOutputClassFileNameProvider, IBinarySour
for (int i = 0; i < cps.size(); i++) {
classpaths[i] = cps.get(i);
}
- environment = new StatefulNameEnvironment(getLibraryAccess(classpaths, filenames), state.getClassNameToFileMap(), state);
+ FileSystem fileSystem = getLibraryAccess(classpaths, filenames);
+ environment = new StatefulNameEnvironment(fileSystem, state.getClassNameToFileMap(), state);
+ state.setFileSystem(fileSystem);
state.setNameEnvironment(environment);
} else {
((StatefulNameEnvironment) environment).update(state.getClassNameToFileMap(), state.deltaAddedClasses);
@@ -1064,6 +1070,33 @@ public class AjBuildManager implements IOutputClassFileNameProvider, IBinarySour
bMain.batchCompiler = compiler;
bMain.initializeAnnotationProcessorManager();
compiler.options.produceReferenceInfo = true; // TODO turn off when not needed
+
+
+ if (bMain.compilerOptions.complianceLevel >= ClassFileConstants.JDK1_6
+ && bMain.compilerOptions.processAnnotations) {
+ // need this too?
+// if (bMain.checkVMVersion(ClassFileConstants.JDK1_6)) {
+// initializeAnnotationProcessorManager();
+// if (this.classNames != null) {
+// this.batchCompiler.setBinaryTypes(processClassNames(this.batchCompiler.lookupEnvironment));
+// }
+// } else {
+// // report a warning
+// this.logger.logIncorrectVMVersionForAnnotationProcessing();
+// }
+ if (bMain.checkVMVersion(ClassFileConstants.JDK9)) {
+ try {
+ bMain.initRootModules(bMain.batchCompiler.lookupEnvironment, state.getFileSystem());
+ } catch (IllegalArgumentException iae) {
+ ISourceLocation location = null;
+ if (buildConfig.getConfigFile() != null) {
+ location = new SourceLocation(buildConfig.getConfigFile(), 0);
+ }
+ IMessage m = new Message(iae.getMessage(), IMessage.ERROR, null, location);
+ handler.handleMessage(m);
+ }
+ }
+ }
try {
compiler.compile(getCompilationUnits(filenames));
@@ -1090,6 +1123,7 @@ public class AjBuildManager implements IOutputClassFileNameProvider, IBinarySour
*/
public IIntermediateResultsRequestor getInterimResultRequestor() {
return new IIntermediateResultsRequestor() {
+ @Override
public void acceptResult(InterimCompilationResult result) {
if (progressListener != null) {
compiledCount++;
@@ -1107,6 +1141,7 @@ public class AjBuildManager implements IOutputClassFileNameProvider, IBinarySour
public ICompilerRequestor getBatchRequestor() {
return new ICompilerRequestor() {
+ @Override
public void acceptResult(CompilationResult unitResult) {
// end of compile, must now write the results to the output destination
// this is either a jar file or a file in a directory
@@ -1351,6 +1386,7 @@ public class AjBuildManager implements IOutputClassFileNameProvider, IBinarySour
return "couldn't find aspectjrt.jar on classpath, checked: " + makeClasspathString(buildConfig);
}
+ @Override
public String toString() {
StringBuffer buf = new StringBuffer();
buf.append("AjBuildManager(");
@@ -1383,6 +1419,7 @@ public class AjBuildManager implements IOutputClassFileNameProvider, IBinarySour
*
* @see org.aspectj.ajdt.internal.compiler.AjCompiler.IOutputClassFileNameProvider#getOutputClassFileName(char[])
*/
+ @Override
public String getOutputClassFileName(char[] eclipseClassFileName, CompilationResult result) {
String filename = new String(eclipseClassFileName);
filename = filename.replace('/', File.separatorChar) + ".class";
@@ -1406,6 +1443,7 @@ public class AjBuildManager implements IOutputClassFileNameProvider, IBinarySour
*
* @see org.eclipse.jdt.internal.compiler.ICompilerAdapterFactory#getAdapter(org.eclipse.jdt.internal.compiler.Compiler)
*/
+ @Override
public ICompilerAdapter getAdapter(org.aspectj.org.eclipse.jdt.internal.compiler.Compiler forCompiler) {
// complete compiler config and return a suitable adapter...
populateCompilerOptionsFromLintSettings(forCompiler);
@@ -1460,6 +1498,7 @@ public class AjBuildManager implements IOutputClassFileNameProvider, IBinarySour
*
* @see org.aspectj.ajdt.internal.compiler.IBinarySourceProvider#getBinarySourcesForThisWeave()
*/
+ @Override
public Map<String, List<UnwovenClassFile>> getBinarySourcesForThisWeave() {
return binarySourcesForTheNextCompile;
}
@@ -1485,6 +1524,7 @@ public class AjBuildManager implements IOutputClassFileNameProvider, IBinarySour
private static class AjBuildContexFormatter implements ContextFormatter {
+ @Override
public String formatEntry(int phaseId, Object data) {
StringBuffer sb = new StringBuffer();
if (phaseId == CompilationAndWeavingContext.BATCH_BUILD) {
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 965e87732..8014e5ff7 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
@@ -35,7 +35,6 @@ import java.util.Set;
import org.aspectj.ajdt.internal.compiler.CompilationResultDestinationManager;
import org.aspectj.ajdt.internal.compiler.InterimCompilationResult;
-import org.aspectj.ajdt.internal.compiler.lookup.AjLookupEnvironment;
import org.aspectj.ajdt.internal.core.builder.AjBuildConfig.BinarySourceFile;
import org.aspectj.apache.bcel.classfile.ClassParser;
import org.aspectj.asm.AsmManager;
@@ -44,6 +43,7 @@ import org.aspectj.bridge.Message;
import org.aspectj.bridge.SourceLocation;
import org.aspectj.org.eclipse.jdt.core.compiler.CharOperation;
import org.aspectj.org.eclipse.jdt.internal.compiler.CompilationResult;
+import org.aspectj.org.eclipse.jdt.internal.compiler.batch.FileSystem;
import org.aspectj.org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader;
import org.aspectj.org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException;
import org.aspectj.org.eclipse.jdt.internal.compiler.env.IBinaryAnnotation;
@@ -117,6 +117,7 @@ public class AjState implements CompilerConfigurationChangeFlags, TypeDelegateRe
private final AjBuildManager buildManager;
private INameEnvironment nameEnvironment;
+ private FileSystem fileSystem;
// now follows normal state that must be written out
@@ -663,6 +664,7 @@ public class AjState implements CompilerConfigurationChangeFlags, TypeDelegateRe
}
}
+ @Override
public Object get(Object key) {
SoftReferenceKnownKey value = (SoftReferenceKnownKey) map.get(key);
if (value == null) {
@@ -677,25 +679,30 @@ public class AjState implements CompilerConfigurationChangeFlags, TypeDelegateRe
}
}
+ @Override
public Object put(Object k, Object v) {
processQueue();
return map.put(k, new SoftReferenceKnownKey(k, v));
}
+ @Override
public Set entrySet() {
return map.entrySet();
}
+ @Override
public void clear() {
processQueue();
map.clear();
}
+ @Override
public int size() {
processQueue();
return map.size();
}
+ @Override
public Object remove(Object k) {
processQueue();
SoftReferenceKnownKey value = (SoftReferenceKnownKey) map.remove(k);
@@ -797,6 +804,7 @@ public class AjState implements CompilerConfigurationChangeFlags, TypeDelegateRe
// return null;
// }
+ @Override
public String toString() {
StringBuffer sb = new StringBuffer();
// null config means failed build i think as it is only set on successful full build?
@@ -2445,6 +2453,7 @@ public class AjState implements CompilerConfigurationChangeFlags, TypeDelegateRe
this.locationOnDisk = location;
}
+ @Override
public String toString() {
StringBuilder s = new StringBuilder();
s.append("ClassFile(type=").append(fullyQualifiedTypeName).append(",location=").append(locationOnDisk).append(")");
@@ -2458,6 +2467,7 @@ public class AjState implements CompilerConfigurationChangeFlags, TypeDelegateRe
File dir = locationOnDisk.getParentFile();
if (dir != null) {
File[] weaverGenerated = dir.listFiles(new FilenameFilter() {
+ @Override
public boolean accept(File dir, String name) {
return name.startsWith(targetPrefix);
}
@@ -2518,6 +2528,14 @@ public class AjState implements CompilerConfigurationChangeFlags, TypeDelegateRe
this.nameEnvironment = nameEnvironment;
}
+ public FileSystem getFileSystem() {
+ return this.fileSystem;
+ }
+
+ public void setFileSystem(FileSystem fileSystem) {
+ this.fileSystem = fileSystem;
+ }
+
/**
* Record an aspect that came in on the aspect path. When a .class file changes on the aspect path we can then recognize it as
* an aspect and know to do more than just a tiny incremental build. <br>
@@ -2540,6 +2558,7 @@ public class AjState implements CompilerConfigurationChangeFlags, TypeDelegateRe
/**
* See if we can create a delegate from a CompactTypeStructure - TODO better comment
*/
+ @Override
public ReferenceTypeDelegate getDelegate(ReferenceType referenceType) {
File f = classesFromName.get(referenceType.getName());
if (f == null) {