Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » AspectJ » StringIndexOutOfBoundsException is caught when modifying any .aj file
StringIndexOutOfBoundsException is caught when modifying any .aj file [message #714188] Wed, 10 August 2011 02:36 Go to next message
P  is currently offline P Friend
Messages: 3
Registered: August 2011
Junior Member
Hi,

As titled, such exception is thrown every time when I try to save any .aj file after modification. The details of the exception is attached. This problem occurs in Eclipse 3.6 and its later version, whereas it works fine in 3.5.1.

index.php/fa/3605/0/
index.php/fa/3606/0/

Does anyone know what is the cause and how to fix it? I am looking for the solution. Thanks in advance.


P.
  • Attachment: err+01.JPG
    (Size: 128.13KB, Downloaded 1048 times)
  • Attachment: err+02.JPG
    (Size: 128.55KB, Downloaded 1000 times)

[Updated on: Wed, 10 August 2011 04:04]

Report message to a moderator

Re: StringIndexOutOfBoundsException is caught when modifying any .aj file [message #714483 is a reply to message #714188] Wed, 10 August 2011 15:57 Go to previous messageGo to next message
Andrew Eisenberg is currently offline Andrew EisenbergFriend
Messages: 382
Registered: July 2009
Senior Member
Do you have a sample project that you can send over so we can look at it? The exception is happening in WTP, but it could be originally caused by something in AJDT. Since the problem spans multiple Eclipse projects, there's not much that I can do unless I have a way to recreate the failure.

What kind of project are you using? Obviously. it is an AspectJ project, but what other kinds of natures does it have?
Re: StringIndexOutOfBoundsException is caught when modifying any .aj file [message #714601 is a reply to message #714483] Thu, 11 August 2011 03:29 Go to previous messageGo to next message
P  is currently offline P Friend
Messages: 3
Registered: August 2011
Junior Member
Thanks for your reply, Andrew.

Sorry, I don't know how to provide the real sample codes because it is a bit complex. But, let me describe what the nature of my project is. In addition, I will do my best to give you some refined sample codes for description.

My project is a combination of JEE and Flex project. FlashBuilder plugin is installed in my Eclipse as well. Here is the hierarchy of my workspace.

myproject-ear: Enterprise Application Project
myproject-ejb: EJB Project
myproject-lib: Java Project
myproject-repo: A respository for Java and Flex
myproject-flex-lib: Flex Project
myproject-web: Java Web Project

myproject-ejb is the area that AspectJ is injected. A EJB instantiates a POJO class in order to perform its relevant operation. A pointcut is written for that POJO class. Let me give a simple sample.

MyPojoClass.java

public class MyPojoSample {

public MyPojoSample() {
}

public void start() {
// codes
}
}


MySampleBean.java

@Stateless
@EJB
public class MySampleBean implements MySampleLocal {

public void start() {
new MyPojoSample().start();
}
}


A simple aspect is written for MyPojoSample which contains a pointcut and its corresponding before(..) and after(..) advices.

MySampleAspect.aj

public aspect MySampleAspect {

pointcut start(MyPojoSample pojo):
call(public void MyPojoSample.start(..)) && target(pojo);

before(MyPojoSample pojo): start(pojo) {
// codes
}

after (MyPojoSample pojo): start(pojo) {
// codes
}
}


As you can see, there is nothing special for my codes. Originally, I thought the problem was about the FlashBuilder plugin. However, as I said before, it worked fine in Eclipse 3.5.1.

Did I give you enough clue? If not, please let me know what you need. Anyway, let me say thank you once again.


P.
Re: StringIndexOutOfBoundsException is caught when modifying any .aj file [message #714605 is a reply to message #714601] Thu, 11 August 2011 03:47 Go to previous messageGo to next message
Andrew Eisenberg is currently offline Andrew EisenbergFriend
Messages: 382
Registered: July 2009
Senior Member
This is a bug with the org.eclipse.jst.ws.jaxws.do.runtime project.

Here is the code of the method that is giving you the trouble:

	protected String guessPrimaryTypeName(ICompilationUnit cu)
	{
		final String parentName = cu.getParent().getElementName();
		final StringBuilder assumedPrimaryTypeName = new StringBuilder();
		if (parentName.length() > 0) {
			assumedPrimaryTypeName .append(parentName).append('.');
		}
		return assumedPrimaryTypeName.append(cu.getElementName()).
			delete(assumedPrimaryTypeName.lastIndexOf(".java"), assumedPrimaryTypeName.length()).toString();//$NON-NLS-1$
	}

Notice that in the return statement, there is the assumption that the file name ends in ',java'. Obviously, this will not work for '.aj' files (or '.scala' files, or '.groovy' files, etc). They need to fix this.

Here's what you should do:

1. raise a bug on the WTP project and describe the problem.
2. try to work around it in your project. It is possible to put aspects in your .java files (AJDT will not like it and many of your AJDT tools will break, but AJC doesn't mind it). You can probably do that. Or a better option would be to somehow configure configure things so that your aspect files are not analyzed by the jaxws plugin.
Re: StringIndexOutOfBoundsException is caught when modifying any .aj file [message #714607 is a reply to message #714605] Thu, 11 August 2011 03:57 Go to previous message
P  is currently offline P Friend
Messages: 3
Registered: August 2011
Junior Member
Thanks a lot, Andrew. You give me the direction in a lost sea.


P.
Previous Topic:CompilationParticipant
Next Topic:Error if super class not carrying annotation
Goto Forum:
  


Current Time: Fri Apr 19 14:22:38 GMT 2024

Powered by FUDForum. Page generated in 0.01955 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top