+ "should be increased from 64M (default) to 128M or even 256M." + LangUtil.EOL + LangUtil.EOL
+ "See the AspectJ FAQ available from the documentation link" + LangUtil.EOL
+ "on the AspectJ home page at http://www.eclipse.org/aspectj";
-
+
+ private static final String MESSAGE_HOLDER_OPTION = "-messageHolder";
+
/** @param args the String[] of command-line arguments */
public static void main(String[] args) throws IOException {
new Main().runMain(args, true);
/** if not null, run this synchronously after each compile completes */
private Runnable completionRunner;
-
+
public Main() {
controller = new CommandController();
commandName = ReflectionFactory.ECLIPSE;
*/
public void runMain(String[] args, boolean useSystemExit) {
final boolean verbose = flagInArgs("-verbose", args);
+ if (null == this.clientHolder) {
+ this.clientHolder = checkForCustomMessageHolder(args);
+ }
IMessageHolder holder = clientHolder;
if (null == holder) {
- holder = ourHandler;
+ holder = ourHandler;
if (verbose) {
ourHandler.setInterceptor(MessagePrinter.VERBOSE);
} else {
ourHandler.ignore(IMessage.INFO);
ourHandler.setInterceptor(MessagePrinter.TERSE);
}
- }
+ }
// make sure we handle out of memory gracefully...
try {
}
}
+ /**
+ * @param args
+ */
+ private IMessageHolder checkForCustomMessageHolder(String[] args) {
+ IMessageHolder holder = null;
+ final String customMessageHolder = parmInArgs(MESSAGE_HOLDER_OPTION, args);
+ if (customMessageHolder != null) {
+ try {
+ holder = (IMessageHolder) Class.forName(customMessageHolder).newInstance();
+ }
+ catch(Exception ex) {
+ holder = ourHandler;
+ throw new AbortException("Failed to create custom message holder of class '" +
+ customMessageHolder + "' : " + ex);
+ }
+ }
+ return holder;
+ }
+
/**
* Run without using System.exit(..), putting all messages in holder:
* <ul>
clientHolder = holder;
}
+ public IMessageHolder getHolder() {
+ return clientHolder;
+ }
+
/**
* Install a Runnable to be invoked synchronously
* after each compile completes.
import java.util.ArrayList;
import java.util.ResourceBundle;
+import org.aspectj.bridge.AbortException;
+
/**
*
*/
assertMessages(result,"Expecting xoptions usage message",
new MessageSpec(null,null,null,newMessageList(new Message(xoptionText)),null));
}
+
+ public void testDashMessageHolder() {
+ try {
+ new Main().runMain(new String[] {"-messageHolder","org.xyz.abc"},false);
+ fail ("Should have thrown abort exception");
+ } catch (AbortException ex) {
+ // good
+ }
+ }
+
+ public void testDashMessageHolderOk() {
+ Main main = new Main();
+ main.runMain(new String[] {"-messageHolder","org.aspectj.tools.ajc.TestMessageHolder"},false);
+ assertSame("ajc should be using our message handler",TestMessageHolder.class,main.getHolder().getClass());
+ }
}
--- /dev/null
+/* *******************************************************************
+ * 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:
+ * Adrian Colyer Initial implementation
+ * ******************************************************************/
+package org.aspectj.tools.ajc;
+
+import java.util.List;
+
+import org.aspectj.bridge.AbortException;
+import org.aspectj.bridge.IMessage;
+import org.aspectj.bridge.IMessageHolder;
+import org.aspectj.bridge.IMessage.Kind;
+
+/**
+ * @author Adrian
+ *
+ * Deliberately empty implementation of IMessageHolder
+ */
+public class TestMessageHolder implements IMessageHolder {
+
+ /* (non-Javadoc)
+ * @see org.aspectj.bridge.IMessageHolder#hasAnyMessage(org.aspectj.bridge.IMessage.Kind, boolean)
+ */
+ public boolean hasAnyMessage(Kind kind, boolean orGreater) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.aspectj.bridge.IMessageHolder#numMessages(org.aspectj.bridge.IMessage.Kind, boolean)
+ */
+ public int numMessages(Kind kind, boolean orGreater) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ /* (non-Javadoc)
+ * @see org.aspectj.bridge.IMessageHolder#getMessages(org.aspectj.bridge.IMessage.Kind, boolean)
+ */
+ public IMessage[] getMessages(Kind kind, boolean orGreater) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.aspectj.bridge.IMessageHolder#getUnmodifiableListView()
+ */
+ public List getUnmodifiableListView() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.aspectj.bridge.IMessageHolder#clearMessages()
+ */
+ public void clearMessages() throws UnsupportedOperationException {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.aspectj.bridge.IMessageHandler#handleMessage(org.aspectj.bridge.IMessage)
+ */
+ public boolean handleMessage(IMessage message) throws AbortException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.aspectj.bridge.IMessageHandler#isIgnoring(org.aspectj.bridge.IMessage.Kind)
+ */
+ public boolean isIgnoring(Kind kind) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.aspectj.bridge.IMessageHandler#dontIgnore(org.aspectj.bridge.IMessage.Kind)
+ */
+ public void dontIgnore(Kind kind) {
+ // TODO Auto-generated method stub
+
+ }
+
+}