Sfoglia il codice sorgente

Fix 404345: another occurence of broken annotation building in JDT

tags/V1_8_10
Andy Clement 7 anni fa
parent
commit
f33db67c2e

BIN
org.eclipse.jdt.core/jdtcore-for-aspectj-src.zip Vedi File


BIN
org.eclipse.jdt.core/jdtcore-for-aspectj.jar Vedi File


+ 5
- 0
tests/multiIncremental/pr404345/base/src/org/Constants.java Vedi File

package org;

public class Constants {
public static final String MISSING="missing";
}

+ 16
- 0
tests/multiIncremental/pr404345/base/src/org/FetchProfile.java Vedi File

package org;

public @interface FetchProfile {
String name();
FetchProfile.FetchOverride[] fetchOverrides();
@interface FetchOverride {
Class<?> entity();
String association() default "";
}
}

//@FetchProfiles({
//@FetchProfile(name = FetchProfileName.LOCATION, fetchOverrides = {
// @FetchProfile.FetchOverride(entity = Location.class, association = Location.PROPERTY_SYSTEMSTATE),
// @FetchProfile.FetchOverride(entity = Location.class, association = Location.PROPERTY_KEYVAULT) }),

+ 5
- 0
tests/multiIncremental/pr404345/base/src/org/FetchProfileName.java Vedi File

package org;

public class FetchProfileName {
public static final String LOCATION="missing";
}

+ 10
- 0
tests/multiIncremental/pr404345/base/src/org/FetchProfiles.java Vedi File

package org;

public @interface FetchProfiles {
FetchProfile[] value();
}

//@FetchProfiles({
//@FetchProfile(name = FetchProfileName.LOCATION, fetchOverrides = {
// @FetchProfile.FetchOverride(entity = Location.class, association = Location.PROPERTY_SYSTEMSTATE),
// @FetchProfile.FetchOverride(entity = Location.class, association = Location.PROPERTY_KEYVAULT) }),

+ 9
- 0
tests/multiIncremental/pr404345/base/src/org/package-info.java Vedi File

//@FetchProfiles({
@FetchProfile(name = FetchProfileName.LOCATION, fetchOverrides = {
// @FetchProfile.FetchOverride(entity = Location.class, association = Location.PROPERTY_SYSTEMSTATE),
@FetchProfile.FetchOverride(entity = Location.class, association = Location.PROPERTY_KEYVAULT)
})
//})
package org;



+ 3
- 0
tests/multiIncremental/pr404345/inc1/src/org/Constants.java Vedi File

package org;
class Constants {
}

+ 5
- 0
tests/multiIncremental/pr404345/inc1/src/org/FetchProfileName.java Vedi File

package org;

public class FetchProfileName {
public static final String LOCATION="missing";
}

+ 2
- 0
tests/multiIncremental/pr404345/inc2/src/org/package-info.java Vedi File

@Foo(Constants.MISSING)
package org;

+ 3
- 4
tests/src/org/aspectj/systemtest/incremental/tools/AjdeInteractionTestbed.java Vedi File

MultiProjTestMessageHandler handler = (MultiProjTestMessageHandler) compiler.getMessageHandler(); MultiProjTestMessageHandler handler = (MultiProjTestMessageHandler) compiler.getMessageHandler();
if (handler.hasErrorMessages()) { if (handler.hasErrorMessages()) {
System.err.println("Build errors:"); System.err.println("Build errors:");
for (Iterator<IMessage> iter = handler.getErrorMessages().iterator(); iter.hasNext();) {
IMessage element = iter.next();
System.err.println(element);
for (IMessage message: handler.getErrorMessages()) {
System.err.println(message);
} }
System.err.println("---------"); System.err.println("---------");
} }
return ((MultiProjTestMessageHandler) compiler.getMessageHandler()).getWeavingMessages(); return ((MultiProjTestMessageHandler) compiler.getMessageHandler()).getWeavingMessages();
} }


public List<IMessage> getCompilerErrorMessages(String projectName) {
public List<String> getCompilerErrorMessages(String projectName) {
AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName); AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName);
return ((MultiProjTestMessageHandler) compiler.getMessageHandler()).getCompilerErrors(); return ((MultiProjTestMessageHandler) compiler.getMessageHandler()).getCompilerErrors();
} }

+ 17
- 19
tests/src/org/aspectj/systemtest/incremental/tools/MultiProjTestCompilerConfiguration.java Vedi File

import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
private boolean verbose = false; private boolean verbose = false;


private String classPath = ""; private String classPath = "";
private Set aspectPath = null;
private Map sourcePathResources = null;
private Set<File> aspectPath = null;
private Map<String,File> sourcePathResources = null;
private IOutputLocationManager outputLocationManager = null; private IOutputLocationManager outputLocationManager = null;
private List<String> dependants; private List<String> dependants;
private Map javaOptionsMap;
private Map<String,String> javaOptionsMap;
private Set<File> inpath; private Set<File> inpath;
private String encoding = null; private String encoding = null;
private String outjar; private String outjar;
private String nonstandardoptions; private String nonstandardoptions;
private List<File> modifiedFiles; private List<File> modifiedFiles;
private List<String> modifiedDirs; private List<String> modifiedDirs;
private List<String> projectSourceFiles = new ArrayList();
private List xmlConfigFiles = new ArrayList();
private List<String> projectSourceFiles = new ArrayList<>();
private List<String> xmlConfigFiles = new ArrayList<>();
private String projectPath; private String projectPath;


int changed; int changed;
this.projectPath = projectPath; this.projectPath = projectPath;
} }


public Set getAspectPath() {
public Set<File> getAspectPath() {
log("ICompilerConfiguration.getAspectPath(" + aspectPath + ")"); log("ICompilerConfiguration.getAspectPath(" + aspectPath + ")");
return aspectPath; return aspectPath;
} }
log("ICompilerConfiguration.getClasspath()"); log("ICompilerConfiguration.getClasspath()");
// AJDT has all the output directories on it's classpath // AJDT has all the output directories on it's classpath
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
List allOutputPaths = getOutputLocationManager().getAllOutputLocations();
for (Iterator iterator = allOutputPaths.iterator(); iterator.hasNext();) {
File dir = (File) iterator.next();
List<File> allOutputPaths = getOutputLocationManager().getAllOutputLocations();
for (File dir: allOutputPaths) {
sb.append(File.pathSeparator + dir.getAbsolutePath()); sb.append(File.pathSeparator + dir.getAbsolutePath());
} }
String cp = sb.toString() + File.pathSeparator + new File(AjdeInteractionTestbed.testdataSrcDir) + File.pathSeparator String cp = sb.toString() + File.pathSeparator + new File(AjdeInteractionTestbed.testdataSrcDir) + File.pathSeparator


// look at dependant projects // look at dependant projects
if (dependants != null) { if (dependants != null) {
for (Iterator iter = dependants.iterator(); iter.hasNext();) {
cp = AjdeInteractionTestbed.getFile((String) iter.next(), "bin") + File.pathSeparator + cp;
for (String dependant: dependants) {
cp = AjdeInteractionTestbed.getFile(dependant, "bin") + File.pathSeparator + cp;
} }
} }
// System.err.println("For project "+projectPath+" getClasspath() returning "+cp); // System.err.println("For project "+projectPath+" getClasspath() returning "+cp);
return outputLocationManager; return outputLocationManager;
} }


public List getProjectSourceFiles() {
public List<String> getProjectSourceFiles() {
log("ICompilerConfiguration.getProjectSourceFiles()"); log("ICompilerConfiguration.getProjectSourceFiles()");
return projectSourceFiles; return projectSourceFiles;
} }


public List getProjectXmlConfigFiles() {
public List<String> getProjectXmlConfigFiles() {
return xmlConfigFiles; return xmlConfigFiles;
} }


return modifiedFiles; return modifiedFiles;
} }


public Map getSourcePathResources() {
public Map<String,File> getSourcePathResources() {
log("ICompilerConfiguration.getSourcePathResources()"); log("ICompilerConfiguration.getSourcePathResources()");
return sourcePathResources; return sourcePathResources;
} }
} }


// -------------------- setter methods useful for testing --------------- // -------------------- setter methods useful for testing ---------------
public void setAspectPath(Set aspectPath) {
public void setAspectPath(Set<File> aspectPath) {
this.aspectPath = aspectPath; this.aspectPath = aspectPath;
this.changed |= ICompilerConfiguration.ASPECTPATH_CHANGED; this.changed |= ICompilerConfiguration.ASPECTPATH_CHANGED;
} }
this.changed |= ICompilerConfiguration.PROCESSOR_CHANGED; this.changed |= ICompilerConfiguration.PROCESSOR_CHANGED;
} }


public void setJavaOptions(Map javaOptions) {
public void setJavaOptions(Map<String,String> javaOptions) {
this.javaOptionsMap = javaOptions; this.javaOptionsMap = javaOptions;
this.changed |= ICompilerConfiguration.JAVAOPTIONS_CHANGED; this.changed |= ICompilerConfiguration.JAVAOPTIONS_CHANGED;
} }
} }
} }


public void setSourcePathResources(Map sourcePathResources) {
public void setSourcePathResources(Map<String,File> sourcePathResources) {
this.sourcePathResources = sourcePathResources; this.sourcePathResources = sourcePathResources;
this.changed |= ICompilerConfiguration.PROJECTSOURCERESOURCES_CHANGED; this.changed |= ICompilerConfiguration.PROJECTSOURCERESOURCES_CHANGED;
} }
modifiedDirs = null; modifiedDirs = null;
} }


public List getClasspathElementsWithModifiedContents() {
public List<String> getClasspathElementsWithModifiedContents() {
return modifiedDirs; return modifiedDirs;
} }



+ 5
- 5
tests/src/org/aspectj/systemtest/incremental/tools/MultiProjTestMessageHandler.java Vedi File

private List<IMessage> errorMessages; private List<IMessage> errorMessages;
private List<IMessage> warningMessages; private List<IMessage> warningMessages;
private List<IMessage> weavingMessages; private List<IMessage> weavingMessages;
private List compilerErrors;
private List ignoring;
private List<String> compilerErrors;
private List<Kind> ignoring;


public MultiProjTestMessageHandler() { public MultiProjTestMessageHandler() {
ignoring = new ArrayList();
ignoring = new ArrayList<>();
errorMessages = new ArrayList<IMessage>(); errorMessages = new ArrayList<IMessage>();
warningMessages = new ArrayList<IMessage>(); warningMessages = new ArrayList<IMessage>();
weavingMessages = new ArrayList<IMessage>(); weavingMessages = new ArrayList<IMessage>();
compilerErrors = new ArrayList();
compilerErrors = new ArrayList<>();
ignore(IMessage.INFO); ignore(IMessage.INFO);
ignore(IMessage.WEAVEINFO); ignore(IMessage.WEAVEINFO);
} }
return weavingMessages; return weavingMessages;
} }


public List<IMessage> getCompilerErrors() {
public List<String> getCompilerErrors() {
return compilerErrors; return compilerErrors;
} }



+ 27
- 24
tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java Vedi File

import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
runMethod(p, "demo.ConverterTest", "run"); runMethod(p, "demo.ConverterTest", "run");
} }



public void testRogueConstantReference() throws Exception {
String p = "pr404345";
initialiseProject(p);
setProjectEncoding(p, "UTF-8");
build(p);
checkWasFullBuild();
// Should both indicate that Location cannot be resolved
assertEquals(2,getErrorMessages(p).size());
}
public void testIncrementalITDInners4() throws Exception { public void testIncrementalITDInners4() throws Exception {
String p = "prInner4"; String p = "prInner4";
initialiseProject(p); initialiseProject(p);
alter(p, "inc1"); alter(p, "inc1");
build(p); build(p);
checkWasntFullBuild(); checkWasntFullBuild();
List l = getCompilerErrorMessages(p);
List<String> l = getCompilerErrorMessages(p);
assertEquals("Unexpected compiler error", 0, l.size()); assertEquals("Unexpected compiler error", 0, l.size());
} }


String p = "pr298504"; String p = "pr298504";
initialiseProject(p); initialiseProject(p);
build(p); build(p);
List l = getErrorMessages(p);
List<IMessage> l = getErrorMessages(p);
assertTrue(l.toString().indexOf("ManagedResource cannot be resolved to a type") != -1); assertTrue(l.toString().indexOf("ManagedResource cannot be resolved to a type") != -1);
// checkWasFullBuild(); // checkWasFullBuild();
alter(p, "inc1"); alter(p, "inc1");
build(p); build(p);
// checkWasntFullBuild(); // checkWasntFullBuild();
l = getCompilerErrorMessages(p);
assertTrue(l.toString().indexOf("NullPointerException") == -1);
List<String> compilerErrors = getCompilerErrorMessages(p);
assertTrue(compilerErrors.toString().indexOf("NullPointerException") == -1);
l = getErrorMessages(p); l = getErrorMessages(p);
assertTrue(l.toString().indexOf("ManagedResource cannot be resolved to a type") != -1); assertTrue(l.toString().indexOf("ManagedResource cannot be resolved to a type") != -1);
} }
// "src/q/Asp.java")); // "src/q/Asp.java"));
build(p); build(p);
checkWasntFullBuild(); checkWasntFullBuild();
List<IMessage> l = getCompilerErrorMessages(p);
List<String> l = getCompilerErrorMessages(p);
assertEquals("Unexpected compiler error", 0, l.size()); assertEquals("Unexpected compiler error", 0, l.size());
} }


alter(p, "inc1"); alter(p, "inc1");
build(p); build(p);
checkWasntFullBuild(); checkWasntFullBuild();
List<IMessage> l = getCompilerErrorMessages(p);
List<String> l = getCompilerErrorMessages(p);
assertEquals("Unexpected compiler error", 0, l.size()); assertEquals("Unexpected compiler error", 0, l.size());
} }


checkWasFullBuild(); checkWasFullBuild();
alter(p, "inc1"); alter(p, "inc1");
build(p); build(p);
List<IMessage> l = getCompilerErrorMessages(p);
List<String> l = getCompilerErrorMessages(p);
assertEquals("Unexpected compiler error", 0, l.size()); assertEquals("Unexpected compiler error", 0, l.size());
} }


+ "ms second=" + timeTakenForSimpleIncBuild + "ms", timeTakenForSimpleIncBuild < timeTakenForFullBuildAndWeave); + "ms second=" + timeTakenForSimpleIncBuild + "ms", timeTakenForSimpleIncBuild < timeTakenForFullBuildAndWeave);
} }


@SuppressWarnings("rawtypes")
public void testBuildingTwoProjectsInTurns() { public void testBuildingTwoProjectsInTurns() {
initialiseProject("P1"); initialiseProject("P1");
initialiseProject("P2"); initialiseProject("P2");
long stime = System.currentTimeMillis(); long stime = System.currentTimeMillis();
try { try {
ZipFile zf = new ZipFile("c:/jvms/jdk1.6.0_06/jre/lib/rt.jar"); ZipFile zf = new ZipFile("c:/jvms/jdk1.6.0_06/jre/lib/rt.jar");
Enumeration e = zf.entries();
Enumeration<? extends ZipEntry> e = zf.entries();
while (e.hasMoreElements()) { while (e.hasMoreElements()) {
ZipEntry ze = (ZipEntry) e.nextElement(); ZipEntry ze = (ZipEntry) e.nextElement();
String n = ze.getName(); String n = ze.getName();
getWarningMessages("PR133117").size() == 1); getWarningMessages("PR133117").size() == 1);
alter("PR133117", "inc1"); alter("PR133117", "inc1");
build("PR133117"); build("PR133117");
List warnings = getWarningMessages("PR133117");
List noGuardWarnings = new ArrayList();
for (Iterator iter = warnings.iterator(); iter.hasNext();) {
IMessage element = (IMessage) iter.next();
if (element.getMessage().indexOf("Xlint:noGuardForLazyTjp") != -1) {
noGuardWarnings.add(element);
List<IMessage> warnings = getWarningMessages("PR133117");
List<IMessage> noGuardWarnings = new ArrayList<>();
for (IMessage warning: warnings) {
if (warning.getMessage().indexOf("Xlint:noGuardForLazyTjp") != -1) {
noGuardWarnings.add(warning);
} }
} }
assertTrue("There should only be two Xlint:noGuardForLazyTjp warning message reported:\n" + noGuardWarnings, assertTrue("There should only be two Xlint:noGuardForLazyTjp warning message reported:\n" + noGuardWarnings,
configureJavaOptionsMap("PR164384", javaOptions); configureJavaOptionsMap("PR164384", javaOptions);


build("PR164384"); build("PR164384");
List errors = getErrorMessages("PR164384");
List<IMessage> errors = getErrorMessages("PR164384");


if (getCompilerForProjectWithName("PR164384").isJava6Compatible()) { if (getCompilerForProjectWithName("PR164384").isJava6Compatible()) {
assertTrue("There should be no errros:\n" + errors, errors.isEmpty()); assertTrue("There should be no errros:\n" + errors, errors.isEmpty());
return ipe; return ipe;
} }
} }
List kids = ipe.getChildren();
for (Iterator iter = kids.iterator(); iter.hasNext();) {
IProgramElement kid = (IProgramElement) iter.next();
List<IProgramElement> kids = ipe.getChildren();
for (IProgramElement kid: kids) {
IProgramElement found = findAdvice(kid, whichOne); IProgramElement found = findAdvice(kid, whichOne);
if (found != null) { if (found != null) {
return found; return found;
} }
} }
List<IProgramElement> kids = ipe.getChildren(); List<IProgramElement> kids = ipe.getChildren();
for (Iterator iter = kids.iterator(); iter.hasNext();) {
IProgramElement kid = (IProgramElement) iter.next();
for (IProgramElement kid: kids) {
IProgramElement found = findCode(kid, linenumber); IProgramElement found = findCode(kid, linenumber);
if (found != null) { if (found != null) {
return found; return found;

Loading…
Annulla
Salva