Use the diamond operator where possibletags/V1_9_7M1
private UserPreferencesAdapter preferencesAdapter; | private UserPreferencesAdapter preferencesAdapter; | ||||
private static TopFrame topFrame = null; | private static TopFrame topFrame = null; | ||||
private List<String> configFiles = new ArrayList<String>(); | |||||
private List<String> configFiles = new ArrayList<>(); | |||||
private JavaBuildOptions javaBuildOptions; | private JavaBuildOptions javaBuildOptions; | ||||
public static BrowserManager getDefault() { | public static BrowserManager getDefault() { | ||||
} | } | ||||
private List<String> getConfigFilesList(String[] configFiles) { | private List<String> getConfigFilesList(String[] configFiles) { | ||||
List<String> configs = new ArrayList<String>(); | |||||
List<String> configs = new ArrayList<>(); | |||||
for (String configFile : configFiles) { | for (String configFile : configFiles) { | ||||
if (configFile.endsWith(BuildConfigManager.CONFIG_FILE_SUFFIX)) { | if (configFile.endsWith(BuildConfigManager.CONFIG_FILE_SUFFIX)) { | ||||
configs.add(configFile); | configs.add(configFile); |
} | } | ||||
public List<File> getAllOutputLocations() { | public List<File> getAllOutputLocations() { | ||||
List<File> outputDirs = new ArrayList<File>(); | |||||
List<File> outputDirs = new ArrayList<>(); | |||||
outputDirs.add(new File(getCommonOutputDir())); | outputDirs.add(new File(getCommonOutputDir())); | ||||
return outputDirs; | return outputDirs; | ||||
} | } |
private List<IMessage> messages; | private List<IMessage> messages; | ||||
public BrowserMessageHandler() { | public BrowserMessageHandler() { | ||||
ignoring = new ArrayList<IMessage.Kind>(); | |||||
messages = new ArrayList<IMessage>(); | |||||
ignoring = new ArrayList<>(); | |||||
messages = new ArrayList<>(); | |||||
ignore(IMessage.INFO); | ignore(IMessage.INFO); | ||||
ignore(IMessage.WEAVEINFO); | ignore(IMessage.WEAVEINFO); | ||||
} | } |
private EditorAdapter editor = null; | private EditorAdapter editor = null; | ||||
private BasicEditor basicEditor = null; | private BasicEditor basicEditor = null; | ||||
private ArrayList<EditorListener> editorListeners = new ArrayList<EditorListener>(); | |||||
private Vector<EditorAdapter> editors = new Vector<EditorAdapter>(); | |||||
private ArrayList<EditorListener> editorListeners = new ArrayList<>(); | |||||
private Vector<EditorAdapter> editors = new Vector<>(); | |||||
private JPanel editor_panel = null; | private JPanel editor_panel = null; | ||||
private Box editors_box = Box.createVerticalBox(); | private Box editors_box = Box.createVerticalBox(); | ||||
public static Map<String,String> getDefaultJavaOptions() { | public static Map<String,String> getDefaultJavaOptions() { | ||||
if (defaultOptionsMap != null) return defaultOptionsMap; | if (defaultOptionsMap != null) return defaultOptionsMap; | ||||
defaultOptionsMap = new HashMap<String,String>(); | |||||
defaultOptionsMap = new HashMap<>(); | |||||
defaultOptionsMap.put(COMPLIANCE_LEVEL, VERSION_14); | defaultOptionsMap.put(COMPLIANCE_LEVEL, VERSION_14); | ||||
defaultOptionsMap.put(SOURCE_COMPATIBILITY_LEVEL, VERSION_13); | defaultOptionsMap.put(SOURCE_COMPATIBILITY_LEVEL, VERSION_13); | ||||
defaultOptionsMap.put(PRESERVE_ALL_LOCALS, OPTIMIZE); | defaultOptionsMap.put(PRESERVE_ALL_LOCALS, OPTIMIZE); |
if (propcp != null && propcp.length() != 0) { | if (propcp != null && propcp.length() != 0) { | ||||
StringTokenizer st = new StringTokenizer(propcp, File.pathSeparator); | StringTokenizer st = new StringTokenizer(propcp, File.pathSeparator); | ||||
List<String> configClasspath = config.getClasspath(); | List<String> configClasspath = config.getClasspath(); | ||||
ArrayList<String> toAdd = new ArrayList<String>(); | |||||
ArrayList<String> toAdd = new ArrayList<>(); | |||||
while (st.hasMoreTokens()) { | while (st.hasMoreTokens()) { | ||||
String entry = st.nextToken(); | String entry = st.nextToken(); | ||||
if (!configClasspath.contains(entry)) { | if (!configClasspath.contains(entry)) { | ||||
} | } | ||||
} | } | ||||
if (0 < toAdd.size()) { | if (0 < toAdd.size()) { | ||||
ArrayList<String> both = new ArrayList<String>(configClasspath.size() + toAdd.size()); | |||||
ArrayList<String> both = new ArrayList<>(configClasspath.size() + toAdd.size()); | |||||
both.addAll(configClasspath); | both.addAll(configClasspath); | ||||
both.addAll(toAdd); | both.addAll(toAdd); | ||||
config.setClasspath(both); | config.setClasspath(both); | ||||
// Break a string into a string array of non-standard options. | // Break a string into a string array of non-standard options. | ||||
// Allows for one option to include a ' '. i.e. assuming it has been quoted, it | // Allows for one option to include a ' '. i.e. assuming it has been quoted, it | ||||
// won't accidentally get treated as a pair of options (can be needed for xlint props file option) | // won't accidentally get treated as a pair of options (can be needed for xlint props file option) | ||||
List<String> tokens = new ArrayList<String>(); | |||||
List<String> tokens = new ArrayList<>(); | |||||
int ind = nonStdOptions.indexOf('\"'); | int ind = nonStdOptions.indexOf('\"'); | ||||
int ind2 = nonStdOptions.indexOf('\"', ind + 1); | int ind2 = nonStdOptions.indexOf('\"', ind + 1); | ||||
if ((ind > -1) && (ind2 > -1)) { // dont tokenize within double quotes | if ((ind > -1) && (ind2 > -1)) { // dont tokenize within double quotes | ||||
/** Local helper method for splitting option strings */ | /** Local helper method for splitting option strings */ | ||||
private List<String> tokenizeString(String str) { | private List<String> tokenizeString(String str) { | ||||
List<String> tokens = new ArrayList<String>(); | |||||
List<String> tokens = new ArrayList<>(); | |||||
StringTokenizer tok = new StringTokenizer(str); | StringTokenizer tok = new StringTokenizer(str); | ||||
while (tok.hasMoreTokens()) { | while (tok.hasMoreTokens()) { | ||||
tokens.add(tok.nextToken()); | tokens.add(tok.nextToken()); |
} | } | ||||
public List<String> getSourceFileList(String[] files) { | public List<String> getSourceFileList(String[] files) { | ||||
List<String> sourceFiles = new ArrayList<String>(); | |||||
List<String> sourceFiles = new ArrayList<>(); | |||||
for (String file : files) { | for (String file : files) { | ||||
sourceFiles.add(getAbsoluteProjectDir() + File.separator + file); | sourceFiles.add(getAbsoluteProjectDir() + File.separator + file); | ||||
} | } |
private String programmableString; | private String programmableString; | ||||
private int count; | private int count; | ||||
private List<String> messagesReceived = new ArrayList<String>(); | |||||
private List<String> messagesReceived = new ArrayList<>(); | |||||
private int currentVal; | private int currentVal; | ||||
private boolean isCancelRequested = false; | private boolean isCancelRequested = false; | ||||
private String outjar; | private String outjar; | ||||
private Map<String, String> javaOptions; | private Map<String, String> javaOptions; | ||||
private String nonStandardOptions; | private String nonStandardOptions; | ||||
private List<String> projectSourceFiles = new ArrayList<String>(); | |||||
private List<String> projectSourceFiles = new ArrayList<>(); | |||||
private Map<String, File> sourcePathResources; | private Map<String, File> sourcePathResources; | ||||
private String srcDirName = "src"; | private String srcDirName = "src"; | ||||
public Map<String, String> getJavaOptionsMap() { | public Map<String, String> getJavaOptionsMap() { | ||||
if (javaOptions == null) { | if (javaOptions == null) { | ||||
javaOptions = new Hashtable<String, String>(); | |||||
javaOptions = new Hashtable<>(); | |||||
javaOptions.put(JavaOptions.COMPLIANCE_LEVEL, JavaOptions.VERSION_13); | javaOptions.put(JavaOptions.COMPLIANCE_LEVEL, JavaOptions.VERSION_13); | ||||
javaOptions.put(JavaOptions.SOURCE_COMPATIBILITY_LEVEL, JavaOptions.VERSION_13); | javaOptions.put(JavaOptions.SOURCE_COMPATIBILITY_LEVEL, JavaOptions.VERSION_13); | ||||
} | } | ||||
public Map<String, File> getSourcePathResources() { | public Map<String, File> getSourcePathResources() { | ||||
if (sourcePathResources == null) { | if (sourcePathResources == null) { | ||||
sourcePathResources = new HashMap<String, File>(); | |||||
sourcePathResources = new HashMap<>(); | |||||
/* Allow the user to override the testProjectPath by using sourceRoots */ | /* Allow the user to override the testProjectPath by using sourceRoots */ | ||||
File[] srcBase = new File[] { new File(projectPath + File.separator + srcDirName) }; | File[] srcBase = new File[] { new File(projectPath + File.separator + srcDirName) }; |
private List<TestMessage> errors; | private List<TestMessage> errors; | ||||
public TestMessageHandler() { | public TestMessageHandler() { | ||||
ignoring = new ArrayList<Kind>(); | |||||
messages = new ArrayList<TestMessage>(); | |||||
errors = new ArrayList<TestMessage>(); | |||||
ignoring = new ArrayList<>(); | |||||
messages = new ArrayList<>(); | |||||
errors = new ArrayList<>(); | |||||
ignore(IMessage.INFO); | ignore(IMessage.INFO); | ||||
ignore(IMessage.WEAVEINFO); | ignore(IMessage.WEAVEINFO); | ||||
} | } |
@Override | @Override | ||||
public List<File> getAllOutputLocations() { | public List<File> getAllOutputLocations() { | ||||
if (allOutputLocations == null) { | if (allOutputLocations == null) { | ||||
allOutputLocations = new ArrayList<File>(); | |||||
allOutputLocations = new ArrayList<>(); | |||||
initLocations(); | initLocations(); | ||||
allOutputLocations.add(classOutputLoc); | allOutputLocations.add(classOutputLoc); | ||||
if (!classOutputLoc.equals(resourceOutputLoc)) { | if (!classOutputLoc.equals(resourceOutputLoc)) { |
} | } | ||||
public void testAspectPath() { | public void testAspectPath() { | ||||
Set<File> aspects = new HashSet<File>(); | |||||
Set<File> aspects = new HashSet<>(); | |||||
compilerConfig.setAspectPath(aspects); | compilerConfig.setAspectPath(aspects); | ||||
AjBuildConfig buildConfig = genAjBuildConfig(); | AjBuildConfig buildConfig = genAjBuildConfig(); | ||||
List<File> aPath = buildConfig.getAspectpath(); | List<File> aPath = buildConfig.getAspectpath(); | ||||
} | } | ||||
public void testInpath() { | public void testInpath() { | ||||
Set<File> jars = new HashSet<File>(); | |||||
Set<File> jars = new HashSet<>(); | |||||
compilerConfig.setInpath(jars); | compilerConfig.setInpath(jars); | ||||
AjBuildConfig buildConfig = genAjBuildConfig(); | AjBuildConfig buildConfig = genAjBuildConfig(); | ||||
List<File> inJars = buildConfig.getInpath(); | List<File> inJars = buildConfig.getInpath(); | ||||
} | } | ||||
public void testSourcePathResources() { | public void testSourcePathResources() { | ||||
Map<String, File> m = new HashMap<String, File>(); | |||||
Map<String, File> m = new HashMap<>(); | |||||
m.put("newFile.txt", getWorkingDir()); | m.put("newFile.txt", getWorkingDir()); | ||||
compilerConfig.setSourcePathResources(m); | compilerConfig.setSourcePathResources(m); | ||||
AjBuildConfig buildConfig = genAjBuildConfig(); | AjBuildConfig buildConfig = genAjBuildConfig(); |
} | } | ||||
public void testWeave() { | public void testWeave() { | ||||
Set<File> injars = new HashSet<File>(); | |||||
Set<File> injars = new HashSet<>(); | |||||
injars.add(openFile(injarName)); | injars.add(openFile(injarName)); | ||||
compilerConfig.setInpath(injars); | compilerConfig.setInpath(injars); | ||||
Set<File> aspectpath = new HashSet<File>(); | |||||
Set<File> aspectpath = new HashSet<>(); | |||||
aspectpath.add(openFile(aspectjarName)); | aspectpath.add(openFile(aspectjarName)); | ||||
compilerConfig.setAspectPath(aspectpath); | compilerConfig.setAspectPath(aspectpath); | ||||
File outjar = openFile(outjarName); | File outjar = openFile(outjarName); |
* Expected result = output jar file contains contents of indir1 and class file for source that was in src | * Expected result = output jar file contains contents of indir1 and class file for source that was in src | ||||
*/ | */ | ||||
public void testInpathToOutjar() { | public void testInpathToOutjar() { | ||||
Set<File> inpath = new HashSet<File>(); | |||||
Set<File> inpath = new HashSet<>(); | |||||
File indir1 = openFile(indir1Name); | File indir1 = openFile(indir1Name); | ||||
inpath.add(indir1); | inpath.add(indir1); | ||||
compilerConfig.setInpath(inpath); | compilerConfig.setInpath(inpath); | ||||
doBuild(true); | doBuild(true); | ||||
assertTrue("Expected no compiler errors or warnings but found " + handler.getMessages(), handler.getMessages().isEmpty()); | assertTrue("Expected no compiler errors or warnings but found " + handler.getMessages(), handler.getMessages().isEmpty()); | ||||
Set<String> expectedOutputJarContents = new HashSet<String>(); | |||||
Set<String> expectedOutputJarContents = new HashSet<>(); | |||||
// From indir1 | // From indir1 | ||||
// If we don't copy resources, these next three files won't make it. | // If we don't copy resources, these next three files won't make it. | ||||
// expectedOutputJarContents.add("META-INF/MANIFEST.MF"); | // expectedOutputJarContents.add("META-INF/MANIFEST.MF"); | ||||
* | * | ||||
*/ | */ | ||||
public void testInpathToBin() { | public void testInpathToBin() { | ||||
Set<File> inpath = new HashSet<File>(); | |||||
Set<File> inpath = new HashSet<>(); | |||||
File indir1 = openFile(indir1Name); | File indir1 = openFile(indir1Name); | ||||
inpath.add(indir1); | inpath.add(indir1); | ||||
compilerConfig.setInpath(inpath); | compilerConfig.setInpath(inpath); | ||||
doBuild(true); | doBuild(true); | ||||
assertTrue("Expected no compiler errors or warnings but found " + handler.getMessages(), handler.getMessages().isEmpty()); | assertTrue("Expected no compiler errors or warnings but found " + handler.getMessages(), handler.getMessages().isEmpty()); | ||||
Set<String> expectedBindirContents = new HashSet<String>(); | |||||
Set<String> expectedBindirContents = new HashSet<>(); | |||||
// From indir1 | // From indir1 | ||||
// If we don't copy resources, these next three files won't make it | // If we don't copy resources, these next three files won't make it | ||||
// expectedBindirContents.add("META-INF/MANIFEST.MF"); | // expectedBindirContents.add("META-INF/MANIFEST.MF"); | ||||
* An extra check is done at the end of this test to verify that HelloWorld has changed size (due to the weaving). | * An extra check is done at the end of this test to verify that HelloWorld has changed size (due to the weaving). | ||||
*/ | */ | ||||
public void testInpathToOutjar2() { | public void testInpathToOutjar2() { | ||||
Set<File> inpath = new HashSet<File>(); | |||||
Set<File> inpath = new HashSet<>(); | |||||
File indir2 = openFile(indir2Name); | File indir2 = openFile(indir2Name); | ||||
inpath.add(indir2); | inpath.add(indir2); | ||||
compilerConfig.setInpath(inpath); | compilerConfig.setInpath(inpath); | ||||
doBuild(true); | doBuild(true); | ||||
assertTrue("Expected no compiler errors or warnings but found " + handler.getMessages(), handler.getMessages().isEmpty()); | assertTrue("Expected no compiler errors or warnings but found " + handler.getMessages(), handler.getMessages().isEmpty()); | ||||
Set<String> expectedOutputJarContents = new HashSet<String>(); | |||||
Set<String> expectedOutputJarContents = new HashSet<>(); | |||||
// From indir1 | // From indir1 | ||||
expectedOutputJarContents.add("example/HelloWorld.class"); | expectedOutputJarContents.add("example/HelloWorld.class"); | ||||
* | * | ||||
*/ | */ | ||||
public void testInpathAndInjarToBin() { | public void testInpathAndInjarToBin() { | ||||
Set<File> inpath = new HashSet<File>(); | |||||
Set<File> inpath = new HashSet<>(); | |||||
File indir2 = openFile(indir2Name); | File indir2 = openFile(indir2Name); | ||||
inpath.add(indir2); | inpath.add(indir2); | ||||
inpath.add(openFile(injarName)); | inpath.add(openFile(injarName)); | ||||
doBuild(true); | doBuild(true); | ||||
assertTrue("Expected no compiler errors or warnings but found " + handler.getMessages(), handler.getMessages().isEmpty()); | assertTrue("Expected no compiler errors or warnings but found " + handler.getMessages(), handler.getMessages().isEmpty()); | ||||
Set<String> expectedBindirContents = new HashSet<String>(); | |||||
Set<String> expectedBindirContents = new HashSet<>(); | |||||
// From indir1 | // From indir1 | ||||
expectedBindirContents.add("example/HelloWorld.class"); | expectedBindirContents.add("example/HelloWorld.class"); |
*/ | */ | ||||
public void testOutxmlToOutjarWithAop_xml () { | public void testOutxmlToOutjarWithAop_xml () { | ||||
File f = new File( getAbsoluteProjectDir() + File.separator + "src-resources" + File.separator + "testjar.jar"); | File f = new File( getAbsoluteProjectDir() + File.separator + "src-resources" + File.separator + "testjar.jar"); | ||||
Set<File> roots = new HashSet<File>(); | |||||
Set<File> roots = new HashSet<>(); | |||||
roots.add(f); | roots.add(f); | ||||
compilerConfig.setInpath(roots); | compilerConfig.setInpath(roots); | ||||
} | } | ||||
public void testInjarsToOutjar() { | public void testInjarsToOutjar() { | ||||
Set<File> injars = new HashSet<File>(); | |||||
Set<File> injars = new HashSet<>(); | |||||
File injar1 = openFile(injar1Name); | File injar1 = openFile(injar1Name); | ||||
injars.add(injar1); | injars.add(injar1); | ||||
compilerConfig.setInpath(injars); | compilerConfig.setInpath(injars); | ||||
} | } | ||||
public void testDuplicateResources() { | public void testDuplicateResources() { | ||||
Set<File> injars = new HashSet<File>(); | |||||
Set<File> injars = new HashSet<>(); | |||||
File injar1 = openFile(injar1Name); | File injar1 = openFile(injar1Name); | ||||
File injar2 = openFile(injar2Name); | File injar2 = openFile(injar2Name); | ||||
injars.add(injar1); | injars.add(injar1); | ||||
} | } | ||||
public void testInjarsToBin() { | public void testInjarsToBin() { | ||||
Set<File> injars = new HashSet<File>(); | |||||
Set<File> injars = new HashSet<>(); | |||||
File injar1 = openFile(injar1Name); | File injar1 = openFile(injar1Name); | ||||
injars.add(injar1); | injars.add(injar1); | ||||
compilerConfig.setInpath(injars); | compilerConfig.setInpath(injars); | ||||
// } | // } | ||||
public void testInjarsToOutjarOddNames() { | public void testInjarsToOutjarOddNames() { | ||||
Set<File> injars = new HashSet<File>(); | |||||
Set<File> injars = new HashSet<>(); | |||||
File injar1 = openFile("input1"); | File injar1 = openFile("input1"); | ||||
File outjar = openFile(outjarName + ".fozout"); | File outjar = openFile(outjarName + ".fozout"); | ||||
injars.add(injar1); | injars.add(injar1); |
Set<File> paths = new HashSet<>(); | Set<File> paths = new HashSet<>(); | ||||
paths.add(openFile(binDir)); | paths.add(openFile(binDir)); | ||||
compilerConfig.setInpath(paths); | compilerConfig.setInpath(paths); | ||||
compilerConfig.setProjectSourceFiles(new ArrayList<String>()); | |||||
compilerConfig.setProjectSourceFiles(new ArrayList<>()); | |||||
doBuild(true); | doBuild(true); | ||||
String expMessage = "aspect tjp.GetInfo cannot be found when reweaving tjp.Demo"; | String expMessage = "aspect tjp.GetInfo cannot be found when reweaving tjp.Demo"; | ||||
Set<File> paths = new HashSet<>(); | Set<File> paths = new HashSet<>(); | ||||
paths.add(openFile(binDir)); | paths.add(openFile(binDir)); | ||||
compilerConfig.setInpath(paths); | compilerConfig.setInpath(paths); | ||||
compilerConfig.setProjectSourceFiles(new ArrayList<String>()); | |||||
compilerConfig.setProjectSourceFiles(new ArrayList<>()); | |||||
doBuild(true); | doBuild(true); | ||||
String expMessage = "successfully verified type tjp.GetInfo exists"; | String expMessage = "successfully verified type tjp.GetInfo exists"; |
public void testWeaveMessagesBinaryAdvice() { | public void testWeaveMessagesBinaryAdvice() { | ||||
if (debugTests) | if (debugTests) | ||||
System.out.println("\ntestWeaveMessagesBinaryAdvice: Simple.jar + AspectAdvice.jar"); | System.out.println("\ntestWeaveMessagesBinaryAdvice: Simple.jar + AspectAdvice.jar"); | ||||
Set<File> inpath = new HashSet<File>(); | |||||
Set<File> inpath = new HashSet<>(); | |||||
inpath.add(openFile("Simple.jar")); | inpath.add(openFile("Simple.jar")); | ||||
compilerConfig.setInpath(inpath); | compilerConfig.setInpath(inpath); | ||||
Set<File> aspectpath = new HashSet<File>(); | |||||
Set<File> aspectpath = new HashSet<>(); | |||||
aspectpath.add(openFile("AspectAdvice.jar")); | aspectpath.add(openFile("AspectAdvice.jar")); | ||||
compilerConfig.setAspectPath(aspectpath); | compilerConfig.setAspectPath(aspectpath); | ||||
doBuild(); | doBuild(); | ||||
public void testWeaveMessagesBinaryITD() { | public void testWeaveMessagesBinaryITD() { | ||||
if (debugTests) | if (debugTests) | ||||
System.out.println("\ntestWeaveMessagesBinaryITD: Simple.jar + AspectITD.jar"); | System.out.println("\ntestWeaveMessagesBinaryITD: Simple.jar + AspectITD.jar"); | ||||
Set<File> inpath = new HashSet<File>(); | |||||
Set<File> inpath = new HashSet<>(); | |||||
inpath.add(openFile("Simple.jar")); | inpath.add(openFile("Simple.jar")); | ||||
compilerConfig.setInpath(inpath); | compilerConfig.setInpath(inpath); | ||||
Set<File> aspectpath = new HashSet<File>(); | |||||
Set<File> aspectpath = new HashSet<>(); | |||||
aspectpath.add(openFile("AspectITD.jar")); | aspectpath.add(openFile("AspectITD.jar")); | ||||
compilerConfig.setAspectPath(aspectpath); | compilerConfig.setAspectPath(aspectpath); | ||||
doBuild(); | doBuild(); | ||||
public void testWeaveMessagesBinaryDeclare() { | public void testWeaveMessagesBinaryDeclare() { | ||||
if (debugTests) | if (debugTests) | ||||
System.out.println("\ntestWeaveMessagesBinaryDeclare: Simple.jar + AspectDeclare.jar"); | System.out.println("\ntestWeaveMessagesBinaryDeclare: Simple.jar + AspectDeclare.jar"); | ||||
Set<File> inpath = new HashSet<File>(); | |||||
Set<File> inpath = new HashSet<>(); | |||||
inpath.add(openFile("Simple.jar")); | inpath.add(openFile("Simple.jar")); | ||||
compilerConfig.setInpath(inpath); | compilerConfig.setInpath(inpath); | ||||
Set<File> aspectpath = new HashSet<File>(); | |||||
Set<File> aspectpath = new HashSet<>(); | |||||
aspectpath.add(openFile("AspectDeclare.jar")); | aspectpath.add(openFile("AspectDeclare.jar")); | ||||
compilerConfig.setAspectPath(aspectpath); | compilerConfig.setAspectPath(aspectpath); | ||||
doBuild(); | doBuild(); | ||||
public void testWeaveMessagesBinaryDeclareSoft() { | public void testWeaveMessagesBinaryDeclareSoft() { | ||||
if (debugTests) | if (debugTests) | ||||
System.out.println("\ntestWeaveMessagesBinaryDeclareSoft: Simple.jar + AspectDeclareSoft.jar"); | System.out.println("\ntestWeaveMessagesBinaryDeclareSoft: Simple.jar + AspectDeclareSoft.jar"); | ||||
Set<File> inpath = new HashSet<File>(); | |||||
Set<File> inpath = new HashSet<>(); | |||||
inpath.add(openFile("Simple.jar")); | inpath.add(openFile("Simple.jar")); | ||||
compilerConfig.setInpath(inpath); | compilerConfig.setInpath(inpath); | ||||
Set<File> aspectpath = new HashSet<File>(); | |||||
Set<File> aspectpath = new HashSet<>(); | |||||
aspectpath.add(openFile("AspectDeclareSoft.jar")); | aspectpath.add(openFile("AspectDeclareSoft.jar")); | ||||
compilerConfig.setAspectPath(aspectpath); | compilerConfig.setAspectPath(aspectpath); | ||||
doBuild(); | doBuild(); | ||||
public void testWeaveMessagesBinaryAdviceInPackageFromJar() { | public void testWeaveMessagesBinaryAdviceInPackageFromJar() { | ||||
if (debugTests) | if (debugTests) | ||||
System.out.println("\ntestWeaveMessagesBinaryAdviceInPackageFromJar: Simple.jar + AspectInPackage.jar"); | System.out.println("\ntestWeaveMessagesBinaryAdviceInPackageFromJar: Simple.jar + AspectInPackage.jar"); | ||||
Set<File> inpath = new HashSet<File>(); | |||||
Set<File> inpath = new HashSet<>(); | |||||
inpath.add(openFile("Simple.jar")); | inpath.add(openFile("Simple.jar")); | ||||
compilerConfig.setInpath(inpath); | compilerConfig.setInpath(inpath); | ||||
Set<File> aspectpath = new HashSet<File>(); | |||||
Set<File> aspectpath = new HashSet<>(); | |||||
aspectpath.add(openFile("AspectInPackage.jar")); | aspectpath.add(openFile("AspectInPackage.jar")); | ||||
compilerConfig.setAspectPath(aspectpath); | compilerConfig.setAspectPath(aspectpath); | ||||
doBuild(); | doBuild(); | ||||
public void testWeaveMessagesBinaryAdviceInPackage() { | public void testWeaveMessagesBinaryAdviceInPackage() { | ||||
if (debugTests) | if (debugTests) | ||||
System.out.println("\ntestWeaveMessagesBinaryAdviceInPackage: Simple.jar + AspectInPackage.jar"); | System.out.println("\ntestWeaveMessagesBinaryAdviceInPackage: Simple.jar + AspectInPackage.jar"); | ||||
Set<File> inpath = new HashSet<File>(); | |||||
Set<File> inpath = new HashSet<>(); | |||||
inpath.add(openFile("Simple.jar")); | inpath.add(openFile("Simple.jar")); | ||||
compilerConfig.setInpath(inpath); | compilerConfig.setInpath(inpath); | ||||
Set<File> aspectpath = new HashSet<File>(); | |||||
Set<File> aspectpath = new HashSet<>(); | |||||
aspectpath.add(openFile("pkg")); | aspectpath.add(openFile("pkg")); | ||||
compilerConfig.setAspectPath(aspectpath); | compilerConfig.setAspectPath(aspectpath); | ||||
doBuild(); | doBuild(); | ||||
public void testWeaveMessagesBinaryAdviceNoDebugInfo() { | public void testWeaveMessagesBinaryAdviceNoDebugInfo() { | ||||
if (debugTests) | if (debugTests) | ||||
System.out.println("\ntestWeaveMessagesBinaryAdvice: Simple.jar + AspectAdvice.jar"); | System.out.println("\ntestWeaveMessagesBinaryAdvice: Simple.jar + AspectAdvice.jar"); | ||||
Set<File> inpath = new HashSet<File>(); | |||||
Set<File> inpath = new HashSet<>(); | |||||
inpath.add(openFile("Simple_nodebug.jar")); | inpath.add(openFile("Simple_nodebug.jar")); | ||||
compilerConfig.setInpath(inpath); | compilerConfig.setInpath(inpath); | ||||
Set<File> aspectpath = new HashSet<File>(); | |||||
Set<File> aspectpath = new HashSet<>(); | |||||
aspectpath.add(openFile("AspectAdvice_nodebug.jar")); | aspectpath.add(openFile("AspectAdvice_nodebug.jar")); | ||||
compilerConfig.setAspectPath(aspectpath); | compilerConfig.setAspectPath(aspectpath); | ||||
doBuild(); | doBuild(); | ||||
public void testWeaveMessagesBinaryDeclareNoDebugInfo() { | public void testWeaveMessagesBinaryDeclareNoDebugInfo() { | ||||
if (debugTests) | if (debugTests) | ||||
System.out.println("\ntestWeaveMessagesBinaryDeclareNoDebugInfo: Simple.jar + AspectDeclare.jar"); | System.out.println("\ntestWeaveMessagesBinaryDeclareNoDebugInfo: Simple.jar + AspectDeclare.jar"); | ||||
Set<File> inpath = new HashSet<File>(); | |||||
Set<File> inpath = new HashSet<>(); | |||||
inpath.add(openFile("Simple_nodebug.jar")); | inpath.add(openFile("Simple_nodebug.jar")); | ||||
compilerConfig.setInpath(inpath); | compilerConfig.setInpath(inpath); | ||||
Set<File> aspectpath = new HashSet<File>(); | |||||
Set<File> aspectpath = new HashSet<>(); | |||||
aspectpath.add(openFile("AspectDeclare_nodebug.jar")); | aspectpath.add(openFile("AspectDeclare_nodebug.jar")); | ||||
compilerConfig.setAspectPath(aspectpath); | compilerConfig.setAspectPath(aspectpath); | ||||
doBuild(); | doBuild(); | ||||
public void testWeaveMessagesBinaryDeclareSoftNoDebugInfo() { | public void testWeaveMessagesBinaryDeclareSoftNoDebugInfo() { | ||||
if (debugTests) | if (debugTests) | ||||
System.out.println("\ntestWeaveMessagesBinaryDeclareSoftNoDebugInfo: Simple.jar + AspectDeclareSoft.jar"); | System.out.println("\ntestWeaveMessagesBinaryDeclareSoftNoDebugInfo: Simple.jar + AspectDeclareSoft.jar"); | ||||
Set<File> inpath = new HashSet<File>(); | |||||
Set<File> inpath = new HashSet<>(); | |||||
inpath.add(openFile("Simple_nodebug.jar")); | inpath.add(openFile("Simple_nodebug.jar")); | ||||
compilerConfig.setInpath(inpath); | compilerConfig.setInpath(inpath); | ||||
Set<File> aspectpath = new HashSet<File>(); | |||||
Set<File> aspectpath = new HashSet<>(); | |||||
aspectpath.add(openFile("AspectDeclareSoft_nodebug.jar")); | aspectpath.add(openFile("AspectDeclareSoft_nodebug.jar")); | ||||
compilerConfig.setAspectPath(aspectpath); | compilerConfig.setAspectPath(aspectpath); | ||||
doBuild(); | doBuild(); |
*/ | */ | ||||
public class LstBuildConfigFileParser extends ConfigParser { | public class LstBuildConfigFileParser extends ConfigParser { | ||||
private List<File> importedFiles = new ArrayList<File>(); | |||||
private List<String> problemEntries = new ArrayList<String>(); | |||||
private List<File> importedFiles = new ArrayList<>(); | |||||
private List<String> problemEntries = new ArrayList<>(); | |||||
// private String currFilePath; | // private String currFilePath; | ||||
null); | null); | ||||
Ajde.getDefault().getMessageHandler().handleMessage(msg); | Ajde.getDefault().getMessageHandler().handleMessage(msg); | ||||
} | } | ||||
List<String> fileContents = new ArrayList<String>(); | |||||
List<String> fileContents = new ArrayList<>(); | |||||
BufferedReader reader = new BufferedReader(new FileReader(configFile)); | BufferedReader reader = new BufferedReader(new FileReader(configFile)); | ||||
String line = reader.readLine(); | String line = reader.readLine(); | ||||
while (line != null) { | while (line != null) { | ||||
ConfigParser configParser = new ConfigParser(); | ConfigParser configParser = new ConfigParser(); | ||||
configParser.parseConfigFile(new File(path)); | configParser.parseConfigFile(new File(path)); | ||||
List<File> files = configParser.getFiles(); | List<File> files = configParser.getFiles(); | ||||
List<String> relativeFiles = new ArrayList<String>(); | |||||
List<String> relativeFiles = new ArrayList<>(); | |||||
for (File file : files) { | for (File file : files) { | ||||
relativeFiles.add(relativizePath(file.getPath(), rootPath)); | relativeFiles.add(relativizePath(file.getPath(), rootPath)); | ||||
} | } | ||||
return relativeFiles; | return relativeFiles; | ||||
} catch (ConfigParser.ParseException pe) { | } catch (ConfigParser.ParseException pe) { | ||||
return new ArrayList<String>(); | |||||
return new ArrayList<>(); | |||||
} | } | ||||
} | } | ||||
private List<String> allBuildConfigFiles; | private List<String> allBuildConfigFiles; | ||||
private List<BuildConfigListener> listeners = new ArrayList<BuildConfigListener>(); | |||||
private List<BuildConfigListener> listeners = new ArrayList<>(); | |||||
private LstBuildConfigFileUpdater fileUpdater = new LstBuildConfigFileUpdater(); | private LstBuildConfigFileUpdater fileUpdater = new LstBuildConfigFileUpdater(); | ||||
protected String currConfigFilePath = null; | protected String currConfigFilePath = null; | ||||
String rootPath = configFile.getParent(); | String rootPath = configFile.getParent(); | ||||
String configFileName = configFile.getName(); | String configFileName = configFile.getName(); | ||||
BuildConfigModel model = new BuildConfigModel(configFilePath); | BuildConfigModel model = new BuildConfigModel(configFilePath); | ||||
List<File> configFiles = new ArrayList<File>(); | |||||
List<File> importedFiles = new ArrayList<File>(); | |||||
List<File> configFiles = new ArrayList<>(); | |||||
List<File> importedFiles = new ArrayList<>(); | |||||
List<String> badEntries = null; | List<String> badEntries = null; | ||||
try { | try { | ||||
LstBuildConfigFileParser configParser = new LstBuildConfigFileParser(configFilePath); | LstBuildConfigFileParser configParser = new LstBuildConfigFileParser(configFilePath); | ||||
} | } | ||||
private List<String> relativizeFilePaths(List<File> configFiles, String rootPath) { | private List<String> relativizeFilePaths(List<File> configFiles, String rootPath) { | ||||
List<String> relativePathsList = new ArrayList<String>(); | |||||
List<String> relativePathsList = new ArrayList<>(); | |||||
for (File file : configFiles) { | for (File file : configFiles) { | ||||
relativePathsList.add(fileUpdater.relativizePath(file.getPath(), rootPath)); | relativePathsList.add(fileUpdater.relativizePath(file.getPath(), rootPath)); | ||||
} | } | ||||
@Override | @Override | ||||
public List<String> getAllBuildConfigFiles() { | public List<String> getAllBuildConfigFiles() { | ||||
if (allBuildConfigFiles == null) { | if (allBuildConfigFiles == null) { | ||||
allBuildConfigFiles = new ArrayList<String>(); | |||||
allBuildConfigFiles = new ArrayList<>(); | |||||
if (getActiveConfigFile() != null) { | if (getActiveConfigFile() != null) { | ||||
allBuildConfigFiles.add(getActiveConfigFile()); | allBuildConfigFiles.add(getActiveConfigFile()); | ||||
} | } |
} | } | ||||
public List<BuildConfigNode> getActiveNodes(BuildConfigNode.Kind kind) { | public List<BuildConfigNode> getActiveNodes(BuildConfigNode.Kind kind) { | ||||
List<BuildConfigNode> nodes = new ArrayList<BuildConfigNode>(); | |||||
List<BuildConfigNode> nodes = new ArrayList<>(); | |||||
getActiveNodesHelper(root, kind, nodes); | getActiveNodesHelper(root, kind, nodes); | ||||
return nodes; | return nodes; | ||||
} | } |
protected String name = ""; | protected String name = ""; | ||||
protected Kind kind; | protected Kind kind; | ||||
// children.listIterator() should support remove() operation | // children.listIterator() should support remove() operation | ||||
protected List<BuildConfigNode> children = new ArrayList<BuildConfigNode>(); | |||||
protected List<BuildConfigNode> children = new ArrayList<>(); | |||||
protected IMessage message = null; | protected IMessage message = null; | ||||
protected ISourceLocation sourceLocation = null; | protected ISourceLocation sourceLocation = null; | ||||
public void addChild(BuildConfigNode child) { | public void addChild(BuildConfigNode child) { | ||||
if (children == null) { | if (children == null) { | ||||
children = new ArrayList<BuildConfigNode>(); | |||||
children = new ArrayList<>(); | |||||
} | } | ||||
children.add(child); | children.add(child); | ||||
child.setParent(this); | child.setParent(this); | ||||
public void addChild(int position, BuildConfigNode child) { | public void addChild(int position, BuildConfigNode child) { | ||||
if (children == null) { | if (children == null) { | ||||
children = new ArrayList<BuildConfigNode>(); | |||||
children = new ArrayList<>(); | |||||
} | } | ||||
children.add(position, child); | children.add(position, child); | ||||
child.setParent(this); | child.setParent(this); |
JComboBox<String> debug = null; | JComboBox<String> debug = null; | ||||
if (javaOptionToSet.equals(JavaOptions.PRESERVE_ALL_LOCALS)) { | if (javaOptionToSet.equals(JavaOptions.PRESERVE_ALL_LOCALS)) { | ||||
debug = new JComboBox<String>(preserveOptions); | |||||
debug = new JComboBox<>(preserveOptions); | |||||
String value = javaBuildOptions.getJavaBuildOptionsMap().get(javaOptionToSet); | String value = javaBuildOptions.getJavaBuildOptionsMap().get(javaOptionToSet); | ||||
if (value.equals(JavaOptions.PRESERVE)) { | if (value.equals(JavaOptions.PRESERVE)) { | ||||
debug.setSelectedIndex(0); | debug.setSelectedIndex(0); | ||||
debug.setSelectedIndex(1); | debug.setSelectedIndex(1); | ||||
} | } | ||||
} else { | } else { | ||||
debug = new JComboBox<String>(debugOptions); | |||||
debug = new JComboBox<>(debugOptions); | |||||
String value = javaBuildOptions.getJavaBuildOptionsMap().get(javaOptionToSet); | String value = javaBuildOptions.getJavaBuildOptionsMap().get(javaOptionToSet); | ||||
if (value.equals(JavaOptions.GENERATE)) { | if (value.equals(JavaOptions.GENERATE)) { | ||||
debug.setSelectedIndex(0); | debug.setSelectedIndex(0); |
private static final String ITD_FIELD_SUMMARY = "Inter-Type Field Summary"; | private static final String ITD_FIELD_SUMMARY = "Inter-Type Field Summary"; | ||||
private static final String ITD_CONSTRUCTOR_SUMMARY = "Inter-Type Constructor Summary"; | private static final String ITD_CONSTRUCTOR_SUMMARY = "Inter-Type Constructor Summary"; | ||||
static List<String> visibleFileList = new ArrayList<String>(); | |||||
static List<String> visibleFileList = new ArrayList<>(); | |||||
static Hashtable declIDTable = null; | static Hashtable declIDTable = null; | ||||
static File rootDir = null; | static File rootDir = null; | ||||
static String docVisibilityModifier; | static String docVisibilityModifier; | ||||
} | } | ||||
static void addAspectDocumentation(IProgramElement node, StringBuffer fileBuffer, int index) { | static void addAspectDocumentation(IProgramElement node, StringBuffer fileBuffer, int index) { | ||||
List<IProgramElement> pointcuts = new ArrayList<IProgramElement>(); | |||||
List<IProgramElement> advice = new ArrayList<IProgramElement>(); | |||||
List<IProgramElement> declares = new ArrayList<IProgramElement>(); | |||||
List<IProgramElement> pointcuts = new ArrayList<>(); | |||||
List<IProgramElement> advice = new ArrayList<>(); | |||||
List<IProgramElement> declares = new ArrayList<>(); | |||||
List<IProgramElement> methodsDeclaredOn = StructureUtil.getDeclareInterTypeTargets(node, IProgramElement.Kind.INTER_TYPE_METHOD); | List<IProgramElement> methodsDeclaredOn = StructureUtil.getDeclareInterTypeTargets(node, IProgramElement.Kind.INTER_TYPE_METHOD); | ||||
if (methodsDeclaredOn != null && !methodsDeclaredOn.isEmpty()) { | if (methodsDeclaredOn != null && !methodsDeclaredOn.isEmpty()) { | ||||
insertDeclarationsSummary(fileBuffer, methodsDeclaredOn, ITD_METHOD_SUMMARY, index); | insertDeclarationsSummary(fileBuffer, methodsDeclaredOn, ITD_METHOD_SUMMARY, index); |
private static String outputWorkingDir = Config.WORKING_DIR; | private static String outputWorkingDir = Config.WORKING_DIR; | ||||
public static void clearState() { | public static void clearState() { | ||||
options = new Vector<String>(); | |||||
ajcOptions = new Vector<String>(); | |||||
filenames = new Vector<String>(); | |||||
fileList = new Vector<String>(); | |||||
packageList = new Vector<String>(); | |||||
options = new Vector<>(); | |||||
ajcOptions = new Vector<>(); | |||||
filenames = new Vector<>(); | |||||
fileList = new Vector<>(); | |||||
packageList = new Vector<>(); | |||||
docModifier = "package"; | docModifier = "package"; | ||||
sourcepath = new Vector<String>(); | |||||
sourcepath = new Vector<>(); | |||||
verboseMode = false; | verboseMode = false; | ||||
packageMode = false; | packageMode = false; | ||||
rootDir = null; | rootDir = null; | ||||
* package-summary properly. | * package-summary properly. | ||||
*/ | */ | ||||
private static void packageHTML(AsmManager model, File[] inputFiles) throws IOException { | private static void packageHTML(AsmManager model, File[] inputFiles) throws IOException { | ||||
ArrayList<String> dirList = new ArrayList<String>(); | |||||
ArrayList<String> dirList = new ArrayList<>(); | |||||
for (File inputFile : inputFiles) { | for (File inputFile : inputFiles) { | ||||
String packageName = StructureUtil.getPackageDeclarationFromFile(model, inputFile); | String packageName = StructureUtil.getPackageDeclarationFromFile(model, inputFile); | ||||
// Only copy the package.html file once. | // Only copy the package.html file once. | ||||
System.out.println("> Calling javadoc..."); | System.out.println("> Calling javadoc..."); | ||||
String[] javadocargs = null; | String[] javadocargs = null; | ||||
List<String> files = new ArrayList<String>(); | |||||
List<String> files = new ArrayList<>(); | |||||
if (packageMode) { | if (packageMode) { | ||||
int numExtraArgs = 2; | int numExtraArgs = 2; | ||||
if (authorStandardDocletSwitch) | if (authorStandardDocletSwitch) | ||||
javadocargs[numExtraArgs + options.size() + packageList.size() + k] = fileList.elementAt(k); | javadocargs[numExtraArgs + options.size() + packageList.size() + k] = fileList.elementAt(k); | ||||
} | } | ||||
if (LangUtil.is19VMOrGreater()) { | if (LangUtil.is19VMOrGreater()) { | ||||
options = new Vector<String>(); | |||||
options = new Vector<>(); | |||||
for (String a: javadocargs) { | for (String a: javadocargs) { | ||||
options.add(a); | options.add(a); | ||||
} | } | ||||
} | } | ||||
static Vector<String> getSourcePath() { | static Vector<String> getSourcePath() { | ||||
Vector<String> sourcePath = new Vector<String>(); | |||||
Vector<String> sourcePath = new Vector<>(); | |||||
boolean found = false; | boolean found = false; | ||||
for (int i = 0; i < options.size(); i++) { | for (int i = 0; i < options.size(); i++) { | ||||
String currOption = options.elementAt(i); | String currOption = options.elementAt(i); | ||||
String line = ""; | String line = ""; | ||||
line = br.readLine(); | line = br.readLine(); | ||||
StringTokenizer st = new StringTokenizer(line, " "); | StringTokenizer st = new StringTokenizer(line, " "); | ||||
List<String> argList = new ArrayList<String>(); | |||||
List<String> argList = new ArrayList<>(); | |||||
while (st.hasMoreElements()) { | while (st.hasMoreElements()) { | ||||
argList.add(st.nextToken()); | argList.add(st.nextToken()); | ||||
} | } | ||||
ioe.printStackTrace(); | ioe.printStackTrace(); | ||||
} | } | ||||
} | } | ||||
List<String> vargs = new LinkedList<String>(Arrays.asList(args)); | |||||
List<String> vargs = new LinkedList<>(Arrays.asList(args)); | |||||
vargs.add("-Xset:minimalModel=false"); | vargs.add("-Xset:minimalModel=false"); | ||||
parseArgs(vargs, new File(".")); // !!! | parseArgs(vargs, new File(".")); // !!! | ||||
} | } | ||||
static void expandAtSignFile(String filename, File currentWorkingDir) { | static void expandAtSignFile(String filename, File currentWorkingDir) { | ||||
List<String> result = new LinkedList<String>(); | |||||
List<String> result = new LinkedList<>(); | |||||
File atFile = qualifiedFile(filename, currentWorkingDir); | File atFile = qualifiedFile(filename, currentWorkingDir); | ||||
String atFileParent = atFile.getParent(); | String atFileParent = atFile.getParent(); |
* @return null if a relationship of that kind is not found | * @return null if a relationship of that kind is not found | ||||
*/ | */ | ||||
public static List<String> getTargets(IProgramElement node, IRelationship.Kind kind, String relName) { | public static List<String> getTargets(IProgramElement node, IRelationship.Kind kind, String relName) { | ||||
List<IRelationship> relations = new ArrayList<IRelationship>(); | |||||
List<IRelationship> relations = new ArrayList<>(); | |||||
List<IRelationship> rels = node.getModel().getRelationshipMap().get(node); | List<IRelationship> rels = node.getModel().getRelationshipMap().get(node); | ||||
if (rels != null) { | if (rels != null) { | ||||
relations.addAll(rels); | relations.addAll(rels); | ||||
} | } | ||||
if (relations == null || relations.isEmpty()) | if (relations == null || relations.isEmpty()) | ||||
return null; | return null; | ||||
List<String> targets = new ArrayList<String>(); | |||||
List<String> targets = new ArrayList<>(); | |||||
for (IRelationship rtn : relations) { | for (IRelationship rtn : relations) { | ||||
if (rtn.getKind().equals(kind) && ((relName != null && relName.equals(rtn.getName())) || relName == null)) { | if (rtn.getKind().equals(kind) && ((relName != null && relName.equals(rtn.getName())) || relName == null)) { | ||||
List<String> targs = rtn.getTargets(); | List<String> targs = rtn.getTargets(); | ||||
} | } | ||||
static List<IProgramElement> getDeclareInterTypeTargets(IProgramElement node, IProgramElement.Kind kind) { | static List<IProgramElement> getDeclareInterTypeTargets(IProgramElement node, IProgramElement.Kind kind) { | ||||
List<IProgramElement> targets = new ArrayList<IProgramElement>(); | |||||
List<IProgramElement> targets = new ArrayList<>(); | |||||
List<String> stringTargets = StructureUtil.getTargets(node, IRelationship.Kind.DECLARE_INTER_TYPE); | List<String> stringTargets = StructureUtil.getTargets(node, IRelationship.Kind.DECLARE_INTER_TYPE); | ||||
if (stringTargets == null) { | if (stringTargets == null) { | ||||
return null; | return null; |
* @throws Exception | * @throws Exception | ||||
*/ | */ | ||||
public static List<String> getMissingStringsInFile(File htmlFile, String[] requiredStrings) throws Exception { | public static List<String> getMissingStringsInFile(File htmlFile, String[] requiredStrings) throws Exception { | ||||
List<String> missingStrings = new ArrayList<String>(); | |||||
List<String> missingStrings = new ArrayList<>(); | |||||
for (String string : requiredStrings) { | for (String string : requiredStrings) { | ||||
if (!containsString(htmlFile, string)) { | if (!containsString(htmlFile, string)) { | ||||
missingStrings.add(string); | missingStrings.add(string); | ||||
*/ | */ | ||||
public static List<String> getMissingStringsInSection(File htmlFile, | public static List<String> getMissingStringsInSection(File htmlFile, | ||||
String[] requiredStrings, String sectionHeader) throws Exception { | String[] requiredStrings, String sectionHeader) throws Exception { | ||||
List<String> missingStrings = new ArrayList<String>(); | |||||
List<String> missingStrings = new ArrayList<>(); | |||||
for (String string : requiredStrings) { | for (String string : requiredStrings) { | ||||
if (!containsStringWithinSection(htmlFile, string, sectionHeader)) { | if (!containsStringWithinSection(htmlFile, string, sectionHeader)) { | ||||
missingStrings.add(string); | missingStrings.add(string); |
private static boolean completingTypeBindings = false; | private static boolean completingTypeBindings = false; | ||||
private final List<IHierarchyListener> structureListeners = new ArrayList<IHierarchyListener>(); | |||||
private final List<IHierarchyListener> structureListeners = new ArrayList<>(); | |||||
// The model is 'manipulated' by the AjBuildManager.setupModel() code which | // The model is 'manipulated' by the AjBuildManager.setupModel() code which | ||||
// trashes all the | // trashes all the | ||||
private final CanonicalFilePathMap canonicalFilePathMap = new CanonicalFilePathMap(); | private final CanonicalFilePathMap canonicalFilePathMap = new CanonicalFilePathMap(); | ||||
// Record the Set<File> for which the model has been modified during the | // Record the Set<File> for which the model has been modified during the | ||||
// last incremental build | // last incremental build | ||||
private final Set<File> lastBuildChanges = new HashSet<File>(); | |||||
private final Set<File> lastBuildChanges = new HashSet<>(); | |||||
// Record the Set<File> of aspects that wove the files listed in lastBuildChanges | // Record the Set<File> of aspects that wove the files listed in lastBuildChanges | ||||
final Set<File> aspectsWeavingInLastBuild = new HashSet<File>(); | |||||
final Set<File> aspectsWeavingInLastBuild = new HashSet<>(); | |||||
// static { | // static { | ||||
// setReporting("c:/model.nfo",true,true,true,true); | // setReporting("c:/model.nfo",true,true,true,true); | ||||
return null; | return null; | ||||
} | } | ||||
HashMap<Integer, List<IProgramElement>> annotations = new HashMap<Integer, List<IProgramElement>>(); | |||||
HashMap<Integer, List<IProgramElement>> annotations = new HashMap<>(); | |||||
IProgramElement node = hierarchy.findElementForSourceFile(sourceFile); | IProgramElement node = hierarchy.findElementForSourceFile(sourceFile); | ||||
if (node == IHierarchy.NO_STRUCTURE) { | if (node == IHierarchy.NO_STRUCTURE) { | ||||
return null; | return null; | ||||
} else { | } else { | ||||
IProgramElement fileNode = node; | IProgramElement fileNode = node; | ||||
ArrayList<IProgramElement> peNodes = new ArrayList<IProgramElement>(); | |||||
ArrayList<IProgramElement> peNodes = new ArrayList<>(); | |||||
getAllStructureChildren(fileNode, peNodes, showSubMember, showMemberAndType); | getAllStructureChildren(fileNode, peNodes, showSubMember, showMemberAndType); | ||||
for (IProgramElement peNode : peNodes) { | for (IProgramElement peNode : peNodes) { | ||||
List<IProgramElement> entries = new ArrayList<IProgramElement>(); | |||||
List<IProgramElement> entries = new ArrayList<>(); | |||||
entries.add(peNode); | entries.add(peNode); | ||||
ISourceLocation sourceLoc = peNode.getSourceLocation(); | ISourceLocation sourceLoc = peNode.getSourceLocation(); | ||||
if (null != sourceLoc) { | if (null != sourceLoc) { | ||||
private static class CanonicalFilePathMap { | private static class CanonicalFilePathMap { | ||||
private static final int MAX_SIZE = 4000; | private static final int MAX_SIZE = 4000; | ||||
private final Map<String, String> pathMap = new HashMap<String, String>(20); | |||||
private final Map<String, String> pathMap = new HashMap<>(20); | |||||
// // guards to ensure correctness and liveness | // // guards to ensure correctness and liveness | ||||
// private boolean cacheInUse = false; | // private boolean cacheInUse = false; | ||||
boolean modelModified = false; | boolean modelModified = false; | ||||
Set<String> deletedNodes = new HashSet<String>(); | |||||
Set<String> deletedNodes = new HashSet<>(); | |||||
for (File fileForCompilation : files) { | for (File fileForCompilation : files) { | ||||
String correctedPath = getCanonicalFilePath(fileForCompilation); | String correctedPath = getCanonicalFilePath(fileForCompilation); | ||||
IProgramElement progElem = (IProgramElement) hierarchy.findInFileMap(correctedPath); | IProgramElement progElem = (IProgramElement) hierarchy.findInFileMap(correctedPath); | ||||
return; | return; | ||||
} | } | ||||
Set<String> sourcesToRemove = new HashSet<String>(); | |||||
Map<String, String> handleToTypenameCache = new HashMap<String, String>(); | |||||
Set<String> sourcesToRemove = new HashSet<>(); | |||||
Map<String, String> handleToTypenameCache = new HashMap<>(); | |||||
// Iterate over the source handles in the relationships map, the aim | // Iterate over the source handles in the relationships map, the aim | ||||
// here is to remove any 'affected by' | // here is to remove any 'affected by' | ||||
// relationships where the source of the relationship is the specified | // relationships where the source of the relationship is the specified | ||||
// type (since it will be readded | // type (since it will be readded | ||||
// when the type is woven) | // when the type is woven) | ||||
Set<String> sourcehandlesSet = mapper.getEntries(); | Set<String> sourcehandlesSet = mapper.getEntries(); | ||||
List<IRelationship> relationshipsToRemove = new ArrayList<IRelationship>(); | |||||
List<IRelationship> relationshipsToRemove = new ArrayList<>(); | |||||
for (String hid : sourcehandlesSet) { | for (String hid : sourcehandlesSet) { | ||||
if (isPhantomHandle(hid)) { | if (isPhantomHandle(hid)) { | ||||
// inpath handle - but for which type? | // inpath handle - but for which type? | ||||
continue; | continue; | ||||
} | } | ||||
List<String> targets = rel.getTargets(); | List<String> targets = rel.getTargets(); | ||||
List<String> targetsToRemove = new ArrayList<String>(); | |||||
List<String> targetsToRemove = new ArrayList<>(); | |||||
// find targets that target the type we are interested in, | // find targets that target the type we are interested in, | ||||
// they need removing | // they need removing | ||||
// Now sort out the relationships map | // Now sort out the relationships map | ||||
// IRelationshipMap irm = AsmManager.getDefault().getRelationshipMap(); | // IRelationshipMap irm = AsmManager.getDefault().getRelationshipMap(); | ||||
Set<String> sourcesToRemove = new HashSet<String>(); | |||||
Set<String> nonExistingHandles = new HashSet<String>(); // Cache of handles that we | |||||
Set<String> sourcesToRemove = new HashSet<>(); | |||||
Set<String> nonExistingHandles = new HashSet<>(); // Cache of handles that we | |||||
// *know* are invalid | // *know* are invalid | ||||
// int srchandlecounter = 0; | // int srchandlecounter = 0; | ||||
// int tgthandlecounter = 0; | // int tgthandlecounter = 0; | ||||
} else { | } else { | ||||
// Ok, so the source is valid, what about the targets? | // Ok, so the source is valid, what about the targets? | ||||
List<IRelationship> relationships = mapper.get(hid); | List<IRelationship> relationships = mapper.get(hid); | ||||
List<IRelationship> relationshipsToRemove = new ArrayList<IRelationship>(); | |||||
List<IRelationship> relationshipsToRemove = new ArrayList<>(); | |||||
// Iterate through the relationships against this source | // Iterate through the relationships against this source | ||||
// handle | // handle | ||||
for (IRelationship rel : relationships) { | for (IRelationship rel : relationships) { | ||||
List<String> targets = rel.getTargets(); | List<String> targets = rel.getTargets(); | ||||
List<String> targetsToRemove = new ArrayList<String>(); | |||||
List<String> targetsToRemove = new ArrayList<>(); | |||||
// Iterate through the targets for this relationship | // Iterate through the targets for this relationship | ||||
for (String targethid : targets) { | for (String targethid : targets) { | ||||
* A ModelInfo object captures basic information about the structure model. It is used for testing and producing debug info. | * A ModelInfo object captures basic information about the structure model. It is used for testing and producing debug info. | ||||
*/ | */ | ||||
public static class ModelInfo { | public static class ModelInfo { | ||||
private final Hashtable<String, Integer> nodeTypeCount = new Hashtable<String, Integer>(); | |||||
private final Hashtable<String, Integer> nodeTypeCount = new Hashtable<>(); | |||||
private final Properties extraProperties = new Properties(); | private final Properties extraProperties = new Properties(); | ||||
private ModelInfo(IHierarchy hierarchy, IRelationshipMap relationshipMap) { | private ModelInfo(IHierarchy hierarchy, IRelationshipMap relationshipMap) { |
} | } | ||||
public static List<Kind> getNonAJMemberKinds() { | public static List<Kind> getNonAJMemberKinds() { | ||||
List<Kind> list = new ArrayList<Kind>(); | |||||
List<Kind> list = new ArrayList<>(); | |||||
list.add(METHOD); | list.add(METHOD); | ||||
list.add(ENUM_VALUE); | list.add(ENUM_VALUE); | ||||
list.add(FIELD); | list.add(FIELD); |
// Access to the handleMap and typeMap are now synchronized - at least the find methods and the updateHandleMap function | // Access to the handleMap and typeMap are now synchronized - at least the find methods and the updateHandleMap function | ||||
// see pr305788 | // see pr305788 | ||||
private Map<String, IProgramElement> fileMap = null; | private Map<String, IProgramElement> fileMap = null; | ||||
private Map<String, IProgramElement> handleMap = new HashMap<String, IProgramElement>(); | |||||
private Map<String, IProgramElement> handleMap = new HashMap<>(); | |||||
private Map<String, IProgramElement> typeMap = null; | private Map<String, IProgramElement> typeMap = null; | ||||
public AspectJElementHierarchy(AsmManager asm) { | public AspectJElementHierarchy(AsmManager asm) { | ||||
public void setRoot(IProgramElement root) { | public void setRoot(IProgramElement root) { | ||||
this.root = root; | this.root = root; | ||||
handleMap = new HashMap<String, IProgramElement>(); | |||||
typeMap = new HashMap<String, IProgramElement>(); | |||||
handleMap = new HashMap<>(); | |||||
typeMap = new HashMap<>(); | |||||
} | } | ||||
public void addToFileMap(String key, IProgramElement value) { | public void addToFileMap(String key, IProgramElement value) { | ||||
if ((children.get(0)).getKind() == IProgramElement.Kind.SOURCE_FOLDER) { | if ((children.get(0)).getKind() == IProgramElement.Kind.SOURCE_FOLDER) { | ||||
String searchPackageName = (packagename == null ? "" : packagename); // default package means match on "" | String searchPackageName = (packagename == null ? "" : packagename); // default package means match on "" | ||||
// dealing with source folders | // dealing with source folders | ||||
List<IProgramElement> matchingPackageNodes = new ArrayList<IProgramElement>(); | |||||
List<IProgramElement> matchingPackageNodes = new ArrayList<>(); | |||||
for (IProgramElement sourceFolder : children) { | for (IProgramElement sourceFolder : children) { | ||||
List<IProgramElement> possiblePackageNodes = sourceFolder.getChildren(); | List<IProgramElement> possiblePackageNodes = sourceFolder.getChildren(); | ||||
for (IProgramElement possiblePackageNode : possiblePackageNodes) { | for (IProgramElement possiblePackageNode : possiblePackageNodes) { | ||||
// thing to return in the list | // thing to return in the list | ||||
if (packagename == null) { | if (packagename == null) { | ||||
// default package | // default package | ||||
List<IProgramElement> result = new ArrayList<IProgramElement>(); | |||||
List<IProgramElement> result = new ArrayList<>(); | |||||
result.add(root); | result.add(root); | ||||
return result; | return result; | ||||
} | } | ||||
List<IProgramElement> result = new ArrayList<IProgramElement>(); | |||||
List<IProgramElement> result = new ArrayList<>(); | |||||
for (IProgramElement possiblePackage : children) { | for (IProgramElement possiblePackage : children) { | ||||
if (possiblePackage.getKind() == IProgramElement.Kind.PACKAGE && possiblePackage.getName().equals(packagename)) { | if (possiblePackage.getKind() == IProgramElement.Kind.PACKAGE && possiblePackage.getName().equals(packagename)) { | ||||
result.add(possiblePackage); | result.add(possiblePackage); | ||||
// TODO rename this method ... it does more than just the handle map | // TODO rename this method ... it does more than just the handle map | ||||
public void updateHandleMap(Set<String> deletedFiles) { | public void updateHandleMap(Set<String> deletedFiles) { | ||||
// Only delete the entries we need to from the handle map - for performance reasons | // Only delete the entries we need to from the handle map - for performance reasons | ||||
List<String> forRemoval = new ArrayList<String>(); | |||||
List<String> forRemoval = new ArrayList<>(); | |||||
Set<String> k = null; | Set<String> k = null; | ||||
synchronized (this) { | synchronized (this) { | ||||
k = handleMap.keySet(); | k = handleMap.keySet(); |
} | } | ||||
private static List<IProgramElement.Modifiers> genModifiers(int modifiers) { | private static List<IProgramElement.Modifiers> genModifiers(int modifiers) { | ||||
List<IProgramElement.Modifiers> modifiersList = new ArrayList<IProgramElement.Modifiers>(); | |||||
List<IProgramElement.Modifiers> modifiersList = new ArrayList<>(); | |||||
if ((modifiers & AccStatic) != 0) { | if ((modifiers & AccStatic) != 0) { | ||||
modifiersList.add(IProgramElement.Modifiers.STATIC); | modifiersList.add(IProgramElement.Modifiers.STATIC); | ||||
} | } | ||||
public void addChild(IProgramElement child) { | public void addChild(IProgramElement child) { | ||||
if (children == null || children == Collections.EMPTY_LIST) { | if (children == null || children == Collections.EMPTY_LIST) { | ||||
children = new ArrayList<IProgramElement>(); | |||||
children = new ArrayList<>(); | |||||
} | } | ||||
children.add(child); | children.add(child); | ||||
child.setParent(this); | child.setParent(this); | ||||
public void addChild(int position, IProgramElement child) { | public void addChild(int position, IProgramElement child) { | ||||
if (children == null || children == Collections.EMPTY_LIST) { | if (children == null || children == Collections.EMPTY_LIST) { | ||||
children = new ArrayList<IProgramElement>(); | |||||
children = new ArrayList<>(); | |||||
} | } | ||||
children.add(position, child); | children.add(position, child); | ||||
child.setParent(this); | child.setParent(this); | ||||
if (l == null || l.isEmpty()) { | if (l == null || l.isEmpty()) { | ||||
return Collections.emptyList(); | return Collections.emptyList(); | ||||
} | } | ||||
List<char[]> params = new ArrayList<char[]>(); | |||||
List<char[]> params = new ArrayList<>(); | |||||
for (char[] param : l) { | for (char[] param : l) { | ||||
params.add(NameConvertor.convertFromSignature(param)); | params.add(NameConvertor.convertFromSignature(param)); | ||||
} | } | ||||
private void fixMap() { | private void fixMap() { | ||||
if (kvpairs == Collections.EMPTY_MAP) { | if (kvpairs == Collections.EMPTY_MAP) { | ||||
kvpairs = new HashMap<String, Object>(); | |||||
kvpairs = new HashMap<>(); | |||||
} | } | ||||
} | } | ||||
if (!createIfMissing) { | if (!createIfMissing) { | ||||
return null; | return null; | ||||
} | } | ||||
relationships = new ArrayList<IRelationship>(); | |||||
IRelationship rel = new Relationship(relationshipName, kind, source, new ArrayList<String>(), runtimeTest); | |||||
relationships = new ArrayList<>(); | |||||
IRelationship rel = new Relationship(relationshipName, kind, source, new ArrayList<>(), runtimeTest); | |||||
relationships.add(rel); | relationships.add(rel); | ||||
super.put(source, relationships); | super.put(source, relationships); | ||||
if (createIfMissing) { | if (createIfMissing) { | ||||
// At this point we did find some relationships for 'source' but not one that looks like what we are | // At this point we did find some relationships for 'source' but not one that looks like what we are | ||||
// after (either the kind or the name or the dynamictests setting don't match) | // after (either the kind or the name or the dynamictests setting don't match) | ||||
IRelationship rel = new Relationship(relationshipName, kind, source, new ArrayList<String>(), runtimeTest); | |||||
IRelationship rel = new Relationship(relationshipName, kind, source, new ArrayList<>(), runtimeTest); | |||||
relationships.add(rel); | relationships.add(rel); | ||||
return rel; | return rel; | ||||
} | } | ||||
List<IRelationship> existingRelationships = super.get(source); | List<IRelationship> existingRelationships = super.get(source); | ||||
if (existingRelationships == null) { | if (existingRelationships == null) { | ||||
// new entry | // new entry | ||||
existingRelationships = new ArrayList<IRelationship>(); | |||||
existingRelationships = new ArrayList<>(); | |||||
existingRelationships.add(relationship); | existingRelationships.add(relationship); | ||||
super.put(source, existingRelationships); | super.put(source, existingRelationships); | ||||
} else { | } else { |
private Constant[] pool; | private Constant[] pool; | ||||
private int poolSize; // number of entries in the pool (could be < pool.length as the array is resized in 'chunks') | private int poolSize; // number of entries in the pool (could be < pool.length as the array is resized in 'chunks') | ||||
private Map<String, Integer> utf8Cache = new HashMap<String, Integer>(); | |||||
private Map<String, Integer> methodCache = new HashMap<String, Integer>(); | |||||
private Map<String, Integer> fieldCache = new HashMap<String, Integer>(); | |||||
private Map<String, Integer> utf8Cache = new HashMap<>(); | |||||
private Map<String, Integer> methodCache = new HashMap<>(); | |||||
private Map<String, Integer> fieldCache = new HashMap<>(); | |||||
public int getSize() { | public int getSize() { | ||||
return poolSize; | return poolSize; |
// remain there. | // remain there. | ||||
if (annotations == null) { | if (annotations == null) { | ||||
// Find attributes that contain annotation data | // Find attributes that contain annotation data | ||||
List<AnnotationGen> accumulatedAnnotations = new ArrayList<AnnotationGen>(); | |||||
List<AnnotationGen> accumulatedAnnotations = new ArrayList<>(); | |||||
for (Attribute attribute : attributes) { | for (Attribute attribute : attributes) { | ||||
if (attribute instanceof RuntimeAnnos) { | if (attribute instanceof RuntimeAnnos) { | ||||
RuntimeAnnos runtimeAnnotations = (RuntimeAnnos) attribute; | RuntimeAnnos runtimeAnnotations = (RuntimeAnnos) attribute; |
public AnnotationGen[] getAnnotations() { | public AnnotationGen[] getAnnotations() { | ||||
if (annotationsOutOfDate) { | if (annotationsOutOfDate) { | ||||
// Find attributes that contain annotation data | // Find attributes that contain annotation data | ||||
List<AnnotationGen> accumulatedAnnotations = new ArrayList<AnnotationGen>(); | |||||
List<AnnotationGen> accumulatedAnnotations = new ArrayList<>(); | |||||
for (Attribute attribute : attributes) { | for (Attribute attribute : attributes) { | ||||
if (attribute instanceof RuntimeAnnos) { | if (attribute instanceof RuntimeAnnos) { | ||||
RuntimeAnnos runtimeAnnotations = (RuntimeAnnos) attribute; | RuntimeAnnos runtimeAnnotations = (RuntimeAnnos) attribute; | ||||
*/ | */ | ||||
public JavaClass[] getSuperClasses() { | public JavaClass[] getSuperClasses() { | ||||
JavaClass clazz = this; | JavaClass clazz = this; | ||||
List<JavaClass> vec = new ArrayList<JavaClass>(); | |||||
List<JavaClass> vec = new ArrayList<>(); | |||||
for (clazz = clazz.getSuperClass(); clazz != null; clazz = clazz.getSuperClass()) { | for (clazz = clazz.getSuperClass(); clazz != null; clazz = clazz.getSuperClass()) { | ||||
vec.add(clazz); | vec.add(clazz); | ||||
} | } | ||||
* Get all interfaces implemented by this JavaClass (transitively). | * Get all interfaces implemented by this JavaClass (transitively). | ||||
*/ | */ | ||||
public Collection<JavaClass> getAllInterfaces() { | public Collection<JavaClass> getAllInterfaces() { | ||||
Queue<JavaClass> queue = new LinkedList<JavaClass>(); | |||||
List<JavaClass> interfaceList = new ArrayList<JavaClass>(); | |||||
Queue<JavaClass> queue = new LinkedList<>(); | |||||
List<JavaClass> interfaceList = new ArrayList<>(); | |||||
queue.add(this); | queue.add(this); | ||||
boolean foundSome = false; | boolean foundSome = false; | ||||
// Build a list of annotation arrays, one per argument | // Build a list of annotation arrays, one per argument | ||||
if (parameterAnnotationsInvis != null || parameterAnnotationsVis != null) { | if (parameterAnnotationsInvis != null || parameterAnnotationsVis != null) { | ||||
List<AnnotationGen[]> annotationsForEachParameter = new ArrayList<AnnotationGen[]>(); | |||||
List<AnnotationGen[]> annotationsForEachParameter = new ArrayList<>(); | |||||
AnnotationGen[] visibleOnes = null; | AnnotationGen[] visibleOnes = null; | ||||
AnnotationGen[] invisibleOnes = null; | AnnotationGen[] invisibleOnes = null; | ||||
for (int i = 0; i < parameterCount; i++) { | for (int i = 0; i < parameterCount; i++) { |
riaIndex = cp.addUtf8("RuntimeInvisibleAnnotations"); | riaIndex = cp.addUtf8("RuntimeInvisibleAnnotations"); | ||||
} | } | ||||
List<RuntimeAnnos> newAttributes = new ArrayList<RuntimeAnnos>(); | |||||
List<RuntimeAnnos> newAttributes = new ArrayList<>(); | |||||
if (rvaData.length > 2) { | if (rvaData.length > 2) { | ||||
newAttributes.add(new RuntimeVisAnnos(rvaIndex, rvaData.length, rvaData, cp)); | newAttributes.add(new RuntimeVisAnnos(rvaIndex, rvaData.length, rvaData, cp)); | ||||
} | } | ||||
riaIndex = cp.addUtf8("RuntimeInvisibleParameterAnnotations"); | riaIndex = cp.addUtf8("RuntimeInvisibleParameterAnnotations"); | ||||
} | } | ||||
List<RuntimeParamAnnos> newAttributes = new ArrayList<RuntimeParamAnnos>(); | |||||
List<RuntimeParamAnnos> newAttributes = new ArrayList<>(); | |||||
if (totalVisCount > 0) { | if (totalVisCount > 0) { | ||||
newAttributes.add(new RuntimeVisParamAnnos(rvaIndex, rvaData.length, rvaData, cp)); | newAttributes.add(new RuntimeVisParamAnnos(rvaIndex, rvaData.length, rvaData, cp)); |
} | } | ||||
private List<NameValuePair> copyValues(List<NameValuePair> in, ConstantPool cpool, boolean copyPoolEntries) { | private List<NameValuePair> copyValues(List<NameValuePair> in, ConstantPool cpool, boolean copyPoolEntries) { | ||||
List<NameValuePair> out = new ArrayList<NameValuePair>(); | |||||
List<NameValuePair> out = new ArrayList<>(); | |||||
for (NameValuePair nvp : in) { | for (NameValuePair nvp : in) { | ||||
out.add(new NameValuePair(nvp, cpool, copyPoolEntries)); | out.add(new NameValuePair(nvp, cpool, copyPoolEntries)); | ||||
} | } | ||||
public void addElementNameValuePair(NameValuePair evp) { | public void addElementNameValuePair(NameValuePair evp) { | ||||
if (pairs == Collections.EMPTY_LIST) { | if (pairs == Collections.EMPTY_LIST) { | ||||
pairs = new ArrayList<NameValuePair>(); | |||||
pairs = new ArrayList<>(); | |||||
} | } | ||||
pairs.add(evp); | pairs.add(evp); | ||||
} | } |
public RuntimeAnnos(byte attrid, boolean visible, int nameIdx, int len, ConstantPool cpool) { | public RuntimeAnnos(byte attrid, boolean visible, int nameIdx, int len, ConstantPool cpool) { | ||||
super(attrid, nameIdx, len, cpool); | super(attrid, nameIdx, len, cpool); | ||||
this.visible = visible; | this.visible = visible; | ||||
annotations = new ArrayList<AnnotationGen>(); | |||||
annotations = new ArrayList<>(); | |||||
} | } | ||||
public RuntimeAnnos(byte attrid, boolean visible, int nameIdx, int len, byte[] data, ConstantPool cpool) { | public RuntimeAnnos(byte attrid, boolean visible, int nameIdx, int len, byte[] data, ConstantPool cpool) { | ||||
super(attrid, nameIdx, len, cpool); | super(attrid, nameIdx, len, cpool); | ||||
this.visible = visible; | this.visible = visible; | ||||
annotations = new ArrayList<AnnotationGen>(); | |||||
annotations = new ArrayList<>(); | |||||
annotation_data = data; | annotation_data = data; | ||||
} | } | ||||
DataInputStream dis = new DataInputStream(new ByteArrayInputStream(annotation_data)); | DataInputStream dis = new DataInputStream(new ByteArrayInputStream(annotation_data)); | ||||
int numberOfAnnotations = dis.readUnsignedShort(); | int numberOfAnnotations = dis.readUnsignedShort(); | ||||
if (numberOfAnnotations > 0) { | if (numberOfAnnotations > 0) { | ||||
List<AnnotationGen> inflatedAnnotations = new ArrayList<AnnotationGen>(); | |||||
List<AnnotationGen> inflatedAnnotations = new ArrayList<>(); | |||||
for (int i = 0; i < numberOfAnnotations; i++) { | for (int i = 0; i < numberOfAnnotations; i++) { | ||||
inflatedAnnotations.add(AnnotationGen.read(dis, getConstantPool(), visible)); | inflatedAnnotations.add(AnnotationGen.read(dis, getConstantPool(), visible)); | ||||
} | } |
int nameIdx, int len, ConstantPool cpool) { | int nameIdx, int len, ConstantPool cpool) { | ||||
super(attrid,nameIdx,len,cpool); | super(attrid,nameIdx,len,cpool); | ||||
this.visible = visible; | this.visible = visible; | ||||
parameterAnnotations = new ArrayList<AnnotationGen[]>(); | |||||
parameterAnnotations = new ArrayList<>(); | |||||
} | } | ||||
public RuntimeParamAnnos(byte attrid,boolean visible,int nameIdx,int len,byte[] data,ConstantPool cpool) { | public RuntimeParamAnnos(byte attrid,boolean visible,int nameIdx,int len,byte[] data,ConstantPool cpool) { | ||||
super(attrid,nameIdx,len,cpool); | super(attrid,nameIdx,len,cpool); | ||||
this.visible = visible; | this.visible = visible; | ||||
parameterAnnotations = new ArrayList<AnnotationGen[]>(); | |||||
parameterAnnotations = new ArrayList<>(); | |||||
annotation_data = data; | annotation_data = data; | ||||
} | } | ||||
DataInputStream dis = new DataInputStream(new ByteArrayInputStream(annotation_data)); | DataInputStream dis = new DataInputStream(new ByteArrayInputStream(annotation_data)); | ||||
int numParameters = dis.readUnsignedByte(); | int numParameters = dis.readUnsignedByte(); | ||||
if (numParameters > 0) { | if (numParameters > 0) { | ||||
List<AnnotationGen[]> inflatedParameterAnnotations = new ArrayList<AnnotationGen[]>(); | |||||
List<AnnotationGen[]> inflatedParameterAnnotations = new ArrayList<>(); | |||||
for (int i=0; i<numParameters; i++) { | for (int i=0; i<numParameters; i++) { | ||||
int numAnnotations = dis.readUnsignedShort(); | int numAnnotations = dis.readUnsignedShort(); | ||||
if (numAnnotations == 0 ) { | if (numAnnotations == 0 ) { |
private int major = Constants.MAJOR_1_1; | private int major = Constants.MAJOR_1_1; | ||||
private int minor = Constants.MINOR_1_1; | private int minor = Constants.MINOR_1_1; | ||||
private ConstantPool cpool; | private ConstantPool cpool; | ||||
private List<Field> fieldsList = new ArrayList<Field>(); | |||||
private List<Method> methodsList = new ArrayList<Method>(); | |||||
private List<Attribute> attributesList = new ArrayList<Attribute>(); | |||||
private List<String> interfaceList = new ArrayList<String>(); | |||||
private List<AnnotationGen> annotationsList = new ArrayList<AnnotationGen>(); | |||||
private List<Field> fieldsList = new ArrayList<>(); | |||||
private List<Method> methodsList = new ArrayList<>(); | |||||
private List<Attribute> attributesList = new ArrayList<>(); | |||||
private List<String> interfaceList = new ArrayList<>(); | |||||
private List<AnnotationGen> annotationsList = new ArrayList<>(); | |||||
public ClassGen(String classname, String superclassname, String filename, int modifiers, String[] interfacenames, | public ClassGen(String classname, String superclassname, String filename, int modifiers, String[] interfacenames, | ||||
ConstantPool cpool) { | ConstantPool cpool) { | ||||
attributes = attributesList; | attributes = attributesList; | ||||
} else { | } else { | ||||
// TODO: Sometime later, trash any attributes called 'RuntimeVisibleAnnotations' or 'RuntimeInvisibleAnnotations' | // TODO: Sometime later, trash any attributes called 'RuntimeVisibleAnnotations' or 'RuntimeInvisibleAnnotations' | ||||
attributes = new ArrayList<Attribute>(); | |||||
attributes = new ArrayList<>(); | |||||
attributes.addAll(Utility.getAnnotationAttributes(cpool, annotationsList)); | attributes.addAll(Utility.getAnnotationAttributes(cpool, annotationsList)); | ||||
attributes.addAll(attributesList); | attributes.addAll(attributesList); | ||||
} | } | ||||
// (relevant modifiers are ACC_PUBLIC, ACC_PRIVATE, | // (relevant modifiers are ACC_PUBLIC, ACC_PRIVATE, | ||||
// ACC_PROTECTED, ACC_STATIC, ACC_FINAL, ACC_VOLATILE, | // ACC_PROTECTED, ACC_STATIC, ACC_FINAL, ACC_VOLATILE, | ||||
// ACC_TRANSIENT) | // ACC_TRANSIENT) | ||||
List<Field> relevantFields = new ArrayList<Field>(); | |||||
List<Field> relevantFields = new ArrayList<>(); | |||||
for (Field field : fieldsList) { | for (Field field : fieldsList) { | ||||
if (!(field.isPrivate() && field.isStatic()) && !(field.isPrivate() && field.isTransient())) { | if (!(field.isPrivate() && field.isStatic()) && !(field.isPrivate() && field.isTransient())) { | ||||
relevantFields.add(field); | relevantFields.add(field); | ||||
} | } | ||||
// some up front method processing: discover clinit, init and ordinary methods of interest: | // some up front method processing: discover clinit, init and ordinary methods of interest: | ||||
List<Method> relevantMethods = new ArrayList<Method>(); | |||||
List<Method> relevantCtors = new ArrayList<Method>(); | |||||
List<Method> relevantMethods = new ArrayList<>(); | |||||
List<Method> relevantCtors = new ArrayList<>(); | |||||
boolean hasClinit = false; | boolean hasClinit = false; | ||||
for (Method m : methodsList) { | for (Method m : methodsList) { | ||||
boolean couldBeInitializer = m.getName().charAt(0) == '<'; | boolean couldBeInitializer = m.getName().charAt(0) == '<'; |
protected String name; | protected String name; | ||||
protected Type type; | protected Type type; | ||||
protected ConstantPool cp; | protected ConstantPool cp; | ||||
private ArrayList<Attribute> attributeList = new ArrayList<Attribute>(); | |||||
protected ArrayList<AnnotationGen> annotationList = new ArrayList<AnnotationGen>(); | |||||
private ArrayList<Attribute> attributeList = new ArrayList<>(); | |||||
protected ArrayList<AnnotationGen> annotationList = new ArrayList<>(); | |||||
protected FieldGenOrMethodGen() { | protected FieldGenOrMethodGen() { | ||||
} | } |
*/ | */ | ||||
public void addTargeter(InstructionTargeter t) { | public void addTargeter(InstructionTargeter t) { | ||||
if (targeters == Collections.EMPTY_SET) { | if (targeters == Collections.EMPTY_SET) { | ||||
targeters = new HashSet<InstructionTargeter>(); | |||||
targeters = new HashSet<>(); | |||||
} | } | ||||
targeters.add(t); | targeters.add(t); | ||||
} | } | ||||
} | } | ||||
public Set<InstructionTargeter> getTargetersCopy() { | public Set<InstructionTargeter> getTargetersCopy() { | ||||
Set<InstructionTargeter> copy = new HashSet<InstructionTargeter>(); | |||||
Set<InstructionTargeter> copy = new HashSet<>(); | |||||
copy.addAll(targeters); | copy.addAll(targeters); | ||||
return copy; | return copy; | ||||
} | } |
return; | return; | ||||
} | } | ||||
ArrayList<InstructionHandle> target_vec = new ArrayList<InstructionHandle>(); | |||||
ArrayList<InstructionHandle> target_vec = new ArrayList<>(); | |||||
for (InstructionHandle ih = first; ih != null; ih = ih.next) { | for (InstructionHandle ih = first; ih != null; ih = ih.next) { | ||||
ih.getInstruction().dispose(); // e.g. BranchInstructions release their targets | ih.getInstruction().dispose(); // e.g. BranchInstructions release their targets | ||||
*/ | */ | ||||
public Instruction[] getInstructions() { | public Instruction[] getInstructions() { | ||||
ByteSequence bytes = new ByteSequence(getByteCode()); | ByteSequence bytes = new ByteSequence(getByteCode()); | ||||
ArrayList<Instruction> instructions = new ArrayList<Instruction>(); | |||||
ArrayList<Instruction> instructions = new ArrayList<>(); | |||||
try { | try { | ||||
while (bytes.available() > 0) { | while (bytes.available() > 0) { | ||||
* @return complete, i.e., deep copy of this list | * @return complete, i.e., deep copy of this list | ||||
*/ | */ | ||||
public InstructionList copy() { | public InstructionList copy() { | ||||
HashMap<InstructionHandle, InstructionHandle> map = new HashMap<InstructionHandle, InstructionHandle>(); | |||||
HashMap<InstructionHandle, InstructionHandle> map = new HashMap<>(); | |||||
InstructionList il = new InstructionList(); | InstructionList il = new InstructionList(); | ||||
/* | /* |
private int highestLineNumber = 0; | private int highestLineNumber = 0; | ||||
private ArrayList<LocalVariableGen> localVariablesList = new ArrayList<LocalVariableGen>(); | |||||
private ArrayList<LineNumberGen> lineNumbersList = new ArrayList<LineNumberGen>(); | |||||
private ArrayList<CodeExceptionGen> exceptionsList = new ArrayList<CodeExceptionGen>(); | |||||
private ArrayList<String> exceptionsThrown = new ArrayList<String>(); | |||||
private ArrayList<Attribute> codeAttributesList = new ArrayList<Attribute>(); | |||||
private ArrayList<LocalVariableGen> localVariablesList = new ArrayList<>(); | |||||
private ArrayList<LineNumberGen> lineNumbersList = new ArrayList<>(); | |||||
private ArrayList<CodeExceptionGen> exceptionsList = new ArrayList<>(); | |||||
private ArrayList<String> exceptionsThrown = new ArrayList<>(); | |||||
private ArrayList<Attribute> codeAttributesList = new ArrayList<>(); | |||||
private List<AnnotationGen>[] param_annotations; // Array of lists containing AnnotationGen objects | private List<AnnotationGen>[] param_annotations; // Array of lists containing AnnotationGen objects | ||||
private boolean hasParameterAnnotations = false; | private boolean hasParameterAnnotations = false; | ||||
private boolean haveUnpackedParameterAnnotations = false; | private boolean haveUnpackedParameterAnnotations = false; | ||||
} | } | ||||
static final class BranchStack { | static final class BranchStack { | ||||
Stack<BranchTarget> branchTargets = new Stack<BranchTarget>(); | |||||
Hashtable<InstructionHandle, BranchTarget> visitedTargets = new Hashtable<InstructionHandle, BranchTarget>(); | |||||
Stack<BranchTarget> branchTargets = new Stack<>(); | |||||
Hashtable<InstructionHandle, BranchTarget> visitedTargets = new Hashtable<>(); | |||||
public void push(InstructionHandle target, int stackDepth) { | public void push(InstructionHandle target, int stackDepth) { | ||||
if (visited(target)) { | if (visited(target)) { | ||||
if (!hasParameterAnnotations) { | if (!hasParameterAnnotations) { | ||||
param_annotations = new List[parameterTypes.length]; | param_annotations = new List[parameterTypes.length]; | ||||
for (int j = 0; j < parameterTypes.length; j++) { | for (int j = 0; j < parameterTypes.length; j++) { | ||||
param_annotations[j] = new ArrayList<AnnotationGen>(); | |||||
param_annotations[j] = new ArrayList<>(); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
private List /* AnnotationGen */<AnnotationGen> makeMutableVersion(AnnotationGen[] mutableArray) { | private List /* AnnotationGen */<AnnotationGen> makeMutableVersion(AnnotationGen[] mutableArray) { | ||||
List<AnnotationGen> result = new ArrayList<AnnotationGen>(); | |||||
List<AnnotationGen> result = new ArrayList<>(); | |||||
for (AnnotationGen annotationGen : mutableArray) { | for (AnnotationGen annotationGen : mutableArray) { | ||||
result.add(new AnnotationGen(annotationGen, getConstantPool(), false)); | result.add(new AnnotationGen(annotationGen, getConstantPool(), false)); | ||||
} | } | ||||
if (existingAnnotations != null) { | if (existingAnnotations != null) { | ||||
existingAnnotations.add(annotation); | existingAnnotations.add(annotation); | ||||
} else { | } else { | ||||
List<AnnotationGen> l = new ArrayList<AnnotationGen>(); | |||||
List<AnnotationGen> l = new ArrayList<>(); | |||||
l.add(annotation); | l.add(annotation); | ||||
param_annotations[parameterIndex] = l; | param_annotations[parameterIndex] = l; | ||||
} | } |
public static final Type[] STRINGARRAY6 = new Type[] { STRING, STRING, STRING, STRING, STRING, STRING }; | public static final Type[] STRINGARRAY6 = new Type[] { STRING, STRING, STRING, STRING, STRING, STRING }; | ||||
public static final Type[] STRINGARRAY7 = new Type[] { STRING, STRING, STRING, STRING, STRING, STRING, STRING }; | public static final Type[] STRINGARRAY7 = new Type[] { STRING, STRING, STRING, STRING, STRING, STRING, STRING }; | ||||
private static Map<String, Type> commonTypes = new HashMap<String, Type>(); | |||||
private static Map<String, Type> commonTypes = new HashMap<>(); | |||||
static { | static { | ||||
commonTypes.put(STRING.getSignature(), STRING); | commonTypes.put(STRING.getSignature(), STRING); | ||||
*/ | */ | ||||
// OPTIMIZE crap impl | // OPTIMIZE crap impl | ||||
public static Type[] getArgumentTypes(String signature) { | public static Type[] getArgumentTypes(String signature) { | ||||
List<Type> argumentTypes = new ArrayList<Type>(); | |||||
List<Type> argumentTypes = new ArrayList<>(); | |||||
int index; | int index; | ||||
Type[] types; | Type[] types; | ||||
private ClassLoaderReference loaderRef; | private ClassLoaderReference loaderRef; | ||||
// Choice of cache... | // Choice of cache... | ||||
private WeakHashMap<URL, SoftReference<JavaClass>> localCache = new WeakHashMap<URL, SoftReference<JavaClass>>(); | |||||
private static SoftHashMap /* <URL,JavaClass> */sharedCache = new SoftHashMap(Collections.synchronizedMap(new HashMap<Object, SpecialValue>())); | |||||
private WeakHashMap<URL, SoftReference<JavaClass>> localCache = new WeakHashMap<>(); | |||||
private static SoftHashMap /* <URL,JavaClass> */sharedCache = new SoftHashMap(Collections.synchronizedMap(new HashMap<>())); | |||||
// For fast translation of the classname *intentionally not static* | // For fast translation of the classname *intentionally not static* | ||||
private SoftHashMap /* <String,URL> */nameMap = new SoftHashMap(new HashMap(), false); | private SoftHashMap /* <String,URL> */nameMap = new SoftHashMap(new HashMap(), false); | ||||
sharedCache.put(url, clazz); | sharedCache.put(url, clazz); | ||||
} else { | } else { | ||||
clazz.setRepository(this); | clazz.setRepository(this); | ||||
localCache.put(url, new SoftReference<JavaClass>(clazz)); | |||||
localCache.put(url, new SoftReference<>(clazz)); | |||||
} | } | ||||
} | } | ||||
public ClassPath(String class_path) { | public ClassPath(String class_path) { | ||||
this.class_path = class_path; | this.class_path = class_path; | ||||
ArrayList<PathEntry> vec = new ArrayList<PathEntry>(); | |||||
ArrayList<PathEntry> vec = new ArrayList<>(); | |||||
for (StringTokenizer tok = new StringTokenizer(class_path, System.getProperty("path.separator")); tok | for (StringTokenizer tok = new StringTokenizer(class_path, System.getProperty("path.separator")); tok | ||||
.hasMoreTokens();) { | .hasMoreTokens();) { | ||||
String ext_path = System.getProperty("java.ext.dirs"); | String ext_path = System.getProperty("java.ext.dirs"); | ||||
String vm_version = System.getProperty("java.version"); | String vm_version = System.getProperty("java.version"); | ||||
ArrayList<String> list = new ArrayList<String>(); | |||||
ArrayList<String> list = new ArrayList<>(); | |||||
getPathComponents(class_path, list); | getPathComponents(class_path, list); | ||||
getPathComponents(boot_path, list); | getPathComponents(boot_path, list); | ||||
ArrayList<String> dirs = new ArrayList<String>(); | |||||
ArrayList<String> dirs = new ArrayList<>(); | |||||
getPathComponents(ext_path, dirs); | getPathComponents(ext_path, dirs); | ||||
for (String string : dirs) { | for (String string : dirs) { |
} | } | ||||
public SoftHashMap() { | public SoftHashMap() { | ||||
this(new HashMap<Object,SpecialValue>()); | |||||
this(new HashMap<>()); | |||||
} | } | ||||
public SoftHashMap(Map<Object,SpecialValue> map, boolean b) { | public SoftHashMap(Map<Object,SpecialValue> map, boolean b) { |
public class SyntheticRepository implements Repository { | public class SyntheticRepository implements Repository { | ||||
private static final String DEFAULT_PATH = ClassPath.getClassPath(); | private static final String DEFAULT_PATH = ClassPath.getClassPath(); | ||||
private static HashMap<ClassPath, SyntheticRepository> _instances = new HashMap<ClassPath, SyntheticRepository>(); // CLASSPATH | |||||
private static HashMap<ClassPath, SyntheticRepository> _instances = new HashMap<>(); // CLASSPATH | |||||
// X | // X | ||||
// REPOSITORY | // REPOSITORY | ||||
private ClassPath _path = null; | private ClassPath _path = null; | ||||
private WeakHashMap<String, JavaClass> _loadedClasses = new WeakHashMap<String, JavaClass>(); // CLASSNAME X JAVACLASS | |||||
private WeakHashMap<String, JavaClass> _loadedClasses = new WeakHashMap<>(); // CLASSNAME X JAVACLASS | |||||
private SyntheticRepository(ClassPath path) { | private SyntheticRepository(ClassPath path) { | ||||
_path = path; | _path = path; |
ObjectType t = new ObjectType("SimpleAnnotation"); | ObjectType t = new ObjectType("SimpleAnnotation"); | ||||
List<NameValuePair> elements = new ArrayList<NameValuePair>(); | |||||
List<NameValuePair> elements = new ArrayList<>(); | |||||
elements.add(nvGen); | elements.add(nvGen); | ||||
// Build an annotation of type 'SimpleAnnotation' with 'id=4' as the only value :) | // Build an annotation of type 'SimpleAnnotation' with 'id=4' as the only value :) | ||||
ObjectType t = new ObjectType("SimpleAnnotation"); | ObjectType t = new ObjectType("SimpleAnnotation"); | ||||
List<NameValuePair> elements = new ArrayList<NameValuePair>(); | |||||
List<NameValuePair> elements = new ArrayList<>(); | |||||
elements.add(nvGen); | elements.add(nvGen); | ||||
// Build a RV annotation of type 'SimpleAnnotation' with 'id=4' as the only value :) | // Build a RV annotation of type 'SimpleAnnotation' with 'id=4' as the only value :) | ||||
AnnotationGen a = new AnnotationGen(t, elements, true, cp); | AnnotationGen a = new AnnotationGen(t, elements, true, cp); | ||||
Vector<AnnotationGen> v = new Vector<AnnotationGen>(); | |||||
Vector<AnnotationGen> v = new Vector<>(); | |||||
v.add(a); | v.add(a); | ||||
Collection<RuntimeAnnos> attributes = Utility.getAnnotationAttributes(cp, v); | Collection<RuntimeAnnos> attributes = Utility.getAnnotationAttributes(cp, v); | ||||
boolean foundRV = false; | boolean foundRV = false; | ||||
// Build a RIV annotation of type 'SimpleAnnotation' with 'id=4' as the only value :) | // Build a RIV annotation of type 'SimpleAnnotation' with 'id=4' as the only value :) | ||||
AnnotationGen a2 = new AnnotationGen(t, elements, false, cp); | AnnotationGen a2 = new AnnotationGen(t, elements, false, cp); | ||||
Vector<AnnotationGen> v2 = new Vector<AnnotationGen>(); | |||||
Vector<AnnotationGen> v2 = new Vector<>(); | |||||
v2.add(a2); | v2.add(a2); | ||||
Collection<RuntimeAnnos> attributes2 = Utility.getAnnotationAttributes(cp, v2); | Collection<RuntimeAnnos> attributes2 = Utility.getAnnotationAttributes(cp, v2); | ||||
boolean foundRIV = false; | boolean foundRIV = false; |
protected Attribute[] findAttribute(String name, JavaClass clazz) { | protected Attribute[] findAttribute(String name, JavaClass clazz) { | ||||
Attribute[] all = clazz.getAttributes(); | Attribute[] all = clazz.getAttributes(); | ||||
List<Attribute> chosenAttrsList = new ArrayList<Attribute>(); | |||||
List<Attribute> chosenAttrsList = new ArrayList<>(); | |||||
for (Attribute attribute : all) { | for (Attribute attribute : all) { | ||||
if (verbose) | if (verbose) | ||||
System.err.println("Attribute: " + attribute.getName()); | System.err.println("Attribute: " + attribute.getName()); | ||||
} | } | ||||
protected Attribute findAttribute(String name, Attribute[] all) { | protected Attribute findAttribute(String name, Attribute[] all) { | ||||
List<Attribute> chosenAttrsList = new ArrayList<Attribute>(); | |||||
List<Attribute> chosenAttrsList = new ArrayList<>(); | |||||
for (Attribute attribute : all) { | for (Attribute attribute : all) { | ||||
if (verbose) | if (verbose) | ||||
System.err.println("Attribute: " + attribute.getName()); | System.err.println("Attribute: " + attribute.getName()); | ||||
SimpleElementValue evg = new SimpleElementValue(ElementValue.STRING, cp, aFruit); | SimpleElementValue evg = new SimpleElementValue(ElementValue.STRING, cp, aFruit); | ||||
NameValuePair nvGen = new NameValuePair("fruit", evg, cp); | NameValuePair nvGen = new NameValuePair("fruit", evg, cp); | ||||
ObjectType t = new ObjectType("SimpleStringAnnotation"); | ObjectType t = new ObjectType("SimpleStringAnnotation"); | ||||
List<NameValuePair> elements = new ArrayList<NameValuePair>(); | |||||
List<NameValuePair> elements = new ArrayList<>(); | |||||
elements.add(nvGen); | elements.add(nvGen); | ||||
return new AnnotationGen(t, elements, visibility, cp); | return new AnnotationGen(t, elements, visibility, cp); | ||||
} | } |
ObjectType t = new ObjectType("SimpleAnnotation"); | ObjectType t = new ObjectType("SimpleAnnotation"); | ||||
List<NameValuePair> elements = new ArrayList<NameValuePair>(); | |||||
List<NameValuePair> elements = new ArrayList<>(); | |||||
elements.add(nvGen); | elements.add(nvGen); | ||||
AnnotationGen a = new AnnotationGen(t, elements, true, cp); | AnnotationGen a = new AnnotationGen(t, elements, true, cp); | ||||
SimpleElementValue evg = new SimpleElementValue(ElementValue.STRING, cp, aFruit); | SimpleElementValue evg = new SimpleElementValue(ElementValue.STRING, cp, aFruit); | ||||
NameValuePair nvGen = new NameValuePair("fruit", evg, cp); | NameValuePair nvGen = new NameValuePair("fruit", evg, cp); | ||||
ObjectType t = new ObjectType("SimpleStringAnnotation"); | ObjectType t = new ObjectType("SimpleStringAnnotation"); | ||||
List<NameValuePair> elements = new ArrayList<NameValuePair>(); | |||||
List<NameValuePair> elements = new ArrayList<>(); | |||||
elements.add(nvGen); | elements.add(nvGen); | ||||
return new AnnotationGen(t, elements, true, cp); | return new AnnotationGen(t, elements, true, cp); | ||||
} | } | ||||
ArrayElementValue array = new ArrayElementValue(cp); | ArrayElementValue array = new ArrayElementValue(cp); | ||||
array.addElement(new AnnotationElementValue(a, cp)); | array.addElement(new AnnotationElementValue(a, cp)); | ||||
NameValuePair nvp = new NameValuePair("value", array, cp); | NameValuePair nvp = new NameValuePair("value", array, cp); | ||||
List<NameValuePair> elements = new ArrayList<NameValuePair>(); | |||||
List<NameValuePair> elements = new ArrayList<>(); | |||||
elements.add(nvp); | elements.add(nvp); | ||||
return new AnnotationGen(new ObjectType("CombinedAnnotation"), elements, true, cp); | return new AnnotationGen(new ObjectType("CombinedAnnotation"), elements, true, cp); | ||||
} | } | ||||
ObjectType t = new ObjectType("SimpleAnnotation"); | ObjectType t = new ObjectType("SimpleAnnotation"); | ||||
List<NameValuePair> elements = new ArrayList<NameValuePair>(); | |||||
List<NameValuePair> elements = new ArrayList<>(); | |||||
elements.add(nvGen); | elements.add(nvGen); | ||||
AnnotationGen a = new AnnotationGen(t, elements, false, cp); | AnnotationGen a = new AnnotationGen(t, elements, false, cp); |
* @return Array of argument types | * @return Array of argument types | ||||
*/ | */ | ||||
public static final String[] methodSignatureArgumentTypes(String signature,boolean chopit) throws ClassFormatException { | public static final String[] methodSignatureArgumentTypes(String signature,boolean chopit) throws ClassFormatException { | ||||
ArrayList<String> vec = new ArrayList<String>(); | |||||
ArrayList<String> vec = new ArrayList<>(); | |||||
int index; | int index; | ||||
String[] types; | String[] types; | ||||
} | } | ||||
public void testConcurrency() throws ClassNotFoundException, InterruptedException { | public void testConcurrency() throws ClassNotFoundException, InterruptedException { | ||||
List<DoneChecker> loaders = new ArrayList<DoneChecker>(); | |||||
List<DoneChecker> loaders = new ArrayList<>(); | |||||
int i1 = 1000; | int i1 = 1000; | ||||
for (int i = 0; i < i1; i++) { | for (int i = 0; i < i1; i++) { | ||||
DoneChecker loader = new Loader(); | DoneChecker loader = new Loader(); |
ObjectType t = new ObjectType("SimpleAnnotation"); | ObjectType t = new ObjectType("SimpleAnnotation"); | ||||
List<NameValuePair> elements = new ArrayList<NameValuePair>(); | |||||
List<NameValuePair> elements = new ArrayList<>(); | |||||
elements.add(nvGen); | elements.add(nvGen); | ||||
AnnotationGen a = new AnnotationGen(t, elements,true, cp); | AnnotationGen a = new AnnotationGen(t, elements,true, cp); | ||||
ArrayElementValue array = new ArrayElementValue(cp); | ArrayElementValue array = new ArrayElementValue(cp); | ||||
array.addElement(new AnnotationElementValue(a,cp)); | array.addElement(new AnnotationElementValue(a,cp)); | ||||
NameValuePair nvp = new NameValuePair("value",array,cp); | NameValuePair nvp = new NameValuePair("value",array,cp); | ||||
List<NameValuePair> elements = new ArrayList<NameValuePair>(); | |||||
List<NameValuePair> elements = new ArrayList<>(); | |||||
elements.add(nvp); | elements.add(nvp); | ||||
return new AnnotationGen(new ObjectType("CombinedAnnotation"),elements,true,cp); | return new AnnotationGen(new ObjectType("CombinedAnnotation"),elements,true,cp); | ||||
} | } | ||||
ObjectType t = new ObjectType("SimpleAnnotation"); | ObjectType t = new ObjectType("SimpleAnnotation"); | ||||
List<NameValuePair> elements = new ArrayList<NameValuePair>(); | |||||
List<NameValuePair> elements = new ArrayList<>(); | |||||
elements.add(nvGen); | elements.add(nvGen); | ||||
AnnotationGen a = new AnnotationGen(t, elements,false, cp); | AnnotationGen a = new AnnotationGen(t, elements,false, cp); |
public static List<String> getListOfAnnotationNames(AnnotationGen a) { | public static List<String> getListOfAnnotationNames(AnnotationGen a) { | ||||
List<NameValuePair> l = a.getValues(); | List<NameValuePair> l = a.getValues(); | ||||
List<String> names = new ArrayList<String>(); | |||||
List<String> names = new ArrayList<>(); | |||||
for (NameValuePair element : l) { | for (NameValuePair element : l) { | ||||
names.add(element.getNameString()); | names.add(element.getNameString()); | ||||
} | } |
/** used when message text is null */ | /** used when message text is null */ | ||||
public static final String NO_MESSAGE_TEXT = "AbortException (no message)"; | public static final String NO_MESSAGE_TEXT = "AbortException (no message)"; | ||||
private static final ArrayList<AbortException> porters = new ArrayList<AbortException>(); | |||||
private static final ArrayList<AbortException> porters = new ArrayList<>(); | |||||
/** | /** | ||||
* Get a porter exception from the pool. Porter exceptions do <b>not</b> have valid stack traces. They are used only to avoid | * Get a porter exception from the pool. Porter exceptions do <b>not</b> have valid stack traces. They are used only to avoid |
public CountingMessageHandler(IMessageHandler delegate) { | public CountingMessageHandler(IMessageHandler delegate) { | ||||
LangUtil.throwIaxIfNull(delegate, "delegate"); | LangUtil.throwIaxIfNull(delegate, "delegate"); | ||||
this.delegate = delegate; | this.delegate = delegate; | ||||
this.counters = new Hashtable<IMessage.Kind, IntHolder>(); | |||||
this.counters = new Hashtable<>(); | |||||
proxy = (delegate instanceof CountingMessageHandler ? (CountingMessageHandler) delegate : null); | proxy = (delegate instanceof CountingMessageHandler ? (CountingMessageHandler) delegate : null); | ||||
} | } | ||||
* @param accumulateOnly the result of handleMessage (i.e., if true, then only accumulate messages - stop processing | * @param accumulateOnly the result of handleMessage (i.e., if true, then only accumulate messages - stop processing | ||||
*/ | */ | ||||
public MessageHandler(boolean accumulateOnly) { | public MessageHandler(boolean accumulateOnly) { | ||||
messages = new ArrayList<IMessage>(); | |||||
ignoring = new ArrayList<IMessage.Kind>(); | |||||
messages = new ArrayList<>(); | |||||
ignoring = new ArrayList<>(); | |||||
init(accumulateOnly); | init(accumulateOnly); | ||||
ignore(IMessage.WEAVEINFO); // Off by default, need to explicitly be enabled (see -showWeaveInfo) | ignore(IMessage.WEAVEINFO); // Off by default, need to explicitly be enabled (see -showWeaveInfo) | ||||
} | } | ||||
if (null == kind) { | if (null == kind) { | ||||
return messages.toArray(IMessage.RA_IMessage); | return messages.toArray(IMessage.RA_IMessage); | ||||
} | } | ||||
ArrayList<IMessage> result = new ArrayList<IMessage>(); | |||||
ArrayList<IMessage> result = new ArrayList<>(); | |||||
if (!orGreater) { | if (!orGreater) { | ||||
for (IMessage m : messages) { | for (IMessage m : messages) { | ||||
if (kind == m.getKind()) { | if (kind == m.getKind()) { |
if (null == kind) { | if (null == kind) { | ||||
return messages; | return messages; | ||||
} | } | ||||
ArrayList<IMessage> result = new ArrayList<IMessage>(); | |||||
ArrayList<IMessage> result = new ArrayList<>(); | |||||
for (IMessage message : messages) { | for (IMessage message : messages) { | ||||
if (kind == message.getKind()) { | if (kind == message.getKind()) { | ||||
result.add(message); | result.add(message); | ||||
return IMessage.RA_IMessage; | return IMessage.RA_IMessage; | ||||
} | } | ||||
LangUtil.throwIaxIfNull(visitor, "visitor"); | LangUtil.throwIaxIfNull(visitor, "visitor"); | ||||
ArrayList<IMessage> result = (accumulate ? new ArrayList<IMessage>() : null); | |||||
ArrayList<IMessage> result = (accumulate ? new ArrayList<>() : null); | |||||
for (IMessage m : messages) { | for (IMessage m : messages) { | ||||
if (visitor.handleMessage(m)) { | if (visitor.handleMessage(m)) { | ||||
if (accumulate) { | if (accumulate) { |
"type munging for @AspectJ aspectOf" }; | "type munging for @AspectJ aspectOf" }; | ||||
// context stacks, one per thread | // context stacks, one per thread | ||||
private static ThreadLocal<Stack<ContextStackEntry>> contextMap = new ThreadLocal<Stack<ContextStackEntry>>(); | |||||
private static ThreadLocal<Stack<ContextStackEntry>> contextMap = new ThreadLocal<>(); | |||||
// single thread mode stack | // single thread mode stack | ||||
private static Stack<ContextStackEntry> contextStack = new Stack<ContextStackEntry>(); | |||||
private static Stack<ContextStackEntry> contextStack = new Stack<>(); | |||||
// formatters, by phase id | // formatters, by phase id | ||||
private static Map<Integer, ContextFormatter> formatterMap = new HashMap<Integer, ContextFormatter>(); | |||||
private static Map<Integer, ContextFormatter> formatterMap = new HashMap<>(); | |||||
private static ContextFormatter defaultFormatter = new DefaultFormatter(); | private static ContextFormatter defaultFormatter = new DefaultFormatter(); | ||||
*/ | */ | ||||
public static String getCurrentContext() { | public static String getCurrentContext() { | ||||
Stack<ContextStackEntry> contextStack = getContextStack(); | Stack<ContextStackEntry> contextStack = getContextStack(); | ||||
Stack<String> explanationStack = new Stack<String>(); | |||||
Stack<String> explanationStack = new Stack<>(); | |||||
for (ContextStackEntry entry : contextStack) { | for (ContextStackEntry entry : contextStack) { | ||||
Object data = entry.getData(); | Object data = entry.getData(); | ||||
if (data != null) { | if (data != null) { | ||||
public static ContextToken enteringPhase(int phaseId, Object data) { | public static ContextToken enteringPhase(int phaseId, Object data) { | ||||
Stack<ContextStackEntry> contextStack = getContextStack(); | Stack<ContextStackEntry> contextStack = getContextStack(); | ||||
ContextTokenImpl nextToken = nextToken(); | ContextTokenImpl nextToken = nextToken(); | ||||
contextStack.push(new ContextStackEntry(nextToken, phaseId, new WeakReference<Object>(data))); | |||||
contextStack.push(new ContextStackEntry(nextToken, phaseId, new WeakReference<>(data))); | |||||
return nextToken; | return nextToken; | ||||
} | } | ||||
} else { | } else { | ||||
Stack<ContextStackEntry> contextStack = contextMap.get(); | Stack<ContextStackEntry> contextStack = contextMap.get(); | ||||
if (contextStack == null) { | if (contextStack == null) { | ||||
contextStack = new Stack<ContextStackEntry>(); | |||||
contextStack = new Stack<>(); | |||||
contextMap.set(contextStack); | contextMap.set(contextStack); | ||||
} | } | ||||
return contextStack; | return contextStack; |
*/ | */ | ||||
@Override | @Override | ||||
protected Result[] getAntecedantResults(Result moduleResult) { | protected Result[] getAntecedantResults(Result moduleResult) { | ||||
Hashtable<String,Target> targets = new Hashtable<String, Target>(); | |||||
Hashtable<String,Target> targets = new Hashtable<>(); | |||||
makeTargetsForResult(moduleResult, targets); | makeTargetsForResult(moduleResult, targets); | ||||
String targetName = resultToTargetName(moduleResult); | String targetName = resultToTargetName(moduleResult); | ||||
// bug: doc says topoSort returns String, but returns Target | // bug: doc says topoSort returns String, but returns Target | ||||
if (0 == result.size()) { | if (0 == result.size()) { | ||||
return new Result[0]; | return new Result[0]; | ||||
} | } | ||||
ArrayList<String> toReturn = new ArrayList<String>(); | |||||
ArrayList<String> toReturn = new ArrayList<>(); | |||||
for (Target target : result) { | for (Target target : result) { | ||||
String name = target.getName(); | String name = target.getName(); | ||||
if (null == name) { | if (null == name) { |
License MPL_ONLY = new License(MPL_ONLY_TAG, LIC_MPL); | License MPL_ONLY = new License(MPL_ONLY_TAG, LIC_MPL); | ||||
License MPL_PARC = new License(MPL_PARC_TAG, LIC_MPL, PARC); | License MPL_PARC = new License(MPL_PARC_TAG, LIC_MPL, PARC); | ||||
License PARC_COPYRIGHT = new License(PARC_COPYRIGHT_TAG, null, PARC); | License PARC_COPYRIGHT = new License(PARC_COPYRIGHT_TAG, null, PARC); | ||||
LICENSES = new Hashtable<String,License>(); | |||||
LICENSES = new Hashtable<>(); | |||||
LICENSES.put(APL.tag, APL); | LICENSES.put(APL.tag, APL); | ||||
LICENSES.put(MPL.tag, MPL); | LICENSES.put(MPL.tag, MPL); | ||||
LICENSES.put(MPL_PARC.tag, MPL_PARC); | LICENSES.put(MPL_PARC.tag, MPL_PARC); | ||||
this.lastLine = lastLine; | this.lastLine = lastLine; | ||||
this.file = file; | this.file = file; | ||||
this.hasLicense = hasLicense; | this.hasLicense = hasLicense; | ||||
List<String> newYears = new ArrayList<String>(); | |||||
List<String> newYears = new ArrayList<>(); | |||||
newYears.addAll(years); | newYears.addAll(years); | ||||
Collections.sort(newYears); | Collections.sort(newYears); | ||||
this.years = Collections.unmodifiableList(newYears); | this.years = Collections.unmodifiableList(newYears); | ||||
} | } | ||||
public static HeaderInfo checkFile(final File file) { | public static HeaderInfo checkFile(final File file) { | ||||
ArrayList<String> years = new ArrayList<String>(); | |||||
ArrayList<String> years = new ArrayList<>(); | |||||
int endLine = 0; | int endLine = 0; | ||||
BufferedReader input = null; | BufferedReader input = null; | ||||
int lineNum = 0; | int lineNum = 0; |
private List<If> ifs; | private List<If> ifs; | ||||
protected List<If> ifs() { | protected List<If> ifs() { | ||||
return ifs != null ? ifs : (ifs = new Vector<If>()); | |||||
return ifs != null ? ifs : (ifs = new Vector<>()); | |||||
} | } | ||||
public If createIf() { | public If createIf() { | ||||
protected List<String> getFalses() { | protected List<String> getFalses() { | ||||
Iterator<If> iter = ifs().iterator(); | Iterator<If> iter = ifs().iterator(); | ||||
List<String> result = new Vector<String>(); | |||||
List<String> result = new Vector<>(); | |||||
while (iter.hasNext()) { | while (iter.hasNext()) { | ||||
If next = iter.next(); | If next = iter.next(); | ||||
String name = next.getName(); | String name = next.getName(); |
if ((null == text) || (0 == text.length())) { | if ((null == text) || (0 == text.length())) { | ||||
return Collections.EMPTY_LIST; | return Collections.EMPTY_LIST; | ||||
} | } | ||||
List<String> strings = new ArrayList<String>(); | |||||
List<String> strings = new ArrayList<>(); | |||||
StringTokenizer tok = new StringTokenizer(text, ","); | StringTokenizer tok = new StringTokenizer(text, ","); | ||||
while (tok.hasMoreTokens()) { | while (tok.hasMoreTokens()) { | ||||
String token = tok.nextToken().trim(); | String token = tok.nextToken().trim(); | ||||
return buildProduct(buildSpec); | return buildProduct(buildSpec); | ||||
} | } | ||||
Result result = specifyResultFor(buildSpec); | Result result = specifyResultFor(buildSpec); | ||||
ArrayList<String> errors = new ArrayList<String>(); | |||||
ArrayList<String> errors = new ArrayList<>(); | |||||
try { | try { | ||||
return buildAll(result, errors); | return buildAll(result, errors); | ||||
} finally { | } finally { | ||||
*/ | */ | ||||
protected final boolean buildAll(Result result, List<String> errors) { | protected final boolean buildAll(Result result, List<String> errors) { | ||||
Result[] buildList = skipUptodate(getAntecedantResults(result)); | Result[] buildList = skipUptodate(getAntecedantResults(result)); | ||||
ArrayList<String> doneList = new ArrayList<String>(); | |||||
ArrayList<String> doneList = new ArrayList<>(); | |||||
if ((null != buildList) && (0 < buildList.length)) { | if ((null != buildList) && (0 < buildList.length)) { | ||||
if (isLogging()) { | if (isLogging()) { | ||||
handler.log("modules to build: " + Arrays.asList(buildList)); | handler.log("modules to build: " + Arrays.asList(buildList)); | ||||
* deliverables. | * deliverables. | ||||
*/ | */ | ||||
protected ProductModule[] discoverModules(File productDir, Modules modules) { | protected ProductModule[] discoverModules(File productDir, Modules modules) { | ||||
final ArrayList<File> found = new ArrayList<File>(); | |||||
final ArrayList<File> found = new ArrayList<>(); | |||||
FileFilter filter = new FileFilter() {// empty jar files | FileFilter filter = new FileFilter() {// empty jar files | ||||
public boolean accept(File file) { | public boolean accept(File file) { | ||||
if ((null != file) && file.canRead() | if ((null != file) && file.canRead() | ||||
} | } | ||||
}; | }; | ||||
Util.visitFiles(productDir, filter); | Util.visitFiles(productDir, filter); | ||||
ArrayList<ProductModule> results = new ArrayList<ProductModule>(); | |||||
ArrayList<ProductModule> results = new ArrayList<>(); | |||||
for (File file: found) { | for (File file: found) { | ||||
String jarName = moduleAliasFor(file.getName().toLowerCase()); | String jarName = moduleAliasFor(file.getName().toLowerCase()); | ||||
if (jarName.endsWith(".jar") || jarName.endsWith(".zip")) { // XXXFileLiteral | if (jarName.endsWith(".jar") || jarName.endsWith(".zip")) { // XXXFileLiteral |
/** @return all source files under srcDir */ | /** @return all source files under srcDir */ | ||||
private static Iterator<File> sourceFiles(File srcDir) { | private static Iterator<File> sourceFiles(File srcDir) { | ||||
ArrayList<File> result = new ArrayList<File>(); | |||||
ArrayList<File> result = new ArrayList<>(); | |||||
sourceFiles(srcDir, result); | sourceFiles(srcDir, result); | ||||
return result.iterator(); | return result.iterator(); | ||||
} | } | ||||
Util.iaxIfNull(name, "name"); | Util.iaxIfNull(name, "name"); | ||||
Util.iaxIfNull(modules, "modules"); | Util.iaxIfNull(modules, "modules"); | ||||
this.moduleDir = moduleDir; | this.moduleDir = moduleDir; | ||||
this.libJars = new ArrayList<File>(); | |||||
this.exportedLibJars = new ArrayList<File>(); | |||||
this.requiredModules = new ArrayList<Module>(); | |||||
this.srcDirs = new ArrayList<File>(); | |||||
this.classpathVariables = new ArrayList<String>(); | |||||
this.libJars = new ArrayList<>(); | |||||
this.exportedLibJars = new ArrayList<>(); | |||||
this.requiredModules = new ArrayList<>(); | |||||
this.srcDirs = new ArrayList<>(); | |||||
this.classpathVariables = new ArrayList<>(); | |||||
this.properties = new Properties(); | this.properties = new Properties(); | ||||
this.name = name; | this.name = name; | ||||
this.modules = modules; | this.modules = modules; | ||||
String[] tokenize(String line) { | String[] tokenize(String line) { | ||||
final String DELIM = " \n\t\\<>\"="; | final String DELIM = " \n\t\\<>\"="; | ||||
StringTokenizer st = new StringTokenizer(line, DELIM, true); | StringTokenizer st = new StringTokenizer(line, DELIM, true); | ||||
ArrayList<String> result = new ArrayList<String>(); | |||||
ArrayList<String> result = new ArrayList<>(); | |||||
StringBuffer quote = new StringBuffer(); | StringBuffer quote = new StringBuffer(); | ||||
boolean inQuote = false; | boolean inQuote = false; | ||||
while (st.hasMoreTokens()) { | while (st.hasMoreTokens()) { |
*/ | */ | ||||
public class Modules { | public class Modules { | ||||
private final Hashtable<String,Module> modules = new Hashtable<String,Module>(); | |||||
private final Hashtable<String,Module> modules = new Hashtable<>(); | |||||
public final File baseDir; | public final File baseDir; | ||||
public final File jarDir; | public final File jarDir; | ||||
private final Messager handler; | private final Messager handler; |
private static final Kind[] KINDS = { RELEASE, TEST, RELEASE_ALL, TEST_ALL }; | private static final Kind[] KINDS = { RELEASE, TEST, RELEASE_ALL, TEST_ALL }; | ||||
private static final HashMap<String,Result> nameToResult = new HashMap<String, Result>(); | |||||
private static final HashMap<String,Result> nameToResult = new HashMap<>(); | |||||
public static boolean isTestingJar(String name) { | public static boolean isTestingJar(String name) { | ||||
name = name.toLowerCase(); | name = name.toLowerCase(); | ||||
Result(Kind kind, Module module, File jarDir) { | Result(Kind kind, Module module, File jarDir) { | ||||
this.kind = kind; | this.kind = kind; | ||||
this.module = module; | this.module = module; | ||||
this.libJars = new ArrayList<File>(); | |||||
this.exportedLibJars = new ArrayList<File>(); | |||||
this.srcDirs = new ArrayList<File>(); | |||||
this.classpathVariables = new ArrayList<String>(); | |||||
this.requiredResults = new ArrayList<Result>(); | |||||
this.libJars = new ArrayList<>(); | |||||
this.exportedLibJars = new ArrayList<>(); | |||||
this.srcDirs = new ArrayList<>(); | |||||
this.classpathVariables = new ArrayList<>(); | |||||
this.requiredResults = new ArrayList<>(); | |||||
String name = module.name; | String name = module.name; | ||||
if (!kind.normal) { | if (!kind.normal) { | ||||
name += "-test"; | name += "-test"; | ||||
/** @return List (File) of jar's required */ | /** @return List (File) of jar's required */ | ||||
public List<File> findJarRequirements() { | public List<File> findJarRequirements() { | ||||
ArrayList<File> result = new ArrayList<File>(); | |||||
ArrayList<File> result = new ArrayList<>(); | |||||
Module.doFindJarRequirements(this, result); | Module.doFindJarRequirements(this, result); | ||||
return result; | return result; | ||||
} | } |
* type-safe Collection of samples. | * type-safe Collection of samples. | ||||
*/ | */ | ||||
class Samples { | class Samples { | ||||
private ArrayList<Sample> samples = new ArrayList<Sample>(); | |||||
private ArrayList<Sample> samples = new ArrayList<>(); | |||||
int size() { | int size() { | ||||
return samples.size(); | return samples.size(); | ||||
} | } | ||||
} | } | ||||
List<Sample> getSortedSamples(Comparator<Sample> comparer) { | List<Sample> getSortedSamples(Comparator<Sample> comparer) { | ||||
ArrayList<Sample> result = new ArrayList<Sample>(); | |||||
ArrayList<Sample> result = new ArrayList<>(); | |||||
result.addAll(samples); | result.addAll(samples); | ||||
Collections.sort(result, comparer); | Collections.sort(result, comparer); | ||||
return result; | return result; | ||||
} | } | ||||
public static String[] splitAnchorName(String anchorName) { | public static String[] splitAnchorName(String anchorName) { | ||||
ArrayList<String> result = new ArrayList<String>(); | |||||
ArrayList<String> result = new ArrayList<>(); | |||||
int start = 0; | int start = 0; | ||||
int loc = anchorName.indexOf("-", start); | int loc = anchorName.indexOf("-", start); | ||||
String next; | String next; |
* @return | * @return | ||||
*/ | */ | ||||
private static File[] findSourceRoots(File moduleDir) { | private static File[] findSourceRoots(File moduleDir) { | ||||
ArrayList<File> result = new ArrayList<File>(); | |||||
ArrayList<File> result = new ArrayList<>(); | |||||
for (String name: SOURCE_NAMES) { | for (String name: SOURCE_NAMES) { | ||||
File srcDir = new File(moduleDir, name); | File srcDir = new File(moduleDir, name); | ||||
if (srcDir.canRead() && srcDir.isDirectory()) { | if (srcDir.canRead() && srcDir.isDirectory()) { | ||||
// separate check to verify all file types (suffixes) are known | // separate check to verify all file types (suffixes) are known | ||||
if (!isTestFolder(srcDir)) { | if (!isTestFolder(srcDir)) { | ||||
ArrayList<File> unknownFiles = new ArrayList<File>(); | |||||
ArrayList<File> unknownFiles = new ArrayList<>(); | |||||
UnknownFileCheck.SINGLETON.unknownFiles(srcDir, unknownFiles); | UnknownFileCheck.SINGLETON.unknownFiles(srcDir, unknownFiles); | ||||
System.out.println(unknownFiles); | System.out.println(unknownFiles); | ||||
if (!unknownFiles.isEmpty()) { | if (!unknownFiles.isEmpty()) { | ||||
*/ | */ | ||||
static class UnknownFileCheck implements FileFilter { | static class UnknownFileCheck implements FileFilter { | ||||
private static final UnknownFileCheck SINGLETON = new UnknownFileCheck(); | private static final UnknownFileCheck SINGLETON = new UnknownFileCheck(); | ||||
private static final ArrayList<String> STATIC_ERRORS = new ArrayList<String>(); | |||||
private static final ArrayList<String> STATIC_ERRORS = new ArrayList<>(); | |||||
// Builder.BINARY_SOURCE_PATTERN and Builder.RESOURCE_PATTERN | // Builder.BINARY_SOURCE_PATTERN and Builder.RESOURCE_PATTERN | ||||
public static final List<String> KNOWN_SUFFIXES; | public static final List<String> KNOWN_SUFFIXES; | ||||
static { | static { | ||||
List<String> suffixes = new ArrayList<String>(); | |||||
List<String> suffixes = new ArrayList<>(); | |||||
// sources from org.aspectj.util.FileUtil.SOURCE_SUFFIXES | // sources from org.aspectj.util.FileUtil.SOURCE_SUFFIXES | ||||
suffixes.add(".aj"); | suffixes.add(".aj"); | ||||
suffixes.add(".java"); | suffixes.add(".java"); |
} | } | ||||
} | } | ||||
ArrayList<File> tempFiles = new ArrayList<File>(); | |||||
ArrayList<File> tempFiles = new ArrayList<>(); | |||||
private File jarDir; | private File jarDir; | ||||
private boolean deleteJars; | private boolean deleteJars; | ||||
boolean building; // must be enabled for tests to run | boolean building; // must be enabled for tests to run | ||||
try { | try { | ||||
zipFile = new ZipFile(weaverAllJar); | zipFile = new ZipFile(weaverAllJar); | ||||
Enumeration e = zipFile.entries(); | Enumeration e = zipFile.entries(); | ||||
ArrayList<String> entryNames = new ArrayList<String>(); | |||||
ArrayList<String> entryNames = new ArrayList<>(); | |||||
while (e.hasMoreElements()) { | while (e.hasMoreElements()) { | ||||
ZipEntry entry = (ZipEntry) e.nextElement(); | ZipEntry entry = (ZipEntry) e.nextElement(); | ||||
String name = entry.getName(); | String name = entry.getName(); |
} | } | ||||
} | } | ||||
ArrayList<File> tempFiles = new ArrayList<File>(); | |||||
ArrayList<File> tempFiles = new ArrayList<>(); | |||||
public ModulesTest(String name) { | public ModulesTest(String name) { | ||||
super(name); | super(name); | ||||
} | } | ||||
public void testAllModulesCreation() { | public void testAllModulesCreation() { | ||||
ArrayList<Module> badModules = new ArrayList<Module>(); | |||||
ArrayList<Module> badModules = new ArrayList<>(); | |||||
for (String name: MODULE_NAMES) { | for (String name: MODULE_NAMES) { | ||||
File dir = new File(BASE_DIR, name); | File dir = new File(BASE_DIR, name); | ||||
if (dir.isDirectory()) { | if (dir.isDirectory()) { |
if (loadersToSkipProperty != null && loadersToSkip == null) { | if (loadersToSkipProperty != null && loadersToSkip == null) { | ||||
if (st.hasMoreTokens()) { | if (st.hasMoreTokens()) { | ||||
// System.out.println("aj.weaving.loadersToSkip is set. Skipping loaders: '"+loadersToSkipProperty+"'"); | // System.out.println("aj.weaving.loadersToSkip is set. Skipping loaders: '"+loadersToSkipProperty+"'"); | ||||
loadersToSkip = new ArrayList<String>(); | |||||
loadersToSkip = new ArrayList<>(); | |||||
} | } | ||||
while (st.hasMoreTokens()) { | while (st.hasMoreTokens()) { | ||||
String nextLoader = st.nextToken(); | String nextLoader = st.nextToken(); | ||||
static class WeaverContainer { | static class WeaverContainer { | ||||
final static Map<AdaptorKey,ExplicitlyInitializedClassLoaderWeavingAdaptor> weavingAdaptors = | final static Map<AdaptorKey,ExplicitlyInitializedClassLoaderWeavingAdaptor> weavingAdaptors = | ||||
Collections.synchronizedMap(new HashMap<AdaptorKey,ExplicitlyInitializedClassLoaderWeavingAdaptor>()); | |||||
Collections.synchronizedMap(new HashMap<>()); | |||||
static WeavingAdaptor getWeaver(ClassLoader loader, IWeavingContext weavingContext) { | static WeavingAdaptor getWeaver(ClassLoader loader, IWeavingContext weavingContext) { | ||||
ExplicitlyInitializedClassLoaderWeavingAdaptor adaptor = null; | ExplicitlyInitializedClassLoaderWeavingAdaptor adaptor = null; |
private boolean initialized; | private boolean initialized; | ||||
private List<TypePattern> dumpTypePattern = new ArrayList<TypePattern>(); | |||||
private List<TypePattern> dumpTypePattern = new ArrayList<>(); | |||||
private boolean dumpBefore = false; | private boolean dumpBefore = false; | ||||
private boolean dumpDirPerClassloader = false; | private boolean dumpDirPerClassloader = false; | ||||
private boolean hasExcludes = false; | private boolean hasExcludes = false; | ||||
private List<TypePattern> excludeTypePattern = new ArrayList<TypePattern>(); // anything | |||||
private List<String> excludeStartsWith = new ArrayList<String>(); // com.foo..* | |||||
private List<String> excludeStarDotDotStar = new ArrayList<String>(); // *..*CGLIB* | |||||
private List<String> excludeExactName = new ArrayList<String>(); // com.foo.Bar | |||||
private List<String> excludeEndsWith = new ArrayList<String>(); // com.foo.Bar | |||||
private List<String[]> excludeSpecial = new ArrayList<String[]>(); | |||||
private List<TypePattern> excludeTypePattern = new ArrayList<>(); // anything | |||||
private List<String> excludeStartsWith = new ArrayList<>(); // com.foo..* | |||||
private List<String> excludeStarDotDotStar = new ArrayList<>(); // *..*CGLIB* | |||||
private List<String> excludeExactName = new ArrayList<>(); // com.foo.Bar | |||||
private List<String> excludeEndsWith = new ArrayList<>(); // com.foo.Bar | |||||
private List<String[]> excludeSpecial = new ArrayList<>(); | |||||
private boolean hasIncludes = false; | private boolean hasIncludes = false; | ||||
private List<TypePattern> includeTypePattern = new ArrayList<TypePattern>(); | |||||
private List<String> includeStartsWith = new ArrayList<String>(); | |||||
private List<String> includeExactName = new ArrayList<String>(); | |||||
private List<TypePattern> includeTypePattern = new ArrayList<>(); | |||||
private List<String> includeStartsWith = new ArrayList<>(); | |||||
private List<String> includeExactName = new ArrayList<>(); | |||||
private boolean includeStar = false; | private boolean includeStar = false; | ||||
private List<TypePattern> aspectExcludeTypePattern = new ArrayList<TypePattern>(); | |||||
private List<String> aspectExcludeStartsWith = new ArrayList<String>(); | |||||
private List<TypePattern> aspectIncludeTypePattern = new ArrayList<TypePattern>(); | |||||
private List<String> aspectIncludeStartsWith = new ArrayList<String>(); | |||||
private List<TypePattern> aspectExcludeTypePattern = new ArrayList<>(); | |||||
private List<String> aspectExcludeStartsWith = new ArrayList<>(); | |||||
private List<TypePattern> aspectIncludeTypePattern = new ArrayList<>(); | |||||
private List<String> aspectIncludeStartsWith = new ArrayList<>(); | |||||
private StringBuffer namespace; | private StringBuffer namespace; | ||||
private IWeavingContext weavingContext; | private IWeavingContext weavingContext; | ||||
private List<ConcreteAspectCodeGen> concreteAspects = new ArrayList<ConcreteAspectCodeGen>(); | |||||
private List<ConcreteAspectCodeGen> concreteAspects = new ArrayList<>(); | |||||
private static Trace trace = TraceFactory.getTraceFactory().getTrace(ClassLoaderWeavingAdaptor.class); | private static Trace trace = TraceFactory.getTraceFactory().getTrace(ClassLoaderWeavingAdaptor.class); | ||||
* @return | * @return | ||||
*/ | */ | ||||
List<String> getAspectClassNames(List<Definition> definitions) { | List<String> getAspectClassNames(List<Definition> definitions) { | ||||
List<String> aspects = new LinkedList<String>(); | |||||
List<String> aspects = new LinkedList<>(); | |||||
for (Definition def : definitions) { | for (Definition def : definitions) { | ||||
List<String> defAspects = def.getAspectClassNames(); | List<String> defAspects = def.getAspectClassNames(); | ||||
if (defAspects != null) { | if (defAspects != null) { | ||||
trace.enter("parseDefinitions", this); | trace.enter("parseDefinitions", this); | ||||
} | } | ||||
List<Definition> definitions = new ArrayList<Definition>(); | |||||
List<Definition> definitions = new ArrayList<>(); | |||||
try { | try { | ||||
info("register classloader " + getClassLoaderName(loader)); | info("register classloader " + getClassLoaderName(loader)); | ||||
// TODO av underoptimized: we will parse each XML once per CL that see it | // TODO av underoptimized: we will parse each XML once per CL that see it | ||||
Enumeration<URL> xmls = weavingContext.getResources(nextDefinition); | Enumeration<URL> xmls = weavingContext.getResources(nextDefinition); | ||||
// System.out.println("? registerDefinitions: found-aop.xml=" + xmls.hasMoreElements() + ", loader=" + loader); | // System.out.println("? registerDefinitions: found-aop.xml=" + xmls.hasMoreElements() + ", loader=" + loader); | ||||
Set<URL> seenBefore = new HashSet<URL>(); | |||||
Set<URL> seenBefore = new HashSet<>(); | |||||
while (xmls.hasMoreElements()) { | while (xmls.hasMoreElements()) { | ||||
URL xml = xmls.nextElement(); | URL xml = xmls.nextElement(); | ||||
if (trace.isTraceEnabled()) { | if (trace.isTraceEnabled()) { | ||||
*/ | */ | ||||
public void flushGeneratedClasses() { | public void flushGeneratedClasses() { | ||||
// System.err.println("? ClassLoaderWeavingAdaptor.flushGeneratedClasses() generatedClasses=" + generatedClasses); | // System.err.println("? ClassLoaderWeavingAdaptor.flushGeneratedClasses() generatedClasses=" + generatedClasses); | ||||
generatedClasses = new HashMap<String, IUnwovenClassFile>(); | |||||
generatedClasses = new HashMap<>(); | |||||
} | } | ||||
/** | /** |
} | } | ||||
// must have all abstractions defined | // must have all abstractions defined | ||||
List<String> elligibleAbstractions = new ArrayList<String>(); | |||||
List<String> elligibleAbstractions = new ArrayList<>(); | |||||
Collection<ResolvedMember> abstractMethods = getOutstandingAbstractMethods(parent); | Collection<ResolvedMember> abstractMethods = getOutstandingAbstractMethods(parent); | ||||
for (ResolvedMember method : abstractMethods) { | for (ResolvedMember method : abstractMethods) { | ||||
} | } | ||||
} | } | ||||
} | } | ||||
List<String> pointcutNames = new ArrayList<String>(); | |||||
List<String> pointcutNames = new ArrayList<>(); | |||||
for (Definition.Pointcut abstractPc : concreteAspect.pointcuts) { | for (Definition.Pointcut abstractPc : concreteAspect.pointcuts) { | ||||
pointcutNames.add(abstractPc.name); | pointcutNames.add(abstractPc.name); | ||||
} | } | ||||
} | } | ||||
private Collection<ResolvedMember> getOutstandingAbstractMethods(ResolvedType type) { | private Collection<ResolvedMember> getOutstandingAbstractMethods(ResolvedType type) { | ||||
Map<String, ResolvedMember> collector = new HashMap<String, ResolvedMember>(); | |||||
Map<String, ResolvedMember> collector = new HashMap<>(); | |||||
// let's get to the top of the hierarchy and then walk down ... | // let's get to the top of the hierarchy and then walk down ... | ||||
// recording abstract methods then removing | // recording abstract methods then removing | ||||
// them if they get defined further down the hierarchy | // them if they get defined further down the hierarchy | ||||
cg.addAnnotation(ag); | cg.addAnnotation(ag); | ||||
} else { | } else { | ||||
// List elems = new ArrayList(); | // List elems = new ArrayList(); | ||||
List<NameValuePair> elems = new ArrayList<NameValuePair>(); | |||||
List<NameValuePair> elems = new ArrayList<>(); | |||||
elems.add(new NameValuePair("value", | elems.add(new NameValuePair("value", | ||||
new SimpleElementValue(ElementValue.STRING, cg.getConstantPool(), perclauseString), cg.getConstantPool())); | new SimpleElementValue(ElementValue.STRING, cg.getConstantPool(), perclauseString), cg.getConstantPool())); | ||||
AnnotationGen ag = new AnnotationGen(new ObjectType("org/aspectj/lang/annotation/Aspect"), elems, true, | AnnotationGen ag = new AnnotationGen(new ObjectType("org/aspectj/lang/annotation/Aspect"), elems, true, | ||||
} | } | ||||
if (concreteAspect.precedence != null) { | if (concreteAspect.precedence != null) { | ||||
SimpleElementValue svg = new SimpleElementValue(ElementValue.STRING, cg.getConstantPool(), concreteAspect.precedence); | SimpleElementValue svg = new SimpleElementValue(ElementValue.STRING, cg.getConstantPool(), concreteAspect.precedence); | ||||
List<NameValuePair> elems = new ArrayList<NameValuePair>(); | |||||
List<NameValuePair> elems = new ArrayList<>(); | |||||
elems.add(new NameValuePair("value", svg, cg.getConstantPool())); | elems.add(new NameValuePair("value", svg, cg.getConstantPool())); | ||||
AnnotationGen agprec = new AnnotationGen(new ObjectType("org/aspectj/lang/annotation/DeclarePrecedence"), elems, true, | AnnotationGen agprec = new AnnotationGen(new ObjectType("org/aspectj/lang/annotation/DeclarePrecedence"), elems, true, | ||||
cg.getConstantPool()); | cg.getConstantPool()); | ||||
// TODO AV - respect visibility instead of opening up as public? | // TODO AV - respect visibility instead of opening up as public? | ||||
LazyMethodGen mg = new LazyMethodGen(Modifier.PUBLIC, Type.VOID, abstractPc.name, EMPTY_TYPES, EMPTY_STRINGS, cg); | LazyMethodGen mg = new LazyMethodGen(Modifier.PUBLIC, Type.VOID, abstractPc.name, EMPTY_TYPES, EMPTY_STRINGS, cg); | ||||
SimpleElementValue svg = new SimpleElementValue(ElementValue.STRING, cg.getConstantPool(), abstractPc.expression); | SimpleElementValue svg = new SimpleElementValue(ElementValue.STRING, cg.getConstantPool(), abstractPc.expression); | ||||
List<NameValuePair> elems = new ArrayList<NameValuePair>(); | |||||
List<NameValuePair> elems = new ArrayList<>(); | |||||
elems.add(new NameValuePair("value", svg, cg.getConstantPool())); | elems.add(new NameValuePair("value", svg, cg.getConstantPool())); | ||||
AnnotationGen mag = new AnnotationGen(new ObjectType("org/aspectj/lang/annotation/Pointcut"), elems, true, | AnnotationGen mag = new AnnotationGen(new ObjectType("org/aspectj/lang/annotation/Pointcut"), elems, true, | ||||
cg.getConstantPool()); | cg.getConstantPool()); | ||||
FieldGen field = new FieldGen(Modifier.FINAL, ObjectType.STRING, "rule" + (counter++), cg.getConstantPool()); | FieldGen field = new FieldGen(Modifier.FINAL, ObjectType.STRING, "rule" + (counter++), cg.getConstantPool()); | ||||
SimpleElementValue svg = new SimpleElementValue(ElementValue.STRING, cg.getConstantPool(), deow.pointcut); | SimpleElementValue svg = new SimpleElementValue(ElementValue.STRING, cg.getConstantPool(), deow.pointcut); | ||||
List<NameValuePair> elems = new ArrayList<NameValuePair>(); | |||||
List<NameValuePair> elems = new ArrayList<>(); | |||||
elems.add(new NameValuePair("value", svg, cg.getConstantPool())); | elems.add(new NameValuePair("value", svg, cg.getConstantPool())); | ||||
AnnotationGen mag = new AnnotationGen(new ObjectType("org/aspectj/lang/annotation/Declare" | AnnotationGen mag = new AnnotationGen(new ObjectType("org/aspectj/lang/annotation/Declare" | ||||
+ (deow.isError ? "Error" : "Warning")), elems, true, cg.getConstantPool()); | + (deow.isError ? "Error" : "Warning")), elems, true, cg.getConstantPool()); | ||||
// Discover the name and name/value pairs | // Discover the name and name/value pairs | ||||
String name = annotationString.substring(0,paren); | String name = annotationString.substring(0,paren); | ||||
// break the rest into pieces based on the commas | // break the rest into pieces based on the commas | ||||
List<String> values = new ArrayList<String>(); | |||||
List<String> values = new ArrayList<>(); | |||||
int pos = paren+1; | int pos = paren+1; | ||||
int depth = 0; | int depth = 0; | ||||
int len = annotationString.length(); | int len = annotationString.length(); | ||||
reportError("declare is using an annotation type that does not have runtime retention: "+typename); | reportError("declare is using an annotation type that does not have runtime retention: "+typename); | ||||
return null; | return null; | ||||
} | } | ||||
List<NameValuePair> elems = new ArrayList<NameValuePair>(); | |||||
List<NameValuePair> elems = new ArrayList<>(); | |||||
return new AnnotationGen(new ObjectType(annoname), elems, true, cp); | return new AnnotationGen(new ObjectType(annoname), elems, true, cp); | ||||
} | } | ||||
} | } | ||||
// Extract parameter types and names | // Extract parameter types and names | ||||
List<Type> paramTypes = new ArrayList<Type>(); | |||||
List<String> paramNames = new ArrayList<String>(); | |||||
List<Type> paramTypes = new ArrayList<>(); | |||||
List<String> paramNames = new ArrayList<>(); | |||||
if (signature.charAt(1) != ')') { | if (signature.charAt(1) != ')') { | ||||
// there are parameters to convert into a signature | // there are parameters to convert into a signature | ||||
StringBuilder convertedSignature = new StringBuilder("("); | StringBuilder convertedSignature = new StringBuilder("("); | ||||
*/ | */ | ||||
private AnnotationAJ buildAdviceAnnotation(LazyClassGen cg, PointcutAndAdvice paa) { | private AnnotationAJ buildAdviceAnnotation(LazyClassGen cg, PointcutAndAdvice paa) { | ||||
SimpleElementValue svg = new SimpleElementValue(ElementValue.STRING, cg.getConstantPool(), paa.pointcut); | SimpleElementValue svg = new SimpleElementValue(ElementValue.STRING, cg.getConstantPool(), paa.pointcut); | ||||
List<NameValuePair> elems = new ArrayList<NameValuePair>(); | |||||
List<NameValuePair> elems = new ArrayList<>(); | |||||
elems.add(new NameValuePair("value", svg, cg.getConstantPool())); | elems.add(new NameValuePair("value", svg, cg.getConstantPool())); | ||||
AnnotationGen mag = new AnnotationGen(new ObjectType("org/aspectj/lang/annotation/" + paa.adviceKind.toString()), elems, | AnnotationGen mag = new AnnotationGen(new ObjectType("org/aspectj/lang/annotation/" + paa.adviceKind.toString()), elems, | ||||
true, cg.getConstantPool()); | true, cg.getConstantPool()); |
static class TestWeavingContext extends DefaultWeavingContext { | static class TestWeavingContext extends DefaultWeavingContext { | ||||
List<Definition> testList = new ArrayList<Definition>(); | |||||
List<Definition> testList = new ArrayList<>(); | |||||
public TestWeavingContext(ClassLoader loader) { | public TestWeavingContext(ClassLoader loader) { | ||||
super(loader); | super(loader); |
boolean incrementalMode = buildConfig.isIncrementalMode() || buildConfig.isIncrementalFileMode(); | boolean incrementalMode = buildConfig.isIncrementalMode() || buildConfig.isIncrementalFileMode(); | ||||
List<File> xmlfileList = new ArrayList<File>(); | |||||
List<File> xmlfileList = new ArrayList<>(); | |||||
xmlfileList.addAll(parser.getXmlFiles()); | xmlfileList.addAll(parser.getXmlFiles()); | ||||
List<File> fileList = new ArrayList<File>(); | |||||
List<File> fileList = new ArrayList<>(); | |||||
List<File> files = parser.getFiles(); | List<File> files = parser.getFiles(); | ||||
if (!LangUtil.isEmpty(files)) { | if (!LangUtil.isEmpty(files)) { | ||||
if (incrementalMode) { | if (incrementalMode) { | ||||
} | } | ||||
} | } | ||||
List<String> javaArgList = new ArrayList<String>(); | |||||
List<String> javaArgList = new ArrayList<>(); | |||||
// disable all special eclipse warnings by default - why??? | // disable all special eclipse warnings by default - why??? | ||||
// ??? might want to instead override getDefaultOptions() | // ??? might want to instead override getDefaultOptions() | ||||
javaArgList.add("-warn:none"); | javaArgList.add("-warn:none"); | ||||
} | } | ||||
private ArrayList<String> toArrayList(java.util.List<File> files) { | private ArrayList<String> toArrayList(java.util.List<File> files) { | ||||
ArrayList<String> arrayList = new ArrayList<String>(); | |||||
ArrayList<String> arrayList = new ArrayList<>(); | |||||
for (File file: files) { | for (File file: files) { | ||||
arrayList.add(file.getAbsolutePath()); | arrayList.add(file.getAbsolutePath()); | ||||
} | } | ||||
} | } | ||||
public List<String> getBootclasspath(AjcConfigParser parser) { | public List<String> getBootclasspath(AjcConfigParser parser) { | ||||
List<String> ret = new ArrayList<String>(); | |||||
List<String> ret = new ArrayList<>(); | |||||
if (parser.bootclasspath == null) { | if (parser.bootclasspath == null) { | ||||
if (LangUtil.is19VMOrGreater()) { | if (LangUtil.is19VMOrGreater()) { | ||||
} | } | ||||
public List<String> getModulepath(AjcConfigParser parser) { | public List<String> getModulepath(AjcConfigParser parser) { | ||||
List<String> ret = new ArrayList<String>(); | |||||
List<String> ret = new ArrayList<>(); | |||||
addClasspath(parser.modulepath, ret); | addClasspath(parser.modulepath, ret); | ||||
return ret; | return ret; | ||||
} | } | ||||
public List<String> getModulesourcepath(AjcConfigParser parser) { | public List<String> getModulesourcepath(AjcConfigParser parser) { | ||||
List<String> ret = new ArrayList<String>(); | |||||
List<String> ret = new ArrayList<>(); | |||||
addClasspath(parser.modulesourcepath, ret); | addClasspath(parser.modulesourcepath, ret); | ||||
return ret; | return ret; | ||||
} | } | ||||
buildConfig.setMakeReflectable(true); | buildConfig.setMakeReflectable(true); | ||||
} else if (arg.equals("-sourceroots")) { | } else if (arg.equals("-sourceroots")) { | ||||
if (args.size() > nextArgIndex) { | if (args.size() > nextArgIndex) { | ||||
List<File> sourceRoots = new ArrayList<File>(); | |||||
List<File> sourceRoots = new ArrayList<>(); | |||||
StringTokenizer st = new StringTokenizer(args.get(nextArgIndex).getValue(), | StringTokenizer st = new StringTokenizer(args.get(nextArgIndex).getValue(), | ||||
File.pathSeparator); | File.pathSeparator); | ||||
while (st.hasMoreTokens()) { | while (st.hasMoreTokens()) { |
public class ConfigParser { | public class ConfigParser { | ||||
Location location; | Location location; | ||||
protected File relativeDirectory = null; | protected File relativeDirectory = null; | ||||
protected List<File> files = new LinkedList<File>(); | |||||
protected List<File> xmlfiles = new ArrayList<File>(); | |||||
protected List<File> files = new LinkedList<>(); | |||||
protected List<File> xmlfiles = new ArrayList<>(); | |||||
private boolean fileParsed = false; | private boolean fileParsed = false; | ||||
protected static String CONFIG_MSG = "build config error: "; | protected static String CONFIG_MSG = "build config error: "; | ||||
public void parseCommandLine(String[] argsArray) throws ParseException { | public void parseCommandLine(String[] argsArray) throws ParseException { | ||||
location = new CommandLineLocation(); | location = new CommandLineLocation(); | ||||
LinkedList<Arg> args = new LinkedList<Arg>(); | |||||
LinkedList<Arg> args = new LinkedList<>(); | |||||
for (String s : argsArray) { | for (String s : argsArray) { | ||||
args.add(new Arg(s, location)); | args.add(new Arg(s, location)); | ||||
} | } | ||||
return; | return; | ||||
} | } | ||||
LinkedList<Arg> args = new LinkedList<Arg>(); | |||||
LinkedList<Arg> args = new LinkedList<>(); | |||||
int lineNum = 0; | int lineNum = 0; | ||||
try { | try { |
private IOutputClassFileNameProvider outputFileNameProvider; | private IOutputClassFileNameProvider outputFileNameProvider; | ||||
private IBinarySourceProvider binarySourceProvider; | private IBinarySourceProvider binarySourceProvider; | ||||
private WeaverMessageHandler weaverMessageHandler; | private WeaverMessageHandler weaverMessageHandler; | ||||
private Map<String, List<UnwovenClassFile>> binarySourceSetForFullWeave = new HashMap<String, List<UnwovenClassFile>>(); | |||||
private Map<String, List<UnwovenClassFile>> binarySourceSetForFullWeave = new HashMap<>(); | |||||
private ContextToken processingToken = null; | private ContextToken processingToken = null; | ||||
private ContextToken resolvingToken = null; | private ContextToken resolvingToken = null; | ||||
private AjState incrementalCompilationState; | private AjState incrementalCompilationState; | ||||
// Maintains a list of whats weaving - whilst the pipeline is stalled, this accumulates aspects. | // Maintains a list of whats weaving - whilst the pipeline is stalled, this accumulates aspects. | ||||
List<InterimCompilationResult> resultsPendingWeave = new ArrayList<InterimCompilationResult>(); | |||||
List<InterimCompilationResult> resultsPendingWeave = new ArrayList<>(); | |||||
// pipelining info | // pipelining info | ||||
private boolean pipelineStalled = true; | private boolean pipelineStalled = true; | ||||
} | } | ||||
// Break the units into two lists... | // Break the units into two lists... | ||||
List<CompilationUnitDeclaration> aspects = new ArrayList<CompilationUnitDeclaration>(); | |||||
List<CompilationUnitDeclaration> nonaspects = new ArrayList<CompilationUnitDeclaration>(); | |||||
List<CompilationUnitDeclaration> aspects = new ArrayList<>(); | |||||
List<CompilationUnitDeclaration> nonaspects = new ArrayList<>(); | |||||
for (CompilationUnitDeclaration unit : units) { | for (CompilationUnitDeclaration unit : units) { | ||||
if (containsAnAspect(unit)) { | if (containsAnAspect(unit)) { | ||||
aspects.add(unit); | aspects.add(unit); | ||||
} | } | ||||
public void beforeCompiling(ICompilationUnit[] sourceUnits) { | public void beforeCompiling(ICompilationUnit[] sourceUnits) { | ||||
resultsPendingWeave = new ArrayList<InterimCompilationResult>(); | |||||
resultsPendingWeave = new ArrayList<>(); | |||||
reportedErrors = false; | reportedErrors = false; | ||||
droppingBackToFullBuild = false; | droppingBackToFullBuild = false; | ||||
} | } | ||||
private List<InterimCompilationResult> getBinarySourcesFrom(Map<String, List<UnwovenClassFile>> binarySourceEntries) { | private List<InterimCompilationResult> getBinarySourcesFrom(Map<String, List<UnwovenClassFile>> binarySourceEntries) { | ||||
// Map is fileName |-> List<UnwovenClassFile> | // Map is fileName |-> List<UnwovenClassFile> | ||||
List<InterimCompilationResult> ret = new ArrayList<InterimCompilationResult>(); | |||||
List<InterimCompilationResult> ret = new ArrayList<>(); | |||||
for (String sourceFileName : binarySourceEntries.keySet()) { | for (String sourceFileName : binarySourceEntries.keySet()) { | ||||
List<UnwovenClassFile> unwovenClassFiles = binarySourceEntries.get(sourceFileName); | List<UnwovenClassFile> unwovenClassFiles = binarySourceEntries.get(sourceFileName); | ||||
// XXX - see bugs 57432,58679 - final parameter on next call should be "compiler.options.maxProblemsPerUnit" | // XXX - see bugs 57432,58679 - final parameter on next call should be "compiler.options.maxProblemsPerUnit" |
private IProblem[] buildSeeAlsoProblems(IProblem originalProblem, List sourceLocations, CompilationResult problemSource, | private IProblem[] buildSeeAlsoProblems(IProblem originalProblem, List sourceLocations, CompilationResult problemSource, | ||||
boolean usedBinarySourceFileName) { | boolean usedBinarySourceFileName) { | ||||
List<IProblem> ret = new ArrayList<IProblem>(); | |||||
List<IProblem> ret = new ArrayList<>(); | |||||
for (Object sourceLocation : sourceLocations) { | for (Object sourceLocation : sourceLocations) { | ||||
ISourceLocation loc = (ISourceLocation) sourceLocation; | ISourceLocation loc = (ISourceLocation) sourceLocation; |
PrivilegedHandler handler; | PrivilegedHandler handler; | ||||
AspectDeclaration inAspect; | AspectDeclaration inAspect; | ||||
EclipseFactory world; // alias for inAspect.world | EclipseFactory world; // alias for inAspect.world | ||||
private Map<TypeBinding, Map<FieldBinding, ResolvedMember>> alreadyProcessedReceivers = new HashMap<TypeBinding, Map<FieldBinding, ResolvedMember>>(); | |||||
private Map<TypeBinding, Map<FieldBinding, ResolvedMember>> alreadyProcessedReceivers = new HashMap<>(); | |||||
// set to true for ClassLiteralAccess and AssertStatement | // set to true for ClassLiteralAccess and AssertStatement | ||||
// ??? A better answer would be to transform these into inlinable forms | // ??? A better answer would be to transform these into inlinable forms | ||||
// Avoid repeatedly building ResolvedMembers by using info on any done previously in this visitor | // Avoid repeatedly building ResolvedMembers by using info on any done previously in this visitor | ||||
Map<FieldBinding, ResolvedMember> alreadyResolvedMembers = alreadyProcessedReceivers.get(receiverType); | Map<FieldBinding, ResolvedMember> alreadyResolvedMembers = alreadyProcessedReceivers.get(receiverType); | ||||
if (alreadyResolvedMembers == null) { | if (alreadyResolvedMembers == null) { | ||||
alreadyResolvedMembers = new HashMap<FieldBinding, ResolvedMember>(); | |||||
alreadyResolvedMembers = new HashMap<>(); | |||||
alreadyProcessedReceivers.put(receiverType, alreadyResolvedMembers); | alreadyProcessedReceivers.put(receiverType, alreadyResolvedMembers); | ||||
} | } | ||||
ResolvedMember m = alreadyResolvedMembers.get(binding); | ResolvedMember m = alreadyResolvedMembers.get(binding); |
public int adviceSequenceNumberInType; | public int adviceSequenceNumberInType; | ||||
public MethodBinding proceedMethodBinding; // set during this.resolveStaments, referenced by Proceed | public MethodBinding proceedMethodBinding; // set during this.resolveStaments, referenced by Proceed | ||||
public List<Proceed> proceedCalls = new ArrayList<Proceed>(2); // populated during Proceed.findEnclosingAround | |||||
public List<Proceed> proceedCalls = new ArrayList<>(2); // populated during Proceed.findEnclosingAround | |||||
private boolean proceedInInners; | private boolean proceedInInners; | ||||
private ResolvedMember[] proceedCallSignatures; | private ResolvedMember[] proceedCallSignatures; | ||||
// override | // override | ||||
protected int generateInfoAttributes(ClassFile classFile) { | protected int generateInfoAttributes(ClassFile classFile) { | ||||
List<EclipseAttributeAdapter> l = new ArrayList<EclipseAttributeAdapter>(1); | |||||
List<EclipseAttributeAdapter> l = new ArrayList<>(1); | |||||
l.add(new EclipseAttributeAdapter(makeAttribute())); | l.add(new EclipseAttributeAdapter(makeAttribute())); | ||||
addDeclarationStartLineAttribute(l, classFile); | addDeclarationStartLineAttribute(l, classFile); | ||||
return classFile.generateMethodInfoAttributes(binding, l); | return classFile.generateMethodInfoAttributes(binding, l); |
public ResolvedMember aspectOfMethod; | public ResolvedMember aspectOfMethod; | ||||
public ResolvedMember ptwGetWithinTypeNameMethod; | public ResolvedMember ptwGetWithinTypeNameMethod; | ||||
public ResolvedMember hasAspectMethod; | public ResolvedMember hasAspectMethod; | ||||
public Map<ResolvedMember, Binding> accessForInline = new LinkedHashMap<ResolvedMember, Binding>(); | |||||
public Map<ResolvedMember, AccessForInlineVisitor.SuperAccessMethodPair> superAccessForInline = new HashMap<ResolvedMember, AccessForInlineVisitor.SuperAccessMethodPair>(); | |||||
public Map<ResolvedMember, Binding> accessForInline = new LinkedHashMap<>(); | |||||
public Map<ResolvedMember, AccessForInlineVisitor.SuperAccessMethodPair> superAccessForInline = new HashMap<>(); | |||||
public boolean isPrivileged; | public boolean isPrivileged; | ||||
public EclipseSourceType concreteName; | public EclipseSourceType concreteName; | ||||
public ReferenceType typeX; | public ReferenceType typeX; | ||||
} | } | ||||
protected List<EclipseAttributeAdapter> makeEffectiveSignatureAttribute(ResolvedMember sig, Shadow.Kind kind, boolean weaveBody) { | protected List<EclipseAttributeAdapter> makeEffectiveSignatureAttribute(ResolvedMember sig, Shadow.Kind kind, boolean weaveBody) { | ||||
List<EclipseAttributeAdapter> l = new ArrayList<EclipseAttributeAdapter>(1); | |||||
List<EclipseAttributeAdapter> l = new ArrayList<>(1); | |||||
l.add(new EclipseAttributeAdapter(new AjAttribute.EffectiveSignatureAttribute(sig, kind, weaveBody))); | l.add(new EclipseAttributeAdapter(new AjAttribute.EffectiveSignatureAttribute(sig, kind, weaveBody))); | ||||
return l; | return l; | ||||
} | } |
public EclipseFactory factory = null; | public EclipseFactory factory = null; | ||||
// private boolean builtInterTypesAndPerClauses = false; | // private boolean builtInterTypesAndPerClauses = false; | ||||
private final List<SourceTypeBinding> pendingTypesToWeave = new ArrayList<SourceTypeBinding>(); | |||||
private final List<SourceTypeBinding> pendingTypesToWeave = new ArrayList<>(); | |||||
// Q: What are dangerousInterfaces? | // Q: What are dangerousInterfaces? | ||||
// A: An interface is considered dangerous if an ITD has been made upon it | // A: An interface is considered dangerous if an ITD has been made upon it | ||||
// need to build inter-type declarations for all AspectDeclarations at | // need to build inter-type declarations for all AspectDeclarations at | ||||
// this point | // this point | ||||
// this MUST be done in order from super-types to subtypes | // this MUST be done in order from super-types to subtypes | ||||
List<SourceTypeBinding> typesToProcess = new ArrayList<SourceTypeBinding>(); | |||||
List<SourceTypeBinding> aspectsToProcess = new ArrayList<SourceTypeBinding>(); | |||||
List<SourceTypeBinding> typesToProcess = new ArrayList<>(); | |||||
List<SourceTypeBinding> aspectsToProcess = new ArrayList<>(); | |||||
for (int i = lastCompletedUnitIndex + 1; i <= lastUnitIndex; i++) { | for (int i = lastCompletedUnitIndex + 1; i <= lastUnitIndex; i++) { | ||||
CompilationUnitScope cus = units[i].scope; | CompilationUnitScope cus = units[i].scope; | ||||
SourceTypeBinding[] stbs = cus.topLevelTypes; | SourceTypeBinding[] stbs = cus.topLevelTypes; | ||||
boolean typeProcessingOrderIsImportant = declareParents.size() > 0 || declareAnnotationOnTypes.size() > 0; // DECAT | boolean typeProcessingOrderIsImportant = declareParents.size() > 0 || declareAnnotationOnTypes.size() > 0; // DECAT | ||||
if (typeProcessingOrderIsImportant) { | if (typeProcessingOrderIsImportant) { | ||||
typesToProcess = new ArrayList<SourceTypeBinding>(); | |||||
typesToProcess = new ArrayList<>(); | |||||
for (int i = lastCompletedUnitIndex + 1; i <= lastUnitIndex; i++) { | for (int i = lastCompletedUnitIndex + 1; i <= lastUnitIndex; i++) { | ||||
CompilationUnitScope cus = units[i].scope; | CompilationUnitScope cus = units[i].scope; | ||||
SourceTypeBinding[] stbs = cus.topLevelTypes; | SourceTypeBinding[] stbs = cus.topLevelTypes; | ||||
} | } | ||||
} | } | ||||
List<SourceTypeBinding> stb2 = new ArrayList<SourceTypeBinding>(); | |||||
List<SourceTypeBinding> stb2 = new ArrayList<>(); | |||||
stb2.addAll(typesToProcess); | stb2.addAll(typesToProcess); | ||||
while (typesToProcess.size() > 0) { | while (typesToProcess.size() > 0) { | ||||
// not-exposed to weaver | // not-exposed to weaver | ||||
// messages... | // messages... | ||||
List<DeclareParents> decpToRepeat = new ArrayList<DeclareParents>(); | |||||
List<DeclareAnnotation> decaToRepeat = new ArrayList<DeclareAnnotation>(); | |||||
List<DeclareParents> decpToRepeat = new ArrayList<>(); | |||||
List<DeclareAnnotation> decaToRepeat = new ArrayList<>(); | |||||
boolean anyNewParents = false; | boolean anyNewParents = false; | ||||
boolean anyNewAnnotations = false; | boolean anyNewAnnotations = false; | ||||
} | } | ||||
} | } | ||||
List<Object> forRemoval = new ArrayList<Object>(); | |||||
List<Object> forRemoval = new ArrayList<>(); | |||||
// now lets loop over and over until we have done all we can | // now lets loop over and over until we have done all we can | ||||
while ((anyNewAnnotations || anyNewParents) && (!decpToRepeat.isEmpty() || !decaToRepeat.isEmpty())) { | while ((anyNewAnnotations || anyNewParents) && (!decpToRepeat.isEmpty() || !decaToRepeat.isEmpty())) { | ||||
anyNewParents = anyNewAnnotations = false; | anyNewParents = anyNewAnnotations = false; | ||||
if ((bits & TagBits.AnnotationTargetMASK) == 0) { | if ((bits & TagBits.AnnotationTargetMASK) == 0) { | ||||
return ""; | return ""; | ||||
} | } | ||||
Set<String> s = new HashSet<String>(); | |||||
Set<String> s = new HashSet<>(); | |||||
if ((bits & TagBits.AnnotationForAnnotationType) != 0) { | if ((bits & TagBits.AnnotationForAnnotationType) != 0) { | ||||
s.add("ANNOTATION_TYPE"); | s.add("ANNOTATION_TYPE"); | ||||
} | } |
// We can get clashes if we don't treat raw types differently - we end up looking | // We can get clashes if we don't treat raw types differently - we end up looking | ||||
// up a raw and getting the generic type (pr115788) | // up a raw and getting the generic type (pr115788) | ||||
private final Map<UnresolvedType, TypeBinding> typexToBinding = new HashMap<UnresolvedType, TypeBinding>(); | |||||
private final Map<UnresolvedType, TypeBinding> rawTypeXToBinding = new HashMap<UnresolvedType, TypeBinding>(); | |||||
private final Map<UnresolvedType, TypeBinding> typexToBinding = new HashMap<>(); | |||||
private final Map<UnresolvedType, TypeBinding> rawTypeXToBinding = new HashMap<>(); | |||||
// XXX currently unused | // XXX currently unused | ||||
// private Map/*TypeBinding, ResolvedType*/ bindingToResolvedTypeX = new HashMap(); | // private Map/*TypeBinding, ResolvedType*/ bindingToResolvedTypeX = new HashMap(); | ||||
/** | /** | ||||
* Some type variables refer to themselves recursively, this enables us to avoid recursion problems. | * Some type variables refer to themselves recursively, this enables us to avoid recursion problems. | ||||
*/ | */ | ||||
private static Map<TypeVariableBinding,UnresolvedType> typeVariableBindingsInProgress = new HashMap<TypeVariableBinding,UnresolvedType>(); | |||||
private static Map<TypeVariableBinding,UnresolvedType> typeVariableBindingsInProgress = new HashMap<>(); | |||||
/** | /** | ||||
* Convert from the eclipse form of type variable (TypeVariableBinding) to the AspectJ form (TypeVariable). | * Convert from the eclipse form of type variable (TypeVariableBinding) to the AspectJ form (TypeVariable). | ||||
public void finishTypeMungers() { | public void finishTypeMungers() { | ||||
// make sure that type mungers are | // make sure that type mungers are | ||||
List<ConcreteTypeMunger> ret = new ArrayList<ConcreteTypeMunger>(); | |||||
List<ConcreteTypeMunger> ret = new ArrayList<>(); | |||||
List<ConcreteTypeMunger> baseTypeMungers = getWorld().getCrosscuttingMembersSet().getTypeMungers(); | List<ConcreteTypeMunger> baseTypeMungers = getWorld().getCrosscuttingMembersSet().getTypeMungers(); | ||||
// XXX by Andy: why do we mix up the mungers here? it means later we know about two sets | // XXX by Andy: why do we mix up the mungers here? it means later we know about two sets | ||||
* Before converting the parts of a methodbinding (params, return type) we store the type variables in this structure, then | * Before converting the parts of a methodbinding (params, return type) we store the type variables in this structure, then | ||||
* should any component of the method binding refer to them, we grab them from the map. | * should any component of the method binding refer to them, we grab them from the map. | ||||
*/ | */ | ||||
private final Map<String,UnresolvedType> typeVariablesForThisMember = new HashMap<String, UnresolvedType>(); | |||||
private final Map<String,UnresolvedType> typeVariablesForThisMember = new HashMap<>(); | |||||
/** | /** | ||||
* This is a map from typevariablebindings (eclipsey things) to the names the user originally specified in their ITD. For | * This is a map from typevariablebindings (eclipsey things) to the names the user originally specified in their ITD. For | ||||
// map back to the same type binding - this is important later when Eclipse code is processing | // map back to the same type binding - this is important later when Eclipse code is processing | ||||
// a methodbinding trying to come up with possible bindings for the type variables. | // a methodbinding trying to come up with possible bindings for the type variables. | ||||
// key is currently the name of the type variable...is that ok? | // key is currently the name of the type variable...is that ok? | ||||
private final Map<String,TypeVariableBinding> typeVariableToTypeBinding = new HashMap<String,TypeVariableBinding>(); | |||||
private final Map<String,TypeVariableBinding> typeVariableToTypeBinding = new HashMap<>(); | |||||
// /** | // /** | ||||
// * Converts from an TypeVariableReference to a TypeVariableBinding. A TypeVariableReference | // * Converts from an TypeVariableReference to a TypeVariableBinding. A TypeVariableReference |
if (importedNames != null) | if (importedNames != null) | ||||
return; | return; | ||||
List<String> importedNamesList = new ArrayList<String>(); | |||||
List<String> importedPrefixesList = new ArrayList<String>(); | |||||
List<String> importedNamesList = new ArrayList<>(); | |||||
List<String> importedPrefixesList = new ArrayList<>(); | |||||
Scope currentScope = scope; | Scope currentScope = scope; | ||||
// add any enclosing types to this list | // add any enclosing types to this list |
protected ResolvedMember[] declaredMethods = null; | protected ResolvedMember[] declaredMethods = null; | ||||
protected ResolvedMember[] declaredFields = null; | protected ResolvedMember[] declaredFields = null; | ||||
public List<Declare> declares = new ArrayList<Declare>(); | |||||
public List<EclipseTypeMunger> typeMungers = new ArrayList<EclipseTypeMunger>(); | |||||
public List<Declare> declares = new ArrayList<>(); | |||||
public List<EclipseTypeMunger> typeMungers = new ArrayList<>(); | |||||
private final EclipseFactory factory; | private final EclipseFactory factory; | ||||
} | } | ||||
protected void fillDeclaredMembers() { | protected void fillDeclaredMembers() { | ||||
List<ResolvedMember> declaredPointcuts = new ArrayList<ResolvedMember>(); | |||||
List<ResolvedMember> declaredMethods = new ArrayList<ResolvedMember>(); | |||||
List<ResolvedMember> declaredFields = new ArrayList<ResolvedMember>(); | |||||
List<ResolvedMember> declaredPointcuts = new ArrayList<>(); | |||||
List<ResolvedMember> declaredMethods = new ArrayList<>(); | |||||
List<ResolvedMember> declaredFields = new ArrayList<>(); | |||||
MethodBinding[] ms = binding.methods(); // the important side-effect of this call is to make | MethodBinding[] ms = binding.methods(); // the important side-effect of this call is to make | ||||
// sure bindings are completed | // sure bindings are completed | ||||
// } | // } | ||||
// return targetKind; | // return targetKind; | ||||
if (isAnnotation()) { | if (isAnnotation()) { | ||||
List<AnnotationTargetKind> targetKinds = new ArrayList<AnnotationTargetKind>(); | |||||
List<AnnotationTargetKind> targetKinds = new ArrayList<>(); | |||||
if ((binding.getAnnotationTagBits() & TagBits.AnnotationForAnnotationType) != 0) { | if ((binding.getAnnotationTagBits() & TagBits.AnnotationForAnnotationType) != 0) { | ||||
targetKinds.add(AnnotationTargetKind.ANNOTATION_TYPE); | targetKinds.add(AnnotationTargetKind.ANNOTATION_TYPE); |
public class HelperInterfaceBinding extends SourceTypeBinding { | public class HelperInterfaceBinding extends SourceTypeBinding { | ||||
private UnresolvedType typeX; | private UnresolvedType typeX; | ||||
SourceTypeBinding enclosingType; | SourceTypeBinding enclosingType; | ||||
List<MethodBinding> methods = new ArrayList<MethodBinding>(); | |||||
List<MethodBinding> methods = new ArrayList<>(); | |||||
public HelperInterfaceBinding(SourceTypeBinding enclosingType, UnresolvedType typeX) { | public HelperInterfaceBinding(SourceTypeBinding enclosingType, UnresolvedType typeX) { | ||||
super(); | super(); |
* The member finder looks after intertype declared members on a type, there is one member finder per type that was hit by an ITD. | * The member finder looks after intertype declared members on a type, there is one member finder per type that was hit by an ITD. | ||||
*/ | */ | ||||
public class InterTypeMemberFinder implements IMemberFinder { | public class InterTypeMemberFinder implements IMemberFinder { | ||||
private List<FieldBinding> interTypeFields = new ArrayList<FieldBinding>(); | |||||
private List<MethodBinding> interTypeMethods = new ArrayList<MethodBinding>(); | |||||
private List<FieldBinding> interTypeFields = new ArrayList<>(); | |||||
private List<MethodBinding> interTypeMethods = new ArrayList<>(); | |||||
public SourceTypeBinding sourceTypeBinding; | public SourceTypeBinding sourceTypeBinding; | ||||
MethodBinding[] orig = sourceTypeBinding.methodsBase(); | MethodBinding[] orig = sourceTypeBinding.methodsBase(); | ||||
// if (interTypeMethods.isEmpty()) return orig; | // if (interTypeMethods.isEmpty()) return orig; | ||||
List<MethodBinding> ret = new ArrayList<MethodBinding>(Arrays.asList(orig)); | |||||
List<MethodBinding> ret = new ArrayList<>(Arrays.asList(orig)); | |||||
for (MethodBinding method : interTypeMethods) { | for (MethodBinding method : interTypeMethods) { | ||||
ret.add(method); | ret.add(method); | ||||
} | } | ||||
return orig; | return orig; | ||||
} | } | ||||
Set<MethodBinding> ret = new HashSet<MethodBinding>(Arrays.asList(orig)); | |||||
Set<MethodBinding> ret = new HashSet<>(Arrays.asList(orig)); | |||||
// System.err.println("declared method: " + ret + " inters = " + interTypeMethods); | // System.err.println("declared method: " + ret + " inters = " + interTypeMethods); | ||||
for (MethodBinding method : interTypeMethods) { | for (MethodBinding method : interTypeMethods) { |
TypeVariableBinding tvb = sourceType.typeVariables()[aliased]; | TypeVariableBinding tvb = sourceType.typeVariables()[aliased]; | ||||
tvb.fPackage = sourceType.fPackage; | tvb.fPackage = sourceType.fPackage; | ||||
if (usedAliases == null) | if (usedAliases == null) | ||||
usedAliases = new HashMap<TypeVariableBinding, String>(); | |||||
usedAliases = new HashMap<>(); | |||||
usedAliases.put(tvb, variableName); | usedAliases.put(tvb, variableName); | ||||
return tvb; | return tvb; | ||||
} else { | } else { |
public SourceTypeBinding targetTypeBinding; | public SourceTypeBinding targetTypeBinding; | ||||
// The new types declared onto the target | // The new types declared onto the target | ||||
private Set<ReferenceBinding> intertypeMemberTypes = new HashSet<ReferenceBinding>(); | |||||
private Set<ReferenceBinding> intertypeMemberTypes = new HashSet<>(); | |||||
public void addInterTypeMemberType(ReferenceBinding binding) { | public void addInterTypeMemberType(ReferenceBinding binding) { | ||||
intertypeMemberTypes.add(binding); | intertypeMemberTypes.add(binding); |
private String suffix; | private String suffix; | ||||
// This first collection stores the 'text' for the declarations. | // This first collection stores the 'text' for the declarations. | ||||
private Map<AbstractMethodDeclaration, RepresentationAndLocation> codeRepresentation = new HashMap<AbstractMethodDeclaration, RepresentationAndLocation>(); | |||||
private Map<AbstractMethodDeclaration, RepresentationAndLocation> codeRepresentation = new HashMap<>(); | |||||
// This stores the new annotations | // This stores the new annotations | ||||
private Map<SourceTypeBinding, List<String>> additionalAnnotations = new HashMap<SourceTypeBinding, List<String>>(); | |||||
private Map<SourceTypeBinding, List<String>> additionalAnnotations = new HashMap<>(); | |||||
// This stores the new parents | // This stores the new parents | ||||
private Map<SourceTypeBinding, List<ExactTypePattern>> additionalParents = new HashMap<SourceTypeBinding, List<ExactTypePattern>>(); | |||||
private Map<SourceTypeBinding, List<ExactTypePattern>> additionalParents = new HashMap<>(); | |||||
// This indicates which types are affected by which intertype declarations | // This indicates which types are affected by which intertype declarations | ||||
private Map<SourceTypeBinding, List<AbstractMethodDeclaration>> newDeclarations = new HashMap<SourceTypeBinding, List<AbstractMethodDeclaration>>(); | |||||
private Map<SourceTypeBinding, List<AbstractMethodDeclaration>> newDeclarations = new HashMap<>(); | |||||
private PushinCollector(World world, Properties configuration) { | private PushinCollector(World world, Properties configuration) { | ||||
this.world = world; | this.world = world; | ||||
} | } | ||||
List<AbstractMethodDeclaration> amds = newDeclarations.get(sourceType); | List<AbstractMethodDeclaration> amds = newDeclarations.get(sourceType); | ||||
if (amds == null) { | if (amds == null) { | ||||
amds = new ArrayList<AbstractMethodDeclaration>(); | |||||
amds = new ArrayList<>(); | |||||
newDeclarations.put(sourceType, amds); | newDeclarations.put(sourceType, amds); | ||||
} | } | ||||
amds.add(sourceMethod); | amds.add(sourceMethod); | ||||
public void tagAsMunged(SourceTypeBinding sourceType, String annotationString) { | public void tagAsMunged(SourceTypeBinding sourceType, String annotationString) { | ||||
List<String> annos = additionalAnnotations.get(sourceType); | List<String> annos = additionalAnnotations.get(sourceType); | ||||
if (annos == null) { | if (annos == null) { | ||||
annos = new ArrayList<String>(); | |||||
annos = new ArrayList<>(); | |||||
additionalAnnotations.put(sourceType, annos); | additionalAnnotations.put(sourceType, annos); | ||||
} | } | ||||
annos.add(annotationString); | annos.add(annotationString); | ||||
if (typePattern instanceof ExactTypePattern) { | if (typePattern instanceof ExactTypePattern) { | ||||
List<ExactTypePattern> annos = additionalParents.get(sourceType); | List<ExactTypePattern> annos = additionalParents.get(sourceType); | ||||
if (annos == null) { | if (annos == null) { | ||||
annos = new ArrayList<ExactTypePattern>(); | |||||
annos = new ArrayList<>(); | |||||
additionalParents.put(sourceType, annos); | additionalParents.put(sourceType, annos); | ||||
} | } | ||||
annos.add((ExactTypePattern) typePattern); | annos.add((ExactTypePattern) typePattern); |
private File outputJar; | private File outputJar; | ||||
private String outxmlName; | private String outxmlName; | ||||
private CompilationResultDestinationManager compilationResultDestinationManager = null; | private CompilationResultDestinationManager compilationResultDestinationManager = null; | ||||
private List<File> sourceRoots = new ArrayList<File>(); | |||||
private List<File> sourceRoots = new ArrayList<>(); | |||||
private List<File> changedFiles; | private List<File> changedFiles; | ||||
private List<File> files = new ArrayList<File>(); | |||||
private List<File> xmlfiles = new ArrayList<File>(); | |||||
private List<File> files = new ArrayList<>(); | |||||
private List<File> xmlfiles = new ArrayList<>(); | |||||
private String processor; | private String processor; | ||||
private String processorPath; | private String processorPath; | ||||
private List<BinarySourceFile> binaryFiles = new ArrayList<BinarySourceFile>(); // .class files in indirs... | |||||
private List<File> inJars = new ArrayList<File>(); | |||||
private List<File> inPath = new ArrayList<File>(); | |||||
private Map<String, File> sourcePathResources = new HashMap<String, File>(); | |||||
private List<File> aspectpath = new ArrayList<File>(); | |||||
private List<String> classpath = new ArrayList<String>(); | |||||
private List<String> modulepath = new ArrayList<String>(); | |||||
private List<BinarySourceFile> binaryFiles = new ArrayList<>(); // .class files in indirs... | |||||
private List<File> inJars = new ArrayList<>(); | |||||
private List<File> inPath = new ArrayList<>(); | |||||
private Map<String, File> sourcePathResources = new HashMap<>(); | |||||
private List<File> aspectpath = new ArrayList<>(); | |||||
private List<String> classpath = new ArrayList<>(); | |||||
private List<String> modulepath = new ArrayList<>(); | |||||
// Expensive to compute (searching modules, parsing module-info) | // Expensive to compute (searching modules, parsing module-info) | ||||
private ArrayList<Classpath> modulepathClasspathEntries = null; | private ArrayList<Classpath> modulepathClasspathEntries = null; | ||||
private List<String> modulesourcepath = new ArrayList<String>(); | |||||
private List<String> modulesourcepath = new ArrayList<>(); | |||||
// Expensive to compute (searching modules, parsing module-info) | // Expensive to compute (searching modules, parsing module-info) | ||||
private ArrayList<Classpath> modulesourcepathClasspathEntries = null; | private ArrayList<Classpath> modulesourcepathClasspathEntries = null; | ||||
private Classpath[] checkedClasspaths = null; | private Classpath[] checkedClasspaths = null; | ||||
private List<String> bootclasspath = new ArrayList<String>(); | |||||
private List<String> cpElementsWithModifiedContents = new ArrayList<String>(); | |||||
private List<String> bootclasspath = new ArrayList<>(); | |||||
private List<String> cpElementsWithModifiedContents = new ArrayList<>(); | |||||
private IModule moduleDesc; | private IModule moduleDesc; | ||||
private File configFile; | private File configFile; | ||||
} | } | ||||
private List<Classpath> processFilePath(List<File> path, java.lang.String encoding) { | private List<Classpath> processFilePath(List<File> path, java.lang.String encoding) { | ||||
List<Classpath> entries = new ArrayList<Classpath>(); | |||||
List<Classpath> entries = new ArrayList<>(); | |||||
for (File file: path) { | for (File file: path) { | ||||
entries.add(FileSystem.getClasspath(file.getAbsolutePath(), encoding, null, ClasspathLocation.BINARY, null)); | entries.add(FileSystem.getClasspath(file.getAbsolutePath(), encoding, null, ClasspathLocation.BINARY, null)); | ||||
} | } | ||||
} | } | ||||
private List<Classpath> processStringPath(List<String> path, java.lang.String encoding) { | private List<Classpath> processStringPath(List<String> path, java.lang.String encoding) { | ||||
List<Classpath> entries = new ArrayList<Classpath>(); | |||||
List<Classpath> entries = new ArrayList<>(); | |||||
for (String file: path) { | for (String file: path) { | ||||
entries.add(FileSystem.getClasspath(file, encoding, null, ClasspathLocation.BINARY, null)); | entries.add(FileSystem.getClasspath(file, encoding, null, ClasspathLocation.BINARY, null)); | ||||
} | } | ||||
public void processInPath() { | public void processInPath() { | ||||
// remember all the class files in directories on the inpath | // remember all the class files in directories on the inpath | ||||
binaryFiles = new ArrayList<BinarySourceFile>(); | |||||
binaryFiles = new ArrayList<>(); | |||||
FileFilter filter = new FileFilter() { | FileFilter filter = new FileFilter() { | ||||
@Override | @Override | ||||
public boolean accept(File pathname) { | public boolean accept(File pathname) { | ||||
* classpath), and output dir or jar | * classpath), and output dir or jar | ||||
*/ | */ | ||||
public List<String> getFullClasspath() { | public List<String> getFullClasspath() { | ||||
List<String> full = new ArrayList<String>(); | |||||
List<String> full = new ArrayList<>(); | |||||
full.addAll(getBootclasspath()); // XXX Is it OK that boot classpath overrides inpath/injars/aspectpath? | full.addAll(getBootclasspath()); // XXX Is it OK that boot classpath overrides inpath/injars/aspectpath? | ||||
for (File file: inJars) { | for (File file: inJars) { | ||||
full.add(file.getAbsolutePath()); | full.add(file.getAbsolutePath()); | ||||
// Possibly a name=value comma separated list of configurations | // Possibly a name=value comma separated list of configurations | ||||
if (lintMode.contains("=")) { | if (lintMode.contains("=")) { | ||||
this.lintMode = AJLINT_DEFAULT; | this.lintMode = AJLINT_DEFAULT; | ||||
lintOptionsMap = new HashMap<String,String>(); | |||||
lintOptionsMap = new HashMap<>(); | |||||
StringTokenizer tokenizer = new StringTokenizer(lintMode,","); | StringTokenizer tokenizer = new StringTokenizer(lintMode,","); | ||||
while (tokenizer.hasMoreElements()) { | while (tokenizer.hasMoreElements()) { | ||||
String option = tokenizer.nextToken(); | String option = tokenizer.nextToken(); | ||||
} | } | ||||
if (lintValue != null || lintOptionsMap != null ) { | if (lintValue != null || lintOptionsMap != null ) { | ||||
Map<String, String> lintOptions = new HashMap<String, String>(); | |||||
Map<String, String> lintOptions = new HashMap<>(); | |||||
setOption(AjCompilerOptions.OPTION_ReportInvalidAbsoluteTypeName, lintValue, lintOptions); | setOption(AjCompilerOptions.OPTION_ReportInvalidAbsoluteTypeName, lintValue, lintOptions); | ||||
setOption(AjCompilerOptions.OPTION_ReportInvalidWildcardTypeName, lintValue, lintOptions); | setOption(AjCompilerOptions.OPTION_ReportInvalidWildcardTypeName, lintValue, lintOptions); | ||||
setOption(AjCompilerOptions.OPTION_ReportUnresolvableMember, lintValue, lintOptions); | setOption(AjCompilerOptions.OPTION_ReportUnresolvableMember, lintValue, lintOptions); | ||||
// What to do about bootclasspath on java 9? | // What to do about bootclasspath on java 9? | ||||
// ArrayList<Classpath> allPaths = handleBootclasspath(bootclasspaths, customEncoding); | // ArrayList<Classpath> allPaths = handleBootclasspath(bootclasspaths, customEncoding); | ||||
ArrayList<FileSystem.Classpath> allPaths = new ArrayList<FileSystem.Classpath>(); | |||||
ArrayList<FileSystem.Classpath> allPaths = new ArrayList<>(); | |||||
allPaths.addAll(processStringPath(bootclasspath, encoding)); | allPaths.addAll(processStringPath(bootclasspath, encoding)); | ||||
allPaths.addAll(processFilePath(inJars, encoding)); | allPaths.addAll(processFilePath(inJars, encoding)); | ||||
allPaths.addAll(processFilePath(inPath, encoding)); | allPaths.addAll(processFilePath(inPath, encoding)); |
private boolean batchCompile = true; | private boolean batchCompile = true; | ||||
private INameEnvironment environment; | private INameEnvironment environment; | ||||
private Map<String, List<UnwovenClassFile>> /* String -> List<UCF> */binarySourcesForTheNextCompile = new HashMap<String, List<UnwovenClassFile>>(); | |||||
private Map<String, List<UnwovenClassFile>> /* String -> List<UCF> */binarySourcesForTheNextCompile = new HashMap<>(); | |||||
// FIXME asc should this really be in here? | // FIXME asc should this really be in here? | ||||
// private AsmManager structureModel; | // private AsmManager structureModel; | ||||
* aspects which are sent to that ouptut directory | * aspects which are sent to that ouptut directory | ||||
*/ | */ | ||||
private Map<File, List<String>> findOutputDirsForAspects() { | private Map<File, List<String>> findOutputDirsForAspects() { | ||||
Map<File, List<String>> outputDirsToAspects = new HashMap<File, List<String>>(); | |||||
Map<File, List<String>> outputDirsToAspects = new HashMap<>(); | |||||
Map<String, char[]> aspectNamesToFileNames = state.getAspectNamesToFileNameMap(); | Map<String, char[]> aspectNamesToFileNames = state.getAspectNamesToFileNameMap(); | ||||
if (buildConfig.getCompilationResultDestinationManager() == null | if (buildConfig.getCompilationResultDestinationManager() == null | ||||
|| buildConfig.getCompilationResultDestinationManager().getAllOutputLocations().size() == 1) { | || buildConfig.getCompilationResultDestinationManager().getAllOutputLocations().size() == 1) { | ||||
if (buildConfig.getCompilationResultDestinationManager() != null) { | if (buildConfig.getCompilationResultDestinationManager() != null) { | ||||
outputDir = buildConfig.getCompilationResultDestinationManager().getDefaultOutputLocation(); | outputDir = buildConfig.getCompilationResultDestinationManager().getDefaultOutputLocation(); | ||||
} | } | ||||
List<String> aspectNames = new ArrayList<String>(); | |||||
List<String> aspectNames = new ArrayList<>(); | |||||
if (aspectNamesToFileNames != null) { | if (aspectNamesToFileNames != null) { | ||||
Set<String> keys = aspectNamesToFileNames.keySet(); | Set<String> keys = aspectNamesToFileNames.keySet(); | ||||
for (String name : keys) { | for (String name : keys) { | ||||
List outputDirs = buildConfig.getCompilationResultDestinationManager().getAllOutputLocations(); | List outputDirs = buildConfig.getCompilationResultDestinationManager().getAllOutputLocations(); | ||||
for (Object dir : outputDirs) { | for (Object dir : outputDirs) { | ||||
File outputDir = (File) dir; | File outputDir = (File) dir; | ||||
outputDirsToAspects.put(outputDir, new ArrayList<String>()); | |||||
outputDirsToAspects.put(outputDir, new ArrayList<>()); | |||||
} | } | ||||
if (aspectNamesToFileNames != null) { | if (aspectNamesToFileNames != null) { | ||||
Set<Map.Entry<String, char[]>> entrySet = aspectNamesToFileNames.entrySet(); | Set<Map.Entry<String, char[]>> entrySet = aspectNamesToFileNames.entrySet(); | ||||
File outputDir = buildConfig.getCompilationResultDestinationManager().getOutputLocationForClass( | File outputDir = buildConfig.getCompilationResultDestinationManager().getOutputLocationForClass( | ||||
new File(new String(fileName))); | new File(new String(fileName))); | ||||
if (!outputDirsToAspects.containsKey(outputDir)) { | if (!outputDirsToAspects.containsKey(outputDir)) { | ||||
outputDirsToAspects.put(outputDir, new ArrayList<String>()); | |||||
outputDirsToAspects.put(outputDir, new ArrayList<>()); | |||||
} | } | ||||
((List) outputDirsToAspects.get(outputDir)).add(aspectName); | ((List) outputDirsToAspects.get(outputDir)).add(aspectName); | ||||
} | } | ||||
} | } | ||||
model.setRoot(new ProgramElement(structureModel, rootLabel, kind, new ArrayList())); | model.setRoot(new ProgramElement(structureModel, rootLabel, kind, new ArrayList())); | ||||
model.setFileMap(new HashMap<String, IProgramElement>()); | |||||
model.setFileMap(new HashMap<>()); | |||||
// setStructureModel(model); | // setStructureModel(model); | ||||
state.setStructureModel(structureModel); | state.setStructureModel(structureModel); | ||||
// state.setRelationshipMap(AsmManager.getDefault().getRelationshipMap()); | // state.setRelationshipMap(AsmManager.getDefault().getRelationshipMap()); | ||||
File[] binSrcs = FileUtil.listFiles(inPathElement, binarySourceFilter); | File[] binSrcs = FileUtil.listFiles(inPathElement, binarySourceFilter); | ||||
for (File binSrc : binSrcs) { | for (File binSrc : binSrcs) { | ||||
UnwovenClassFile ucf = bcelWeaver.addClassFile(binSrc, inPathElement, outputDir); | UnwovenClassFile ucf = bcelWeaver.addClassFile(binSrc, inPathElement, outputDir); | ||||
List<UnwovenClassFile> ucfl = new ArrayList<UnwovenClassFile>(); | |||||
List<UnwovenClassFile> ucfl = new ArrayList<>(); | |||||
ucfl.add(ucf); | ucfl.add(ucf); | ||||
state.recordBinarySource(binSrc.getPath(), ucfl); | state.recordBinarySource(binSrc.getPath(), ucfl); | ||||
} | } |
* When looking at changes on the classpath, this set accumulates files in our state instance that affected by those changes. | * When looking at changes on the classpath, this set accumulates files in our state instance that affected by those changes. | ||||
* Then if we can do an incremental build - these must be compiled. | * Then if we can do an incremental build - these must be compiled. | ||||
*/ | */ | ||||
private final Set<File> affectedFiles = new HashSet<File>(); | |||||
private final Set<File> affectedFiles = new HashSet<>(); | |||||
// these are references created on a particular compile run - when looping round in | // these are references created on a particular compile run - when looping round in | ||||
// addAffectedSourceFiles(), if some have been created then we look at which source files | // addAffectedSourceFiles(), if some have been created then we look at which source files | ||||
private Set<BinarySourceFile> addedBinaryFiles; | private Set<BinarySourceFile> addedBinaryFiles; | ||||
private Set<BinarySourceFile> deletedBinaryFiles; | private Set<BinarySourceFile> deletedBinaryFiles; | ||||
// For a particular build run, this set records the changes to classesFromName | // For a particular build run, this set records the changes to classesFromName | ||||
public final Set<String> deltaAddedClasses = new HashSet<String>(); | |||||
public final Set<String> deltaAddedClasses = new HashSet<>(); | |||||
// now follows non static, but transient state - no need to write out, DOES need reinitializing when read AjState instance | // now follows non static, but transient state - no need to write out, DOES need reinitializing when read AjState instance | ||||
// reloaded | // reloaded | ||||
private boolean batchBuildRequiredThisTime = false; | private boolean batchBuildRequiredThisTime = false; | ||||
private AjBuildConfig buildConfig; | private AjBuildConfig buildConfig; | ||||
private long lastSuccessfulFullBuildTime = -1; | private long lastSuccessfulFullBuildTime = -1; | ||||
private final Hashtable<String, Long> structuralChangesSinceLastFullBuild = new Hashtable<String, Long>(); | |||||
private final Hashtable<String, Long> structuralChangesSinceLastFullBuild = new Hashtable<>(); | |||||
private long lastSuccessfulBuildTime = -1; | private long lastSuccessfulBuildTime = -1; | ||||
private long currentBuildTime = -1; | private long currentBuildTime = -1; | ||||
private AsmManager structureModel; | private AsmManager structureModel; | ||||
* For a given source file, records the ClassFiles (which contain a fully qualified name and a file name) that were created when | * For a given source file, records the ClassFiles (which contain a fully qualified name and a file name) that were created when | ||||
* the source file was compiled. Populated in noteResult and used in addDependentsOf(File) | * the source file was compiled. Populated in noteResult and used in addDependentsOf(File) | ||||
*/ | */ | ||||
private final Map<File, List<ClassFile>> fullyQualifiedTypeNamesResultingFromCompilationUnit = new HashMap<File, List<ClassFile>>(); | |||||
private final Map<File, List<ClassFile>> fullyQualifiedTypeNamesResultingFromCompilationUnit = new HashMap<>(); | |||||
/** | /** | ||||
* Source files defining aspects Populated in noteResult and used in processDeletedFiles | * Source files defining aspects Populated in noteResult and used in processDeletedFiles | ||||
*/ | */ | ||||
private final Set<File> sourceFilesDefiningAspects = new HashSet<File>(); | |||||
private final Set<File> sourceFilesDefiningAspects = new HashSet<>(); | |||||
/** | /** | ||||
* Populated in noteResult to record the set of types that should be recompiled if the given file is modified or deleted. | * Populated in noteResult to record the set of types that should be recompiled if the given file is modified or deleted. | ||||
* Referred to during addAffectedSourceFiles when calculating incremental compilation set. | * Referred to during addAffectedSourceFiles when calculating incremental compilation set. | ||||
*/ | */ | ||||
private final Map<File, ReferenceCollection> references = new HashMap<File, ReferenceCollection>(); | |||||
private final Map<File, ReferenceCollection> references = new HashMap<>(); | |||||
/** | /** | ||||
* Holds UnwovenClassFiles (byte[]s) originating from the given file source. This could be a jar file, a directory, or an | * Holds UnwovenClassFiles (byte[]s) originating from the given file source. This could be a jar file, a directory, or an | ||||
* input file has changed. | * input file has changed. | ||||
* | * | ||||
*/ | */ | ||||
private Map<String, List<UnwovenClassFile>> binarySourceFiles = new HashMap<String, List<UnwovenClassFile>>(); | |||||
private Map<String, List<UnwovenClassFile>> binarySourceFiles = new HashMap<>(); | |||||
/** | /** | ||||
* Initially a duplicate of the information held in binarySourceFiles, with the key difference that the values are ClassFiles | * Initially a duplicate of the information held in binarySourceFiles, with the key difference that the values are ClassFiles | ||||
* (type name, File) not UnwovenClassFiles (which also have all the byte code in them). After a batch build, binarySourceFiles | * (type name, File) not UnwovenClassFiles (which also have all the byte code in them). After a batch build, binarySourceFiles | ||||
* is cleared, leaving just this much lighter weight map to use in processing subsequent incremental builds. | * is cleared, leaving just this much lighter weight map to use in processing subsequent incremental builds. | ||||
*/ | */ | ||||
private final Map<String, List<ClassFile>> inputClassFilesBySource = new HashMap<String, List<ClassFile>>(); | |||||
private final Map<String, List<ClassFile>> inputClassFilesBySource = new HashMap<>(); | |||||
/** | /** | ||||
* A list of the .class files created by this state that contain aspects. | * A list of the .class files created by this state that contain aspects. | ||||
*/ | */ | ||||
private final List<String> aspectClassFiles = new ArrayList<String>(); | |||||
private final List<String> aspectClassFiles = new ArrayList<>(); | |||||
/** | /** | ||||
* Holds structure information on types as they were at the end of the last build. It would be nice to get rid of this too, but | * Holds structure information on types as they were at the end of the last build. It would be nice to get rid of this too, but | ||||
* can't see an easy way to do that right now. | * can't see an easy way to do that right now. | ||||
*/ | */ | ||||
private final Map<String, CompactTypeStructureRepresentation> resolvedTypeStructuresFromLastBuild = new HashMap<String, CompactTypeStructureRepresentation>(); | |||||
private final Map<String, CompactTypeStructureRepresentation> resolvedTypeStructuresFromLastBuild = new HashMap<>(); | |||||
/** | /** | ||||
* Populated in noteResult to record the set of UnwovenClassFiles (intermediate results) that originated from compilation of the | * Populated in noteResult to record the set of UnwovenClassFiles (intermediate results) that originated from compilation of the | ||||
* | * | ||||
* Passed into StatefulNameEnvironment during incremental compilation to support findType lookups. | * Passed into StatefulNameEnvironment during incremental compilation to support findType lookups. | ||||
*/ | */ | ||||
private final Map<String, File> classesFromName = new HashMap<String, File>(); | |||||
private final Map<String, File> classesFromName = new HashMap<>(); | |||||
/** | /** | ||||
* Populated by AjBuildManager to record the aspects with the file name in which they're contained. This is later used when | * Populated by AjBuildManager to record the aspects with the file name in which they're contained. This is later used when | ||||
*/ | */ | ||||
private Map<String, char[]> aspectsFromFileNames; | private Map<String, char[]> aspectsFromFileNames; | ||||
private Set<File> compiledSourceFiles = new HashSet<File>(); | |||||
private final Map<String, File> resources = new HashMap<String, File>(); | |||||
private Set<File> compiledSourceFiles = new HashSet<>(); | |||||
private final Map<String, File> resources = new HashMap<>(); | |||||
SoftHashMap/* <baseDir,SoftHashMap<theFile,className>> */fileToClassNameMap = new SoftHashMap(); | SoftHashMap/* <baseDir,SoftHashMap<theFile,className>> */fileToClassNameMap = new SoftHashMap(); | ||||
addedFiles = Collections.emptySet(); | addedFiles = Collections.emptySet(); | ||||
deletedFiles = Collections.emptySet(); | deletedFiles = Collections.emptySet(); | ||||
} else { | } else { | ||||
Set<File> oldFiles = new HashSet<File>(buildConfig.getFiles()); | |||||
Set<File> newFiles = new HashSet<File>(newBuildConfig.getFiles()); | |||||
Set<File> oldFiles = new HashSet<>(buildConfig.getFiles()); | |||||
Set<File> newFiles = new HashSet<>(newBuildConfig.getFiles()); | |||||
addedFiles = new HashSet<File>(newFiles); | |||||
addedFiles = new HashSet<>(newFiles); | |||||
addedFiles.removeAll(oldFiles); | addedFiles.removeAll(oldFiles); | ||||
deletedFiles = new HashSet<File>(oldFiles); | |||||
deletedFiles = new HashSet<>(oldFiles); | |||||
deletedFiles.removeAll(newFiles); | deletedFiles.removeAll(newFiles); | ||||
} | } | ||||
Set<BinarySourceFile> oldBinaryFiles = new HashSet<BinarySourceFile>(buildConfig.getBinaryFiles()); | |||||
Set<BinarySourceFile> newBinaryFiles = new HashSet<BinarySourceFile>(newBuildConfig.getBinaryFiles()); | |||||
Set<BinarySourceFile> oldBinaryFiles = new HashSet<>(buildConfig.getBinaryFiles()); | |||||
Set<BinarySourceFile> newBinaryFiles = new HashSet<>(newBuildConfig.getBinaryFiles()); | |||||
addedBinaryFiles = new HashSet<BinarySourceFile>(newBinaryFiles); | |||||
addedBinaryFiles = new HashSet<>(newBinaryFiles); | |||||
addedBinaryFiles.removeAll(oldBinaryFiles); | addedBinaryFiles.removeAll(oldBinaryFiles); | ||||
deletedBinaryFiles = new HashSet<BinarySourceFile>(oldBinaryFiles); | |||||
deletedBinaryFiles = new HashSet<>(oldBinaryFiles); | |||||
deletedBinaryFiles.removeAll(newBinaryFiles); | deletedBinaryFiles.removeAll(newBinaryFiles); | ||||
boolean couldStillBeIncremental = processDeletedFiles(deletedFiles); | boolean couldStillBeIncremental = processDeletedFiles(deletedFiles); | ||||
} | } | ||||
Collection<File> getModifiedFiles(long lastBuildTime) { | Collection<File> getModifiedFiles(long lastBuildTime) { | ||||
Set<File> ret = new HashSet<File>(); | |||||
Set<File> ret = new HashSet<>(); | |||||
// Check if the build configuration knows what files have changed... | // Check if the build configuration knows what files have changed... | ||||
List<File> modifiedFiles = buildConfig.getModifiedFiles(); | List<File> modifiedFiles = buildConfig.getModifiedFiles(); | ||||
} | } | ||||
Collection<BinarySourceFile> getModifiedBinaryFiles(long lastBuildTime) { | Collection<BinarySourceFile> getModifiedBinaryFiles(long lastBuildTime) { | ||||
List<BinarySourceFile> ret = new ArrayList<BinarySourceFile>(); | |||||
List<BinarySourceFile> ret = new ArrayList<>(); | |||||
// not our job to account for new and deleted files | // not our job to account for new and deleted files | ||||
for (BinarySourceFile bsfile : buildConfig.getBinaryFiles()) { | for (BinarySourceFile bsfile : buildConfig.getBinaryFiles()) { | ||||
File file = bsfile.binSrc; | File file = bsfile.binSrc; | ||||
if ((changes & (CLASSPATH_CHANGED | ASPECTPATH_CHANGED | INPATH_CHANGED | OUTPUTDESTINATIONS_CHANGED | INJARS_CHANGED)) != 0) { | if ((changes & (CLASSPATH_CHANGED | ASPECTPATH_CHANGED | INPATH_CHANGED | OUTPUTDESTINATIONS_CHANGED | INJARS_CHANGED)) != 0) { | ||||
List<File> oldOutputLocs = getOutputLocations(previousConfig); | List<File> oldOutputLocs = getOutputLocations(previousConfig); | ||||
Set<String> alreadyAnalysedPaths = new HashSet<String>(); | |||||
Set<String> alreadyAnalysedPaths = new HashSet<>(); | |||||
List<String> oldClasspath = previousConfig.getClasspath(); | List<String> oldClasspath = previousConfig.getClasspath(); | ||||
List<String> newClasspath = newConfig.getClasspath(); | List<String> newClasspath = newConfig.getClasspath(); | ||||
* @return a list of file objects | * @return a list of file objects | ||||
*/ | */ | ||||
private List<File> getOutputLocations(AjBuildConfig config) { | private List<File> getOutputLocations(AjBuildConfig config) { | ||||
List<File> outputLocs = new ArrayList<File>(); | |||||
List<File> outputLocs = new ArrayList<>(); | |||||
// Is there a default location? | // Is there a default location? | ||||
if (config.getOutputDir() != null) { | if (config.getOutputDir() != null) { | ||||
try { | try { | ||||
} | } | ||||
public Set<File> getFilesToCompile(boolean firstPass) { | public Set<File> getFilesToCompile(boolean firstPass) { | ||||
Set<File> thisTime = new HashSet<File>(); | |||||
Set<File> thisTime = new HashSet<>(); | |||||
if (firstPass) { | if (firstPass) { | ||||
compiledSourceFiles = new HashSet<File>(); | |||||
compiledSourceFiles = new HashSet<>(); | |||||
Collection<File> modifiedFiles = getModifiedFiles(); | Collection<File> modifiedFiles = getModifiedFiles(); | ||||
// System.out.println("modified: " + modifiedFiles); | // System.out.println("modified: " + modifiedFiles); | ||||
thisTime.addAll(modifiedFiles); | thisTime.addAll(modifiedFiles); | ||||
return binarySourceFiles; | return binarySourceFiles; | ||||
} | } | ||||
// else incremental... | // else incremental... | ||||
Map<String, List<UnwovenClassFile>> toWeave = new HashMap<String, List<UnwovenClassFile>>(); | |||||
Map<String, List<UnwovenClassFile>> toWeave = new HashMap<>(); | |||||
if (firstTime) { | if (firstTime) { | ||||
List<BinarySourceFile> addedOrModified = new ArrayList<BinarySourceFile>(); | |||||
List<BinarySourceFile> addedOrModified = new ArrayList<>(); | |||||
addedOrModified.addAll(addedBinaryFiles); | addedOrModified.addAll(addedBinaryFiles); | ||||
addedOrModified.addAll(getModifiedBinaryFiles()); | addedOrModified.addAll(getModifiedBinaryFiles()); | ||||
for (BinarySourceFile bsf : addedOrModified) { | for (BinarySourceFile bsf : addedOrModified) { | ||||
if (ucf == null) { | if (ucf == null) { | ||||
continue; | continue; | ||||
} | } | ||||
List<UnwovenClassFile> ucfs = new ArrayList<UnwovenClassFile>(); | |||||
List<UnwovenClassFile> ucfs = new ArrayList<>(); | |||||
ucfs.add(ucf); | ucfs.add(ucf); | ||||
recordTypeChanged(ucf.getClassName()); | recordTypeChanged(ucf.getClassName()); | ||||
binarySourceFiles.put(bsf.binSrc.getPath(), ucfs); | binarySourceFiles.put(bsf.binSrc.getPath(), ucfs); | ||||
List<ClassFile> cfs = new ArrayList<ClassFile>(1); | |||||
List<ClassFile> cfs = new ArrayList<>(1); | |||||
cfs.add(getClassFileFor(ucf)); | cfs.add(getClassFileFor(ucf)); | ||||
this.inputClassFilesBySource.put(bsf.binSrc.getPath(), cfs); | this.inputClassFilesBySource.put(bsf.binSrc.getPath(), cfs); | ||||
toWeave.put(bsf.binSrc.getPath(), ucfs); | toWeave.put(bsf.binSrc.getPath(), ucfs); | ||||
* @param icr, the CompilationResult from compiling it | * @param icr, the CompilationResult from compiling it | ||||
*/ | */ | ||||
private void recordFQNsResultingFromCompilationUnit(File sourceFile, InterimCompilationResult icr) { | private void recordFQNsResultingFromCompilationUnit(File sourceFile, InterimCompilationResult icr) { | ||||
List<ClassFile> classFiles = new ArrayList<ClassFile>(); | |||||
List<ClassFile> classFiles = new ArrayList<>(); | |||||
UnwovenClassFile[] types = icr.unwovenClassFiles(); | UnwovenClassFile[] types = icr.unwovenClassFiles(); | ||||
for (UnwovenClassFile type : types) { | for (UnwovenClassFile type : types) { | ||||
classFiles.add(new ClassFile(type.getClassName(), new File(type.getFilename()))); | classFiles.add(new ClassFile(type.getClassName(), new File(type.getFilename()))); | ||||
} | } | ||||
public void clearBinarySourceFiles() { | public void clearBinarySourceFiles() { | ||||
this.binarySourceFiles = new HashMap<String, List<UnwovenClassFile>>(); | |||||
this.binarySourceFiles = new HashMap<>(); | |||||
} | } | ||||
public void recordBinarySource(String fromPathName, List<UnwovenClassFile> unwovenClassFiles) { | public void recordBinarySource(String fromPathName, List<UnwovenClassFile> unwovenClassFiles) { | ||||
this.binarySourceFiles.put(fromPathName, unwovenClassFiles); | this.binarySourceFiles.put(fromPathName, unwovenClassFiles); | ||||
if (this.maybeIncremental()) { | if (this.maybeIncremental()) { | ||||
List<ClassFile> simpleClassFiles = new LinkedList<ClassFile>(); | |||||
List<ClassFile> simpleClassFiles = new LinkedList<>(); | |||||
for (UnwovenClassFile ucf : unwovenClassFiles) { | for (UnwovenClassFile ucf : unwovenClassFiles) { | ||||
ClassFile cf = getClassFileFor(ucf); | ClassFile cf = getClassFileFor(ucf); | ||||
simpleClassFiles.add(cf); | simpleClassFiles.add(cf); | ||||
} | } | ||||
public void initializeAspectNamesToFileNameMap() { | public void initializeAspectNamesToFileNameMap() { | ||||
this.aspectsFromFileNames = new HashMap<String, char[]>(); | |||||
this.aspectsFromFileNames = new HashMap<>(); | |||||
} | } | ||||
// Will allow us to record decisions made during incremental processing, hopefully aid in debugging | // Will allow us to record decisions made during incremental processing, hopefully aid in debugging |
pe.setParameterNames(Collections.<String>emptyList()); | pe.setParameterNames(Collections.<String>emptyList()); | ||||
pe.setParameterSignatures(Collections.<char[]>emptyList(), Collections.<String>emptyList()); | pe.setParameterSignatures(Collections.<char[]>emptyList(), Collections.<String>emptyList()); | ||||
} else { | } else { | ||||
List<String> names = new ArrayList<String>(); | |||||
List<char[]> paramSigs = new ArrayList<char[]>(); | |||||
List<String> paramSourceRefs = new ArrayList<String>(); | |||||
List<String> names = new ArrayList<>(); | |||||
List<char[]> paramSigs = new ArrayList<>(); | |||||
List<String> paramSourceRefs = new ArrayList<>(); | |||||
boolean problemWithSourceRefs = false; | boolean problemWithSourceRefs = false; | ||||
for (Argument argument : argArray) { | for (Argument argument : argArray) { | ||||
String argName = new String(argument.name); | String argName = new String(argument.name); |
Declare decl = dDeclaration.declareDecl; | Declare decl = dDeclaration.declareDecl; | ||||
if (decl instanceof DeclareParents) { | if (decl instanceof DeclareParents) { | ||||
TypePatternList tpl = ((DeclareParents) decl).getParents(); | TypePatternList tpl = ((DeclareParents) decl).getParents(); | ||||
List<String> parents = new ArrayList<String>(); | |||||
List<String> parents = new ArrayList<>(); | |||||
for (int i = 0; i < tpl.size(); i++) { | for (int i = 0; i < tpl.size(); i++) { | ||||
parents.add(tpl.get(i).getExactType().getName().replaceAll("\\$", ".")); | parents.add(tpl.get(i).getExactType().getName().replaceAll("\\$", ".")); | ||||
} | } |