/* *******************************************************************
- * 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
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;
/**
private boolean incrementalMode;
private File incrementalFile;
+ @Override
public String toString() {
StringBuffer sb = new StringBuffer();
sb.append("BuildConfig[" + (configFile == null ? "null" : configFile.getAbsoluteFile().toString()) + "] #Files="
public File fromInPathDirectory;
public File binSrc;
+ @Override
public boolean equals(Object obj) {
if (obj != null && (obj instanceof BinarySourceFile)) {
BinarySourceFile other = (BinarySourceFile) obj;
return false;
}
+ @Override
public int hashCode() {
return binSrc != null ? binSrc.hashCode() : 0;
}
// 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");
}
// 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():
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;
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;
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");
}
}
// 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;
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);
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));
*/
public IIntermediateResultsRequestor getInterimResultRequestor() {
return new IIntermediateResultsRequestor() {
+ @Override
public void acceptResult(InterimCompilationResult result) {
if (progressListener != null) {
compiledCount++;
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
return "couldn't find aspectjrt.jar on classpath, checked: " + makeClasspathString(buildConfig);
}
+ @Override
public String toString() {
StringBuffer buf = new StringBuffer();
buf.append("AjBuildManager(");
*
* @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";
*
* @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);
*
* @see org.aspectj.ajdt.internal.compiler.IBinarySourceProvider#getBinarySourcesForThisWeave()
*/
+ @Override
public Map<String, List<UnwovenClassFile>> getBinarySourcesForThisWeave() {
return binarySourcesForTheNextCompile;
}
private static class AjBuildContexFormatter implements ContextFormatter {
+ @Override
public String formatEntry(int phaseId, Object data) {
StringBuffer sb = new StringBuffer();
if (phaseId == CompilationAndWeavingContext.BATCH_BUILD) {
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;
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;
private final AjBuildManager buildManager;
private INameEnvironment nameEnvironment;
+ private FileSystem fileSystem;
// now follows normal state that must be written out
}
}
+ @Override
public Object get(Object key) {
SoftReferenceKnownKey value = (SoftReferenceKnownKey) map.get(key);
if (value == null) {
}
}
+ @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);
// 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?
this.locationOnDisk = location;
}
+ @Override
public String toString() {
StringBuilder s = new StringBuilder();
s.append("ClassFile(type=").append(fullyQualifiedTypeName).append(",location=").append(locationOnDisk).append(")");
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);
}
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>
/**
* 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) {