java.lang.NoSuchFieldError: field$1

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

java.lang.NoSuchFieldError: field$1

vadim
Hi, Mathias.
When I run the following code with 1.0.1 libraries:
import org.parboiled.BaseParser;
import org.parboiled.Parboiled;
import org.parboiled.Rule;
import org.parboiled.parserunners.ReportingParseRunner;
import org.parboiled.support.ParsingResult;


public class TestParser extends BaseParser<Object> {

    static class A {}

    public Rule InputLine() {
        return Sequence(RuleA(), EOI);
    }

    public Rule RuleA() {
        A va = new A();
        return Sequence(RuleB(), push(va));
    }

    protected Rule RuleB() {
        String vb = "b";
        return Sequence("b", push(vb), pop() != null);
    }

    public static A parse(String s) {
        ParsingResult<?> parseResult = new ReportingParseRunner<Object>(Parboiled.createParser(TestParser.class).InputLine()).run(s);
        return (A)parseResult.resultValue;
    }

    public static void main(String[] args) {
        System.out.println(TestParser.parse("b"));
    }
}
I get
Exception in thread "main" java.lang.NoSuchFieldError: field$1
	at ru.yandex.money.oauth.scope.TestParser$$parboiled.RuleB(Unknown Source)
	at ru.yandex.money.oauth.scope.TestParser$$parboiled.RuleA(Unknown Source)
	at ru.yandex.money.oauth.scope.TestParser.InputLine(TestParser.java:15)
	at ru.yandex.money.oauth.scope.TestParser$$parboiled.InputLine(Unknown Source)
	at ru.yandex.money.oauth.scope.TestParser.parse(TestParser.java:29)
	at ru.yandex.money.oauth.scope.TestParser.main(TestParser.java:34)

Questions:
1. Is the code wrong (not counting that it is not optimal)?
2. How to fix the problem and how to generally avoid it?

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

Re: java.lang.NoSuchFieldError: field$1

vadim
environment

asm-3.3.1.jar
asm-analysis-3.3.1.jar
asm-tree-3.3.1.jar

parboiled-core-1.0.1.jar
parboiled-java-1.0.1.jar

jdk1.6.0_21
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: java.lang.NoSuchFieldError: field$1

mathias
Administrator
I can reproduce the problem and will look into this.
I've created a GH issue for this (https://github.com/sirthias/parboiled/issues/30).
It looks like its a problem with the lifting of local variables into action class fields.

As a work around don't use local variables in your actions, rather move all object creation into the action itself (which, in most cases, is actually what you really want to do anyway) or up to the parser level.

Cheers,
Mathias

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

On 23.07.2011, at 19:48, vadim [via parboiled users] wrote:

> environment
>
> asm-3.3.1.jar
> asm-analysis-3.3.1.jar
> asm-tree-3.3.1.jar
>
> parboiled-core-1.0.1.jar
> parboiled-java-1.0.1.jar
>
> jdk1.6.0_21
>
> If you reply to this email, your message will be added to the discussion below:
> http://users.parboiled.org/java-lang-NoSuchFieldError-field-1-tp3193644p3193911.html
> To start a new topic under parboiled users, email [hidden email]
> To unsubscribe from parboiled users, click here.

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

Re: java.lang.NoSuchFieldError: field$1

vadim
thanks for prompt reply. I've tried the Var<Integer> action variable example (https://github.com/sirthias/parboiled/wiki/Action-Variables) and it do work fine.
It may be better to throw parser compilation exception in case of rule local variables presence, because they do not lead to parse time errors generally, but only in some cases, which may be confusing.

Vadim.

On Sun, Jul 24, 2011 at 2:35 AM, mathias [via parboiled users] <[hidden email]> wrote:
I can reproduce the problem and will look into this.
I've created a GH issue for this (https://github.com/sirthias/parboiled/issues/30).
It looks like its a problem with the lifting of local variables into action class fields.

As a work around don't use local variables in your actions, rather move all object creation into the action itself (which, in most cases, is actually what you really want to do anyway) or up to the parser level.

Cheers,
Mathias

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


On 23.07.2011, at 19:48, vadim [via parboiled users] wrote:

> environment
>
> asm-3.3.1.jar
> asm-analysis-3.3.1.jar
> asm-tree-3.3.1.jar
>
> parboiled-core-1.0.1.jar
> parboiled-java-1.0.1.jar
>
> jdk1.6.0_21
>
> If you reply to this email, your message will be added to the discussion below:
> http://users.parboiled.org/java-lang-NoSuchFieldError-field-1-tp3193644p3193911.html
> To start a new topic under parboiled users, email [hidden email]
> To unsubscribe from parboiled users, click here.




If you reply to this email, your message will be added to the discussion below:
http://users.parboiled.org/java-lang-NoSuchFieldError-field-1-tp3193644p3194357.html
To unsubscribe from java.lang.NoSuchFieldError: field$1, click here.

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

Re: java.lang.NoSuchFieldError: field$1

mathias
Administrator
> It may be better to throw parser compilation exception in case of rule local variables presence,

Actually they should just work, and not throw any exceptions!
The the error you were seeing is a bug I'll have to fix and not intended behavior...

Cheers,
Mathias

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

On 24.07.2011, at 13:11, vadim [via parboiled users] wrote:

> thanks for prompt reply. I've tried the Var<Integer> action variable example (https://github.com/sirthias/parboiled/wiki/Action-Variables) and it do work fine.
> It may be better to throw parser compilation exception in case of rule local variables presence, because they do not lead to parse time errors generally, but only in some cases, which may be confusing.
>
> Vadim.
>
> On Sun, Jul 24, 2011 at 2:35 AM, mathias [via parboiled users] <[hidden email]> wrote:
> I can reproduce the problem and will look into this.
> I've created a GH issue for this (https://github.com/sirthias/parboiled/issues/30).
> It looks like its a problem with the lifting of local variables into action class fields.
>
> As a work around don't use local variables in your actions, rather move all object creation into the action itself (which, in most cases, is actually what you really want to do anyway) or up to the parser level.
>
> Cheers,
> Mathias
>
> ---
> [hidden email]
> http://www.parboiled.org
>
>
> On 23.07.2011, at 19:48, vadim [via parboiled users] wrote:
>
> > environment
> >
> > asm-3.3.1.jar
> > asm-analysis-3.3.1.jar
> > asm-tree-3.3.1.jar
> >
> > parboiled-core-1.0.1.jar
> > parboiled-java-1.0.1.jar
> >
> > jdk1.6.0_21
> >
> > If you reply to this email, your message will be added to the discussion below:
> > http://users.parboiled.org/java-lang-NoSuchFieldError-field-1-tp3193644p3193911.html
> > To start a new topic under parboiled users, email [hidden email]
> > To unsubscribe from parboiled users, click here.
>
>
>
> If you reply to this email, your message will be added to the discussion below:
> http://users.parboiled.org/java-lang-NoSuchFieldError-field-1-tp3193644p3194357.html
> To unsubscribe from java.lang.NoSuchFieldError: field$1, click here.
>
>
>
> If you reply to this email, your message will be added to the discussion below:
> http://users.parboiled.org/java-lang-NoSuchFieldError-field-1-tp3193644p3195033.html
> To start a new topic under parboiled users, email [hidden email]
> To unsubscribe from parboiled users, click here.

Loading...