Re: [abc-users] Exception in CheckPackageNames pass

From: Kevin Viggers <viggers@cpsc.ucalgary.ca>
Date: Thu Feb 24 2005 - 19:14:06 GMT

Hi Eric,

The story is told in the follow 3 lines from CheckPackageNames.

String filename=pctype.fromSource().path();
int dotindex=filename.lastIndexOf(".");
String gotname=filename.substring(0,dotindex).toLowerCase();

The first line expects the path to the file containing your aspect. For
whatever reason, the root of your problem is that this returned value
is not correct, and perhaps is even the empty string. As a result, in
the second line, the call to lastIndexOf() assigns dotindex a value of
-1, indicating that the filename string obtained does not contain any
".". In the third line, substring() blows up with a
StringIndexOutOfBoundsException because it is looking for a substring
from index 0 to index -1. This exception is eventually caught and
rethrown as an InternalCompilerError.

So, what it comes down to is that the Source object returned by
pctype.fromSource() is not being initialized correctly. According to
some comments in ParsedClassType, a return value of null from
fromSource() apparently may be appropriate in some cases.

Kevin

On 24-Feb-05, at 7:21 AM, Eric Bodden wrote:

>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi. Into ABC I stick something like the following "aspect". It holds
> a LTL formula that is lateron transformed into sensible code.
>
> package rwth.i2.ltlrv.formulas;
> public aspect F1580588821 {
> public F1580588821() {
> initFormula();
> }
> LTL(F(call(void AnnotationTest.bar())));
> }
>
> During passes_patterns_and_parents I get the following exception:
>
> Exception in thread "main" polyglot.util.InternalCompilerError:
> unhandled exception during compilation
> at abc.main.Main.run(Main.java:569)
> at abc.main.Main.main(Main.java:197)
> at junit.LTLParsingTest.testParsing(LTLParsingTest.java:27)
> at junit.LTLParsingTest.main(LTLParsingTest.java:33)
> Caused by: java.lang.StringIndexOutOfBoundsException: String index
> out of range: -1
> at java.lang.String.substring(String.java:1768)
> at
> abc.aspectj.visit.CheckPackageNames.once(CheckPackageNames.java:65)
> at abc.aspectj.visit.OncePass.run(OncePass.java:46)
> at
> polyglot.frontend.AbstractExtensionInfo.runPass(AbstractExtensionInfo.
> java:307)
> at
> polyglot.frontend.AbstractExtensionInfo.runToPass(AbstractExtensionInf
> o.java:227)
> at
> polyglot.frontend.AbstractExtensionInfo.runAllPasses(AbstractExtension
> Info.java:194)
> at
> polyglot.frontend.AbstractExtensionInfo.runToCompletion(AbstractExtens
> ionInfo.java:109)
> at polyglot.frontend.Compiler.compile(Compiler.java:95)
> at abc.main.Main.compile(Main.java:719)
> at abc.main.Main.run(Main.java:480)
> ... 3 more
>
> This is my list of passes:
>
> public List passes(Job job) {
>
> List<Pass> l = new ArrayList<Pass>();
> l.add(new InitClasses(INIT_CLASSES, this, ts));
>
> passes_parse_and_clean(l, job);
> //
> passes_patterns_and_parents(l, job); // <-- errror
> passes_precedence_relation(l, job);
> //
> passes_disambiguate_signatures(l, job);
>
> l.add(new GlobalBarrierPass(BARRIER_1, job));
>
> //transform formulas
> l.add(new VisitorPass(FORMULA_IDS, job, new
> FormulaIDExtractionVisitor()));
>
> l.add(new VisitorPass(FORMULA_CONSTRUCTORS, job, new
> FormulaConstructionVisitor()));
>
> l.add(new GlobalBarrierPass(BARRIER_2, job));
>
> l.add(new PrettyPrintPass(INSPECT_AST,job,new
> CodeWriter(System.out,1000),new PrettyPrinter()));
>
> passes_add_members(l, job);
> passes_interface_ITDs(l, job);
> passes_disambiguate_all(l, job);
> passes_fold_and_checkcode(l, job);
> passes_saveAST(l, job);
> passes_mangle_names(l, job);
> passes_aspectj_transforms(l, job);
> passes_jimple(l, job);
>
> return l;
> }
>
> Can anybody tell me why that exception could occur?
>
> Cheers,
> Eric
>
>
> - --
> Eric Bodden
> RWTH Aachen University
> ICQ UIN: 12656220, Skype: ericbodden, PGP: BB465582
> Website: http://www.bodden.de
>
> -----BEGIN PGP SIGNATURE-----
> Version: PGP 8.0.3
>
> iQA/AwUBQh3i2swiFCm7RlWCEQKt1QCeL5IekY//xiasEL3vGAvXPUvJhlkAnify
> aHouACKlxwTU/OAjojINuOLN
> =UjlB
> -----END PGP SIGNATURE-----
>
>
Received on Thu Feb 24 20:15:41 2005

This archive was generated by hypermail 2.1.8 : Thu Feb 24 2005 - 21:00:04 GMT