/********************************************************************
- * Copyright (c) 2007 Contributors. All rights reserved.
- * This program and the accompanying materials are made available
- * under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution and is available at
- * http://eclipse.org/legal/epl-v10.html
- *
- * Contributors: IBM Corporation - initial API and implementation
+ * Copyright (c) 2007 Contributors. All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: IBM Corporation - initial API and implementation
* Helen Hawkins - initial version (bug 148190)
*******************************************************************/
package org.aspectj.ajde.core.internal;
import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
/**
* Execute a full or incremental build
- *
+ *
* @param fullBuild true if requesting a full build, false if requesting to try an incremental build
*/
public void performBuild(boolean fullBuild) {
private String getFormattedOptionsString() {
ICompilerConfiguration compilerConfig = compiler.getCompilerConfiguration();
return "Building with settings: " + "\n-> output paths: "
- + formatCollection(compilerConfig.getOutputLocationManager().getAllOutputLocations()) + "\n-> classpath: "
- + compilerConfig.getClasspath() + "\n-> -inpath " + formatCollection(compilerConfig.getInpath()) + "\n-> -outjar "
- + formatOptionalString(compilerConfig.getOutJar()) + "\n-> -aspectpath "
- + formatCollection(compilerConfig.getAspectPath()) + "\n-> -sourcePathResources "
- + formatMap(compilerConfig.getSourcePathResources()) + "\n-> non-standard options: "
- + compilerConfig.getNonStandardOptions() + "\n-> javaoptions:" + formatMap(compilerConfig.getJavaOptionsMap());
+ + formatCollection(compilerConfig.getOutputLocationManager().getAllOutputLocations()) + "\n-> classpath: "
+ + compilerConfig.getClasspath() + "\n-> -inpath " + formatCollection(compilerConfig.getInpath()) + "\n-> -outjar "
+ + formatOptionalString(compilerConfig.getOutJar()) + "\n-> -aspectpath "
+ + formatCollection(compilerConfig.getAspectPath()) + "\n-> -sourcePathResources "
+ + formatMap(compilerConfig.getSourcePathResources()) + "\n-> non-standard options: "
+ + compilerConfig.getNonStandardOptions() + "\n-> javaoptions:" + formatMap(compilerConfig.getJavaOptionsMap());
}
private String formatCollection(Collection<?> options) {
/**
* Generate a new AjBuildConfig from the compiler configuration associated with this AjdeCoreBuildManager or from a
* configuration file.
- *
+ *
* @return null if invalid configuration, corresponding AjBuildConfig otherwise
*/
public AjBuildConfig generateAjBuildConfig() {
/********************************************************************
- * Copyright (c) 2007 Contributors. All rights reserved.
- * This program and the accompanying materials are made available
- * under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution and is available at
- * http://eclipse.org/legal/epl-v10.html
- *
- * Contributors: IBM Corporation - initial API and implementation
+ * Copyright (c) 2007 Contributors. All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: IBM Corporation - initial API and implementation
* Helen Hawkins - initial version
*******************************************************************/
package org.aspectj.ajde.core;
* after a specified string has been printed.
*/
public class TestBuildProgressMonitor implements IBuildProgressMonitor {
-
+
+ private static boolean verbose = System.getProperty("aspectj.tests.verbose","false").equalsIgnoreCase("true");
private static boolean debugTests = false;
-
+
public int numWovenClassMessages = 0;
- public int numWovenAspectMessages = 0;
- public int numCompiledMessages = 0;
-
+ public int numWovenAspectMessages = 0;
+ public int numCompiledMessages = 0;
+
private String programmableString;
private int count;
private List<String> messagesReceived = new ArrayList<>();
private int currentVal;
private boolean isCancelRequested = false;
-
+
public void finish(boolean wasFullBuild) {
System.out.println("build finished. Was full build: " + wasFullBuild);
}
}
public void setProgressText(String text) {
- System.out.println("progress text: " + text);
+ if (verbose) {
+ System.out.println("progress text: " + text);
+ }
String newText = text+" [Percentage="+currentVal+"%]";
messagesReceived.add(newText);
if (text.startsWith("woven aspect ")) numWovenAspectMessages++;
if (text.startsWith("woven class ")) numWovenClassMessages++;
if (text.startsWith("compiled:")) numCompiledMessages++;
if (programmableString != null
- && text.contains(programmableString)) {
+ && text.contains(programmableString)) {
count--;
if (count==0) {
if (debugTests) System.out.println("Just got message '"+newText+"' - asking build to cancel");
}
public void begin() {
- System.out.println("build started");
+ if (verbose) {
+ System.out.println("build started");
+ }
currentVal = 0;
}
programmableString = string;
this.count = count;
}
-
+
public boolean containsMessage(String prefix,String distinguishingMarks) {
for (String element: messagesReceived) {
if (element.startsWith(prefix) &&
}
return false;
}
-
+
public void dumpMessages() {
- System.out.println("ProgressMonitorMessages");
+ if (verbose) {
+ System.out.println("ProgressMonitorMessages");
+ }
for (String element: messagesReceived) {
System.out.println(element);
}
}
-
+
}
/********************************************************************
- * Copyright (c) 2003 Contributors. All rights reserved.
- * This program and the accompanying materials are made available
- * under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
+ * Copyright (c) 2003 Contributors. All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
* Matthew Webster initial implementation
* Helen Hawkins Converted to new interface (bug 148190)
*******************************************************************/
public static final String PROJECT_DIR = "OutxmlTest";
public static final String BIN_DIR = "bin";
- public static final String OUTJAR_NAME = "/bin/test.jar";
- public static final String DEFAULT_AOPXML_NAME = Constants.AOP_AJC_XML;
- public static final String CUSTOM_AOPXML_NAME = "custom/aop.xml";
+ public static final String OUTJAR_NAME = "/bin/test.jar";
+ public static final String DEFAULT_AOPXML_NAME = Constants.AOP_AJC_XML;
+ public static final String CUSTOM_AOPXML_NAME = "custom/aop.xml";
private String[] files = new String[]{
"src" + File.separator + "TestAbstractAspect.aj",
"src" + File.separator + "TestConcreteAspect.aj",
"src" + File.separator + "TestInterface.java"
};
-
+
private TestMessageHandler handler;
private TestCompilerConfiguration compilerConfig;
handler = null;
compilerConfig = null;
}
-
+
/**
* Aim: Test "-outxml" option produces the correct xml file
*/
compilerConfig.setNonStandardOptions("-outxml");
doBuild(true);
assertTrue("Expected no compiler errors or warnings but found "
- + handler.getMessages(), handler.getMessages().isEmpty());
+ + handler.getMessages(), handler.getMessages().isEmpty());
File aopxml = openFile(BIN_DIR + "/" + DEFAULT_AOPXML_NAME);
assertTrue(DEFAULT_AOPXML_NAME + " missing",aopxml.exists());
}
-
+
/**
- * Aim: Test "-outxmlfile filename" option produces the correct
+ * Aim: Test "-outxmlfile filename" option produces the correct
* xml file
- *
+ *
*/
public void testOutxmlfileToFile () {
compilerConfig.setProjectSourceFiles(getSourceFileList(files));
compilerConfig.setNonStandardOptions("-outxmlfile custom/aop.xml");
doBuild(true);
assertTrue("Expected no compiler errors or warnings but found "
- + handler.getMessages(), handler.getMessages().isEmpty());
-
+ + handler.getMessages(), handler.getMessages().isEmpty());
+
File aopxml = openFile(BIN_DIR + "/" + CUSTOM_AOPXML_NAME);
assertTrue(CUSTOM_AOPXML_NAME + " missing",aopxml.exists());
}
/**
- * Aim: Test "-outxml" option produces the correct
+ * Aim: Test "-outxml" option produces the correct
* xml entry in outjar file
- *
+ *
*/
public void testOutxmlToOutjar () {
File outjar = openFile(OUTJAR_NAME);
compilerConfig.setNonStandardOptions("-outxml");
doBuild(true);
assertTrue("Expected no compiler errors or warnings but found "
- + handler.getMessages(), handler.getMessages().isEmpty());
-
+ + handler.getMessages(), handler.getMessages().isEmpty());
+
File aopxml = openFile(BIN_DIR + "/" + DEFAULT_AOPXML_NAME);
assertFalse(DEFAULT_AOPXML_NAME + " should not exisit",aopxml.exists());
assertJarContainsEntry(outjar,DEFAULT_AOPXML_NAME);
}
/**
- * Aim: Test "-outxml" option produces a warning if "META-INF/aop.xml
+ * Aim: Test "-outxml" option produces a warning if "META-INF/aop.xml
* already exists in source
- *
+ *
*/
public void testOutxmlToOutjarWithAop_xml () {
File f = new File( getAbsoluteProjectDir() + File.separator + "src-resources" + File.separator + "testjar.jar");
Set<File> roots = new HashSet<>();
roots.add(f);
compilerConfig.setInpath(roots);
-
+
File outjar = openFile(OUTJAR_NAME);
compilerConfig.setOutjar(outjar.getAbsolutePath());
compilerConfig.setNonStandardOptions("-outxml");
doBuild(true);
assertFalse("Expected compiler errors or warnings but didn't find any "
+ handler.getMessages(), handler.getMessages().isEmpty());
-
+
List<TestMessage> msgs = handler.getMessages();
- String msg = ((TestMessageHandler.TestMessage)msgs.get(0)).getContainedMessage().getMessage();
+ String msg = msgs.get(0).getContainedMessage().getMessage();
String exp = "-outxml/-outxmlfile option ignored because resource already exists:";
assertTrue("Expected message to start with : " + exp + " but found message " + msg,msg.startsWith(exp));
-
+
File aopxml = openFile(BIN_DIR + "/" + DEFAULT_AOPXML_NAME);
assertFalse(DEFAULT_AOPXML_NAME + " should not exisit",aopxml.exists());
assertJarContainsEntry(outjar,DEFAULT_AOPXML_NAME);
}
-
+
/**
- * Aim: Test "-outxmlfile filename" option produces the correct
+ * Aim: Test "-outxmlfile filename" option produces the correct
* xml entry in outjar file
*/
public void testOutxmlfileToOutjar () {
compilerConfig.setNonStandardOptions("-outxmlfile custom/aop.xml");
doBuild(true);
assertTrue("Expected no compiler errors or warnings but found "
- + handler.getMessages(), handler.getMessages().isEmpty());
-
+ + handler.getMessages(), handler.getMessages().isEmpty());
+
File aopxml = openFile(BIN_DIR + "/" + CUSTOM_AOPXML_NAME);
assertFalse(CUSTOM_AOPXML_NAME + " should not exisit",aopxml.exists());
assertJarContainsEntry(outjar,CUSTOM_AOPXML_NAME);
}
private void assertJarContainsEntry (File file, String entryName) {
-
- try {
- JarFile jarFile = new JarFile(file);
+ try (JarFile jarFile = new JarFile(file)) {
JarEntry jarEntry = jarFile.getJarEntry(entryName);
assertNotNull(entryName + " missing",jarEntry);
}
/* *******************************************************************
* Copyright (c) 2004 Contributors.
- * All rights reserved.
- * This program and the accompanying materials are made available
- * under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
* Andy Clement Initial version
* Helen Hawkins Converted to new interface (bug 148190)
* ******************************************************************/
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Hashtable;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
* Weaving messages are complicated things. There are multiple places where weaving takes place and the places vary depending on
* whether we are doing a binary weave or going from source. All places that output weaving messages are tagged: // TAG:
* WeavingMessage so you can easily find them!
- *
+ *
* Advice is the simplest to deal with as that is advice weaving is always done in the weaver.
- *
+ *
* Next is intertype declarations. These are also always done in the weaver but in the case of a binary weave we don't know the
* originating source line for the ITD.
- *
+ *
* Finally, declares. Declare Parents: extends Can only be done when going from source, if attempted by a binary weave then an error
* message (compiler limitation) is produced. Declare Parents: implements Is (currently!) done at both compile time and weave time.
* If going from source then the message is produced by the code in the compiler. if going from binary then the message is produced
* by the weaver. Declare Soft: Comes out with 'advice' as a special kind of advice: softener advice
- *
- *
+ *
+ *
* Q: Where are the messages turned on/off? A: It is a bit messy. See BuildArgParser.genBuildConfig(). Basically that method is the
* first time we parse the option set. Whether weaving messages are on or off is stored in the build config. As soon as we have
* parser the options and determined that weave messages are on, we grab the top level message handler and tell it not to ignore
* WeaveInfo messages.
- *
- *
+ *
+ *
* TODO - Other forms of declare? Do they need messages? e.g. declare precedence *
*/
public class ShowWeaveMessagesTest extends AjdeCoreTestCase {
/* *******************************************************************
* Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
- * All rights reserved.
- * This program and the accompanying materials are made available
- * under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
* ******************************************************************/
package org.aspectj.ajde.core.tests.model;
public class AsmDeclarationsTest extends AjdeCoreTestCase {
- private AsmManager manager = null;
+ // private AsmManager manager = null;
private IHierarchy model = null;
private final String[] files = new String[] { "ModelCoverage.java", "pkg" + File.separator + "InPackage.java" };
compilerConfig.setProjectSourceFiles(getSourceFileList(files));
compilerConfig.setNonStandardOptions("-Xset:minimalModel=false");
doBuild();
- manager = AsmManager.lastActiveStructureModel;
+ // manager = AsmManager.lastActiveStructureModel;
model = AsmManager.lastActiveStructureModel.getHierarchy();
}
public void testFileInPackageAndDefaultPackage() {
IProgramElement root = model.getRoot();
assertEquals(root.toLabelString(), "coverage");
- IProgramElement pkg = (IProgramElement) root.getChildren().get(1);
+ IProgramElement pkg = root.getChildren().get(1);
assertEquals(pkg.toLabelString(), "pkg");
- assertEquals(((IProgramElement) pkg.getChildren().get(0)).toLabelString(), "InPackage.java");
- assertEquals(((IProgramElement) ((IProgramElement) root.getChildren().get(0)).getChildren().get(0)).toLabelString(),
+ assertEquals(pkg.getChildren().get(0).toLabelString(), "InPackage.java");
+ assertEquals(root.getChildren().get(0).getChildren().get(0).toLabelString(),
"ModelCoverage.java");
}
// check the next two relative to this one
int declareIndex = decParentsNode.getParent().getChildren().indexOf(decParentsNode);
String decParentsPtnMessage = "declare parents: extends Observable";
- assertEquals(decParentsPtnMessage, ((IProgramElement) aspect.getChildren().get(declareIndex + 1)).toLabelString());
+ assertEquals(decParentsPtnMessage, aspect.getChildren().get(declareIndex + 1).toLabelString());
String decParentsTPMessage = "declare parents: extends Observable";
- assertEquals(decParentsTPMessage, ((IProgramElement) aspect.getChildren().get(declareIndex + 2)).toLabelString());
+ assertEquals(decParentsTPMessage, aspect.getChildren().get(declareIndex + 2).toLabelString());
String decSoftMessage = "declare soft: SizeException";
IProgramElement decSoftNode = model.findElementForSignature(aspect, IProgramElement.Kind.DECLARE_SOFT, "declare soft");
/* *******************************************************************
* Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
- * All rights reserved.
- * This program and the accompanying materials are made available
- * under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
* ******************************************************************/
package org.aspectj.ajde.core.tests.model;
import java.io.File;
-import java.util.Iterator;
import java.util.List;
import org.aspectj.ajde.core.AjdeCoreTestCase;
/* *******************************************************************
* Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
- * All rights reserved.
- * This program and the accompanying materials are made available
- * under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Xerox/PARC initial implementation
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Xerox/PARC initial implementation
* AMC 21.01.2003 fixed for new source location in eclipse.org
* Helen Hawkins Converted to new interface (bug 148190)
* ******************************************************************/
import java.io.File;
import java.io.IOException;
-import java.util.Iterator;
import org.aspectj.ajde.core.AjdeCoreTestCase;
import org.aspectj.ajde.core.TestCompilerConfiguration;
File testFile = openFile("figures" + File.separator + "Figure.java");
IProgramElement node = manager.getHierarchy().findElementForSourceFile(testFile.getAbsolutePath());
assertTrue("find result", node != null);
- String child = ((IProgramElement) node.getChildren().get(2)).getName();
+ String child = node.getChildren().get(2).getName();
assertTrue("expected Figure got child " + child, child.equals("Figure"));
}
File testFile = openFile("figures" + File.separator + "Main.java");
IProgramElement node = manager.getHierarchy().findElementForSourceFile(testFile.getAbsolutePath());
assertTrue("find result", node != null);
- IProgramElement pNode = (IProgramElement) (node).getChildren().get(3);
+ IProgramElement pNode = (node).getChildren().get(3);
assertEquals(IProgramElement.Kind.ASPECT, pNode.getKind());
- IProgramElement pointcut = (IProgramElement) pNode.getChildren().get(0);
+ IProgramElement pointcut = pNode.getChildren().get(0);
assertTrue("kind", pointcut.getKind().equals(IProgramElement.Kind.POINTCUT));
assertTrue("found node: " + pointcut.getName(), pointcut.toLabelString().equals("testptct()"));
}
private int incrementalStage = 10;
private boolean shouldEmptySandbox = true;
private final AjcCommandController controller;
- public static boolean verbose = System.getProperty("org.aspectj.tools.ajc.Ajc.verbose", "true").equals("true");
+ public static boolean verbose = System.getProperty("aspectj.tests.verbose", "true").equals("true");
/**
* Constructs a new Ajc instance, with a new AspectJ compiler inside.
public final static PrintStream out = System.out;
private final static DelegatingOutputStream delegatingErr;
private final static DelegatingOutputStream delegatingOut;
- public final static boolean DEFAULT_VERBOSE = getBoolean("org.aspectj.tools.ajc.AjcTestCase.verbose", true);
+ public final static boolean DEFAULT_VERBOSE = getBoolean("aspectj.tests.verbose", true);
public final static boolean DEFAULT_ERR_VERBOSE = getBoolean("org.aspectj.tools.ajc.AjcTestCase.verbose.err", DEFAULT_VERBOSE);
public final static boolean DEFAULT_OUT_VERBOSE = getBoolean("org.aspectj.tools.ajc.AjcTestCase.verbose.out", DEFAULT_VERBOSE);
System.out.println("Annotation count is "+annos.length);
for (Annotation anno: la) {
- System.out.println(anno);
+ print(anno);
}
}
} catch (Exception e) {
}
}
+ static void print(Annotation anno) {
+ if (anno instanceof AnnoDouble) {
+ AnnoDouble ad = ((AnnoDouble)anno);
+ System.out.println("@AnnoDouble(value="+ad.value()+",ddd="+ad.ddd()+")");
+ } else {
+ System.out.println(anno);
+ }
+ }
+
static class AnnoComparator implements Comparator<Annotation> {
public int compare(Annotation a, Annotation b) {
return a.toString().compareTo(b.toString());
/********************************************************************
- * Copyright (c) 2005 Contributors.All rights reserved.
- * This program and the accompanying materials are made available
- * under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution and is available at
- * http://eclipse.org/legal/epl-v10.html
- *
- * Contributors:
+ * Copyright (c) 2005 Contributors.All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
* Andy Clement initial implementation
* Helen Hawkins Converted to new interface (bug 148190)
*******************************************************************/
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* This class uses Ajde in the same way that an IDE (e.g. AJDT) does.
- *
+ *
* The build is driven through 'doBuild(projectName)' but the build can be configured by the methods beginning 'configure***'.
* Information about what happened during a build is accessible through the get*, was*, print* public methods...
- *
+ *
*/
public class AjdeInteractionTestbed extends TestCase {
- public static boolean VERBOSE = false; // do you want the gory details?
+ public static boolean VERBOSE = System.getProperty("aspectj.tests.verbose","true").equalsIgnoreCase("true");
public static String testdataSrcDir = "../tests/multiIncremental";
protected static File sandboxDir;
decisions.append(s).append("\n");
log(s);
}
- };
+ }
}
\ No newline at end of file
<line text="Annotation count is 4"/>
<line text="@AnnoChar(value=z, ccc=a)" vm="1.2,1.3,1.4,1.5,1.6,1.7,1.8"/>
<line text="@AnnoChar(value='z', ccc='a')" vm="9+"/>
- <line text="@AnnoDouble(ddd=3.0, value=99.0)" vm="1.2,1.3,1.4,1.5,1.6,1.7,1.8"/>
- <line text="@AnnoDouble(value=99.0, ddd=3.0)" vm="11,12,13,14+"/>
+ <line text="@AnnoDouble(value=99.0,ddd=3.0)"/>
<line text="@AnnoFloat(value=6.0, fff=4.0)" vm="1.2,1.3,1.4,1.5,1.6,1.7,1.8"/>
<line text="@AnnoFloat(value=6.0f, fff=4.0f)" vm="9+"/>
<line text="@AnnoShort(value=8, sss=3)"/>
private static Trace trace = TraceFactory.getTraceFactory().getTrace(BcelClassWeaver.class);
// Name of helper method generated by JDT compiler. Javac uses a separate inner class.
- private static final String SWITCH_TABLE_SYNTHETIC_METHOD_PREFIX = "$SWITCH_TABLE$";
+ private static final String SWITCH_TABLE_SYNTHETIC_METHOD_PREFIX = "$SWITCH_TABLE$";
public static boolean weave(BcelWorld world, LazyClassGen clazz, List<ShadowMunger> shadowMungers,
List<ConcreteTypeMunger> typeMungers, List<ConcreteTypeMunger> lateTypeMungers, boolean inReweavableMode) {
return false; // dont bother if we are an interface
}
- boolean didSomething = false; // set if we build any bridge methods
// So what methods do we have right now in this class?
List<LazyMethodGen> methods = clazz.getMethodGens();
methodsSet.add(sb.toString()); // e.g. "foo(Ljava/lang/String;)V"
}
+ List<BridgeMethodDescriptor> bridges = null;
// Now go through all the methods in this type
for (LazyMethodGen bridgeToCandidate : methods) {
// This is the local method that we *might* have to bridge to
if (world.forDEBUG_bridgingCode) {
System.err.println("Bridging:bridging to '" + overriddenMethod + "'");
}
- createBridgeMethod(world, bridgeToCandidate, clazz, overriddenMethod);
+ if (bridges== null) {
+ bridges = new ArrayList<>();
+ }
+ bridges.add(new BridgeMethodDescriptor(bridgeToCandidate, overriddenMethod));
+ //createBridgeMethod(world, bridgeToCandidate, clazz, overriddenMethod);
methodsSet.add(key);
- didSomething = true;
}
}
}
String key = new StringBuffer().append(overriddenMethod.getName()).append(overriddenMethod.getSignatureErased()).toString(); // pr237419
boolean alreadyHaveABridgeMethod = methodsSet.contains(key);
if (!alreadyHaveABridgeMethod) {
- createBridgeMethod(world, bridgeToCandidate, clazz, overriddenMethod);
+ if (bridges== null) {
+ bridges = new ArrayList<>();
+ }
+ bridges.add(new BridgeMethodDescriptor(bridgeToCandidate, overriddenMethod));
+ // createBridgeMethod(world, bridgeToCandidate, clazz, overriddenMethod);
methodsSet.add(key);
- didSomething = true;
if (world.forDEBUG_bridgingCode) {
System.err.println("Bridging:bridging to " + overriddenMethod);
}
}
}
- return didSomething;
+ if (bridges != null) {
+ for (BridgeMethodDescriptor bmDescriptor: bridges) {
+ createBridgeMethod(world, bmDescriptor.bridgeToCandidate, clazz, bmDescriptor.overriddenMethod);
+ }
+ }
+
+ return bridges!=null && !bridges.isEmpty();
+ }
+
+ static class BridgeMethodDescriptor {
+
+ final LazyMethodGen bridgeToCandidate;
+ final ResolvedMember overriddenMethod;
+
+ public BridgeMethodDescriptor(LazyMethodGen bridgeToCandidate, ResolvedMember overriddenMethod) {
+ this.bridgeToCandidate = bridgeToCandidate;
+ this.overriddenMethod = overriddenMethod;
+ }
+
}
// **************************** end of bridge method creation code *****************
for (LazyMethodGen method: addedLazyMethodGens) {
// They have no resolvedmember of their own, conjure one up for matching purposes
ResolvedMember resolvedmember =
- new ResolvedMemberImpl(ResolvedMember.METHOD,method.getEnclosingClass().getType(),method.getAccessFlags(),
- BcelWorld.fromBcel(method.getReturnType()),method.getName(),
- BcelWorld.fromBcel(method.getArgumentTypes()),UnresolvedType.forNames(method.getDeclaredExceptions()));
+ new ResolvedMemberImpl(ResolvedMember.METHOD,method.getEnclosingClass().getType(),method.getAccessFlags(),
+ BcelWorld.fromBcel(method.getReturnType()),method.getName(),
+ BcelWorld.fromBcel(method.getArgumentTypes()),UnresolvedType.forNames(method.getDeclaredExceptions()));
resolvedmember.setAnnotationTypes(method.getAnnotationTypes());
resolvedmember.setAnnotations(method.getAnnotations());
WeaveMessage.WEAVEMESSAGE_ANNOTATES,
new String[] { sig.toString(), loc.toString(), decaM.getAnnotationString(),
methodName.startsWith("<init>") ? "constructor" : "method", decaM.getAspect().toString(),
- Utility.beautifyLocation(decaM.getSourceLocation()) }));
+ Utility.beautifyLocation(decaM.getSourceLocation()) }));
}
}
world.getMessageHandler().handleMessage(
WeaveMessage.constructWeavingMessage(
isRemove ? WeaveMessage.WEAVEMESSAGE_REMOVES_ANNOTATION : WeaveMessage.WEAVEMESSAGE_ANNOTATES,
- new String[] { theField.getFieldAsIs().toString() + "' of type '" + clazz.getName(),
- clazz.getFileName(), decaf.getAnnotationString(), "field", decaf.getAspect().toString(),
- Utility.beautifyLocation(decaf.getSourceLocation()) }));
+ new String[] { theField.getFieldAsIs().toString() + "' of type '" + clazz.getName(),
+ clazz.getFileName(), decaf.getAnnotationString(), "field", decaf.getAspect().toString(),
+ Utility.beautifyLocation(decaf.getSourceLocation()) }));
}
}
cpi.setIndex(recipientCpg.addConstant(donorCpg.getConstant(cpi.getIndex()), donorCpg));
}
// May need to copy bootstrapmethods across too.
-// if (fresh instanceof InvokeDynamic) {
-// InvokeDynamic id = (InvokeDynamic)fresh;
-// ConstantInvokeDynamic cid = (ConstantInvokeDynamic)donorCpg.getConstant(src.getInstruction().getIndex());
-// int bmaIndex = cid.getBootstrapMethodAttrIndex();
-// if (bootstrapMethods == null) {
-// Collection<Attribute> attributes = donor.getEnclosingClass().getAttributes();
-// if (attributes != null) {
-// for (Attribute attribute: attributes) {
-// if (attribute instanceof BootstrapMethods) {
-// bootstrapMethods = (BootstrapMethods)attribute;
-// }
-// }
-// }
-// BootstrapMethods.BootstrapMethod bootstrapMethod =
-// bootstrapMethods.getBootstrapMethods()[bmaIndex];
-// ConstantMethodHandle methodhandle = (ConstantMethodHandle)donorCpg.getConstant(bootstrapMethod.getBootstrapMethodRef());
-// int bootstrapMethodArguments[] = bootstrapMethod.getBootstrapArguments();
-//
-// // Finally have all we need to build the new one...
-//
-// int newMethodHandleIndex = recipientCpg.addConstant(methodhandle, donorCpg);
-// int[] newMethodArguments = new int[bootstrapMethodArguments.length];
-// for (int a=0; a<bootstrapMethodArguments.length; a++) {
-// newMethodArguments[a] = recipientCpg.addConstant(donorCpg.getConstant(bootstrapMethodArguments[a]),donorCpg);
-// }
-// BootstrapMethods.BootstrapMethod newBootstrapMethod =
-// new BootstrapMethods.BootstrapMethod(newMethodHandleIndex,newMethodArguments);
-//
-// Collection<Attribute> newAttributes = recipient.getEnclosingClass().getAttributes();
-// BootstrapMethods newBootstrapMethods = null;
-// for (Attribute attr: newAttributes) {
-// if (attr instanceof BootstrapMethods) {
-// newBootstrapMethods = (BootstrapMethods)newBootstrapMethods;
-// }
-// }
-// if (newBootstrapMethods == null) {
-// newBootstrapMethods =
-// new BootstrapMethods(recipientCpg.addUtf8("BootstrapMethods"),
-// 2+newBootstrapMethod.getLength(),
-// new BootstrapMethods.BootstrapMethod[] {newBootstrapMethod},
-// recipientCpg);
-// recipient.getEnclosingClass().addAttribute(newBootstrapMethods);
-// }
-// TODO need to copy over lambda$0 support methods too...
-// }
-//
-// }
+ // if (fresh instanceof InvokeDynamic) {
+ // InvokeDynamic id = (InvokeDynamic)fresh;
+ // ConstantInvokeDynamic cid = (ConstantInvokeDynamic)donorCpg.getConstant(src.getInstruction().getIndex());
+ // int bmaIndex = cid.getBootstrapMethodAttrIndex();
+ // if (bootstrapMethods == null) {
+ // Collection<Attribute> attributes = donor.getEnclosingClass().getAttributes();
+ // if (attributes != null) {
+ // for (Attribute attribute: attributes) {
+ // if (attribute instanceof BootstrapMethods) {
+ // bootstrapMethods = (BootstrapMethods)attribute;
+ // }
+ // }
+ // }
+ // BootstrapMethods.BootstrapMethod bootstrapMethod =
+ // bootstrapMethods.getBootstrapMethods()[bmaIndex];
+ // ConstantMethodHandle methodhandle = (ConstantMethodHandle)donorCpg.getConstant(bootstrapMethod.getBootstrapMethodRef());
+ // int bootstrapMethodArguments[] = bootstrapMethod.getBootstrapArguments();
+ //
+ // // Finally have all we need to build the new one...
+ //
+ // int newMethodHandleIndex = recipientCpg.addConstant(methodhandle, donorCpg);
+ // int[] newMethodArguments = new int[bootstrapMethodArguments.length];
+ // for (int a=0; a<bootstrapMethodArguments.length; a++) {
+ // newMethodArguments[a] = recipientCpg.addConstant(donorCpg.getConstant(bootstrapMethodArguments[a]),donorCpg);
+ // }
+ // BootstrapMethods.BootstrapMethod newBootstrapMethod =
+ // new BootstrapMethods.BootstrapMethod(newMethodHandleIndex,newMethodArguments);
+ //
+ // Collection<Attribute> newAttributes = recipient.getEnclosingClass().getAttributes();
+ // BootstrapMethods newBootstrapMethods = null;
+ // for (Attribute attr: newAttributes) {
+ // if (attr instanceof BootstrapMethods) {
+ // newBootstrapMethods = (BootstrapMethods)newBootstrapMethods;
+ // }
+ // }
+ // if (newBootstrapMethods == null) {
+ // newBootstrapMethods =
+ // new BootstrapMethods(recipientCpg.addUtf8("BootstrapMethods"),
+ // 2+newBootstrapMethod.getLength(),
+ // new BootstrapMethods.BootstrapMethod[] {newBootstrapMethod},
+ // recipientCpg);
+ // recipient.getEnclosingClass().addAttribute(newBootstrapMethods);
+ // }
+ // TODO need to copy over lambda$0 support methods too...
+ // }
+ //
+ // }
}
if (src.getInstruction() == Range.RANGEINSTRUCTION) {
dest = ret.append(Range.RANGEINSTRUCTION);
return false;
}
if (mg.getName().startsWith(SWITCH_TABLE_SYNTHETIC_METHOD_PREFIX)
- && Objects.equals(mg.getReturnType().getSignature(), "[I")) {
+ && Objects.equals(mg.getReturnType().getSignature(), "[I")) {
// this is a synthetic switch helper, should be skipped (since it's not 'declared')
return false;
}
&& s.charAt(4) == 'a'
&& (s.equals("org.aspectj.runtime.internal.CFlowCounter")
|| s.equals("org.aspectj.runtime.internal.CFlowStack") || s
- .equals("org.aspectj.runtime.reflect.Factory"))) {
+ .equals("org.aspectj.runtime.reflect.Factory"))) {
proceed = false;
} else {
if (methodName.equals("aspectOf")) {