fglock / Perlito

"Perlito" Perl programming language compiler
http://fglock.github.io/Perlito/
Other
414 stars 47 forks source link

Package org.perlito.Perlito5 does not exist with jrunscript #50

Closed dionys closed 6 years ago

dionys commented 6 years ago

When I try to run on last master:

jrunscript -cp .:perlito.jar -l Perl5 -e 'print 1'

I receive the following error message:

/PlEval0.java:1: error: package org.perlito.Perlito5 does not exist
import org.perlito.Perlito5.*;
^
/PlEval0.java:6: error: cannot find symbol
    public static PlObject runEval(int want, Object scalar_val, Object array_val, Object hash_val, PlArray List__) {
                                                                                                   ^
  symbol:   class PlArray
  location: class PlEval0
/PlEval0.java:6: error: cannot find symbol
    public static PlObject runEval(int want, Object scalar_val, Object array_val, Object hash_val, PlArray List__) {
                  ^
  symbol:   class PlObject
  location: class PlEval0
/PlEval0.java:9: error: cannot find symbol
            PlObject ret = new PlClosure(PlCx.UNDEF, new PlObject[]{  }, "main", true) {
            ^
  symbol:   class PlObject
  location: class PlEval0
/PlEval0.java:20: error: cannot find symbol
            }.apply(want, new PlArray());
                              ^
  symbol:   class PlArray
  location: class PlEval0
/PlEval0.java:9: error: cannot find symbol
            PlObject ret = new PlClosure(PlCx.UNDEF, new PlObject[]{  }, "main", true) {
                               ^
  symbol:   class PlClosure
  location: class PlEval0
/PlEval0.java:9: error: cannot find symbol
            PlObject ret = new PlClosure(PlCx.UNDEF, new PlObject[]{  }, "main", true) {
                                         ^
  symbol:   variable PlCx
  location: class PlEval0
/PlEval0.java:9: error: cannot find symbol
            PlObject ret = new PlClosure(PlCx.UNDEF, new PlObject[]{  }, "main", true) {
                                                         ^
  symbol:   class PlObject
  location: class PlEval0
/PlEval0.java:21: error: cannot find symbol
            PlV.sset("main::@", PlCx.EMPTY);
                                ^
  symbol:   variable PlCx
  location: class PlEval0
/PlEval0.java:21: error: cannot find symbol
            PlV.sset("main::@", PlCx.EMPTY);
            ^
  symbol:   variable PlV
  location: class PlEval0
/PlEval0.java:24: error: cannot find symbol
        catch(PlReturnException e) {
              ^
  symbol:   class PlReturnException
  location: class PlEval0
/PlEval0.java:25: error: cannot find symbol
            PlV.sset("main::@", PlCx.EMPTY);
                                ^
  symbol:   variable PlCx
  location: class PlEval0
/PlEval0.java:25: error: cannot find symbol
            PlV.sset("main::@", PlCx.EMPTY);
            ^
  symbol:   variable PlV
  location: class PlEval0
/PlEval0.java:28: error: cannot find symbol
        catch(PlNextException e) {
              ^
  symbol:   class PlNextException
  location: class PlEval0
/PlEval0.java:29: error: cannot find symbol
            PlV.sset("main::@", PlCx.EMPTY);
                                ^
  symbol:   variable PlCx
  location: class PlEval0
/PlEval0.java:29: error: cannot find symbol
            PlV.sset("main::@", PlCx.EMPTY);
            ^
  symbol:   variable PlV
  location: class PlEval0
/PlEval0.java:32: error: cannot find symbol
        catch(PlLastException e) {
              ^
  symbol:   class PlLastException
  location: class PlEval0
/PlEval0.java:33: error: cannot find symbol
            PlV.sset("main::@", PlCx.EMPTY);
                                ^
  symbol:   variable PlCx
  location: class PlEval0
/PlEval0.java:33: error: cannot find symbol
            PlV.sset("main::@", PlCx.EMPTY);
            ^
  symbol:   variable PlV
  location: class PlEval0
/PlEval0.java:36: error: cannot find symbol
        catch(PlRedoException e) {
              ^
  symbol:   class PlRedoException
  location: class PlEval0
/PlEval0.java:37: error: cannot find symbol
            PlV.sset("main::@", PlCx.EMPTY);
                                ^
  symbol:   variable PlCx
  location: class PlEval0
/PlEval0.java:37: error: cannot find symbol
            PlV.sset("main::@", PlCx.EMPTY);
            ^
  symbol:   variable PlV
  location: class PlEval0
/PlEval0.java:42: error: cannot find symbol
            PlV.sset("main::@", new PlString("" + message));
                                    ^
  symbol:   class PlString
  location: class PlEval0
/PlEval0.java:42: error: cannot find symbol
            PlV.sset("main::@", new PlString("" + message));
            ^
  symbol:   variable PlV
  location: class PlEval0
/PlEval0.java:43: error: cannot find symbol
            return PerlOp.context(want);
                   ^
  symbol:   variable PerlOp
  location: class PlEval0
25 errors
script error: Unknown error during compilation.

Running make test-5jar is ok. Runing java -jar perlito5.jar -I src5/lib -e 'print 1' is ok. Only jrunscript throws the error.

fglock commented 6 years ago

Note that

jrunscript -cp .:perlito.jar -l Perl5 -e 'print 1'

should be:

jrunscript -cp .:perlito5.jar -l Perl5 -e 'print 1'

but that doesn't explain the problem, because even this works here:

jrunscript -cp . -l Perl5 -e 'print 1'

The error may be related to the problem fixed in commit 066f25cfa12bde0543615f6a23126f0093726d0a from about 2 weeks ago:

classLoader = new DynamicClassLoader( new PlArray().getClass().getClassLoader() );

This patch makes sure that eval runs in the same ClassLoader context as the Perl runtime (PlArray comes from the Perl runtime).

I can't reproduce the bug here.

Would you try the sequence below, hopefully it will give us some hints on how to reproduce the problem:

git reset --hard
git pull
make clean
make
jrunscript -cp .:perlito5.jar -l Perl5 -e 'print "1\n" '
java -version
git show --oneline -s
dionys commented 6 years ago

Yes, it's typo. I ran:

jrunscript -cp .:perlito5.jar -l Perl5 -e 'print 1'

The error is not solved after all your commands are executed.

> java -version
openjdk version "1.8.0_151"
OpenJDK Runtime Environment (build 1.8.0_151-8u151-b12-0ubuntu0.16.04.2-b12)
OpenJDK 64-Bit Server VM (build 25.151-b12, mixed mode)

> git show --oneline -s
5822b31 Perlito5 - java - Java API wip
fglock commented 6 years ago

I can reproduce with Java 8:

$ java -version
java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)

The error goes away with Java 9:

$ java -version
java version "9.0.1"
Java(TM) SE Runtime Environment (build 9.0.1+11)
Java HotSpot(TM) 64-Bit Server VM (build 9.0.1+11, mixed mode)
fglock commented 6 years ago

73ade0c seems to fix it, tested in Oracle Java "1.8.0_131" and "9.0.1"

dionys commented 6 years ago

It works. Thanks!