IllegalAccessError trying to access pegdown Parser from extension

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

IllegalAccessError trying to access pegdown Parser from extension

jhinkey
I've done a simple extension of the pegdown Parser in class ParserExt below ...

public class ParserExt extends Parser {

	public ParserExt(Integer options) {
		super(options);
	}

	public ParserExt(Integer options, ParseRunnerProvider parseRunnerProvider) {
		super(options, parseRunnerProvider);
	}

	public static void main(String[] args) {

		PegDownProcessor pegDownProcessor = new PegDownProcessor(
				Parboiled.createParser(ParserExt.class, Extensions.ALL));

		String processedOutput = pegDownProcessor.markdownToHtml(
				"*Hello*".toCharArray(), new LinkRenderer());

		System.out.print(processedOutput);
	}
}

But when I run the main I get the following ...

E:\workImport60x\Jim>java -classpath bin;lib/asm.jar;lib/asm-analysis.jar;lib/asm-commons.jar;lib/asm-tree.jar;lib/asm-util.jar;lib/asm-xml.jar;lib/parboiled-core-1.0.2.jar;lib/parboiled-java-1.0.2.jar;lib/pegdown-1.1.0.jar ParserExt
Exception in thread "main" java.lang.IllegalAccessError: tried to access class org.pegdown.Parser$4 from class ParserExt$$parboiled
        at ParserExt$$parboiled.OrderedList(Unknown Source)
        at ParserExt$$parboiled.Block(Unknown Source)
        at ParserExt$$parboiled.Root(Unknown Source)
        at org.pegdown.Parser.parseToParsingResult(Parser.java:1296)
        at org.pegdown.Parser.parseInternal(Parser.java:1284)
        at org.pegdown.Parser.parse(Parser.java:76)
        at org.pegdown.PegDownProcessor.parseMarkdown(PegDownProcessor.java:110)

        at org.pegdown.PegDownProcessor.markdownToHtml(PegDownProcessor.java:99)

        at ParserExt.main(ParserExt.java:23)

I've tried compiling and running with Java 6 and Java 7 JDKs but still get the same result. I'm wondering if I should build parboiled and pegdown locally and try again; but I'm curious if anyone else is running into this or has some ideas as to how to resolve.

Thanks

Jim
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: IllegalAccessError trying to access pegdown Parser from extension

jhinkey
As my colleague discovered, the following change in creating the Parser and PegDownProcessor resolves the IllegalAccessError, but uncovers a GrammarException.



public class ParserExt extends Parser {

	public ParserExt(Integer options) {
		super(options);
	}

	public ParserExt(Integer options, ParseRunnerProvider parseRunnerProvider) {
		super(options, parseRunnerProvider);
	}

	public static void main(String[] args) {

		ParserExt parser = new ParserExt(Extensions.ALL);

		PegDownProcessor pegDownProcessor = new PegDownProcessor(parser);

//old		PegDownProcessor pegDownProcessor = new PegDownProcessor(
//				Parboiled.createParser(ParserExt.class, Extensions.ALL));

		String processedOutput = pegDownProcessor.markdownToHtml(
				"*Hello*".toCharArray(), new LinkRenderer());

		System.out.print(processedOutput);
	}
}

Current runtime exception ...
Exception in thread "main" org.parboiled.errors.GrammarException: Illegal rule definition: Unwrapped action expression!
	at org.parboiled.support.Checks.ensure(Checks.java:49)
	at org.parboiled.BaseActions.check(BaseActions.java:435)
	at org.parboiled.BaseActions.push(BaseActions.java:172)
	at org.pegdown.Parser.Root(Parser.java:89)
	at org.pegdown.Parser.parseToParsingResult(Parser.java:1296)
	at org.pegdown.Parser.parseInternal(Parser.java:1284)
	at org.pegdown.Parser.parse(Parser.java:76)
	at org.pegdown.PegDownProcessor.parseMarkdown(PegDownProcessor.java:110)
	at org.pegdown.PegDownProcessor.markdownToHtml(PegDownProcessor.java:99)
	at ParserExt.main(ParserExt.java:24)

Is calling Parboiled.createParser(...) the recommended way of creating an extension of pegdown Parser?
Thanks.

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: IllegalAccessError trying to access pegdown Parser from extension

mathias
Administrator
Jim,

yeah, the IllegalAccessError is a known limitation in parser class hierarchies spanning multiple packages.
Try putting your extended parser in the same package as the original pegdown parser and you should be all set.

Cheers,
Mathias

---
[hidden email]
http://www.parboiled.org

On 09.05.2012, at 21:09, jhinkey [via parboiled users] wrote:

> As my colleague discovered, the following change in creating the Parser and PegDownProcessor resolves the IllegalAccessError, but uncovers a GrammarException.
>
>
>
> public class ParserExt extends Parser {
>
> public ParserExt(Integer options) {
> super(options);
> }
>
> public ParserExt(Integer options, ParseRunnerProvider parseRunnerProvider) {
> super(options, parseRunnerProvider);
> }
>
> public static void main(String[] args) {
>
> ParserExt parser = new ParserExt(Extensions.ALL);
>
> PegDownProcessor pegDownProcessor = new PegDownProcessor(parser);
>
> //old PegDownProcessor pegDownProcessor = new PegDownProcessor(
> // Parboiled.createParser(ParserExt.class, Extensions.ALL));
>
> String processedOutput = pegDownProcessor.markdownToHtml(
> "*Hello*".toCharArray(), new LinkRenderer());
>
> System.out.print(processedOutput);
> }
> }
>
>
> Current runtime exception ...
> Exception in thread "main" org.parboiled.errors.GrammarException: Illegal rule definition: Unwrapped action expression!
> at org.parboiled.support.Checks.ensure(Checks.java:49)
> at org.parboiled.BaseActions.check(BaseActions.java:435)
> at org.parboiled.BaseActions.push(BaseActions.java:172)
> at org.pegdown.Parser.Root(Parser.java:89)
> at org.pegdown.Parser.parseToParsingResult(Parser.java:1296)
> at org.pegdown.Parser.parseInternal(Parser.java:1284)
> at org.pegdown.Parser.parse(Parser.java:76)
> at org.pegdown.PegDownProcessor.parseMarkdown(PegDownProcessor.java:110)
> at org.pegdown.PegDownProcessor.markdownToHtml(PegDownProcessor.java:99)
> at ParserExt.main(ParserExt.java:24)
>
>
> Is calling Parboiled.createParser(...) the recommended way of creating an extension of pegdown Parser?
> Thanks.
>
>
>
> If you reply to this email, your message will be added to the discussion below:
> http://users.parboiled.org/IllegalAccessError-trying-to-access-pegdown-Parser-from-extension-tp3974776p3975090.html
> To start a new topic under parboiled users, email [hidden email]
> To unsubscribe from parboiled users, click here.
> NAML

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: IllegalAccessError trying to access pegdown Parser from extension

jhinkey
Hi Mathias,

Right. I found that out last night that putting my parser in the same package worked.

Thanks for confirming that.

Best,
Jim
Loading...