Skip to content

Instantly share code, notes, and snippets.

@peschwa
Last active August 29, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peschwa/e5aee72dcce9d4b60ec1 to your computer and use it in GitHub Desktop.
Save peschwa/e5aee72dcce9d4b60ec1 to your computer and use it in GitHub Desktop.
$ ls
Foo Foo.jar Foo.pm
$ cat Foo.pm
class Foo;
need Foo::Bar;
method baz(Str $in) {
Foo::Bar::doLookup($in);
}
$ cat Foo/Bar.pm
use v6;
package Foo::Bar {
my %lookup = (
"a" => 1,
"b" => 2,
"c" => 3,
);
our sub doLookup(Str $in) {
return %lookup{$in}.Int // Int;
}
}
$ perl6-j --target=jar --output=Foo/Bar.jar Foo/Bar.pm
$ perl6-j -I. --target=jar --output=Foo.jar Foo.pm
$ perl6-j -I. -MFoo -e'my $foo = Foo.new; say $foo.baz("a")'
java.lang.NullPointerException
in sub doLookup at Foo/Bar.pm:10
in method baz at Foo.pm:5
in block at -e:1
$
main[1] list
191 SixModelObject invokee = Ops.getlex(name, tc);
192
193 /* Don't update callsite in cases where it's not safe. */
194 boolean shared = tc.curFrame.codeRef.staticInfo.compUnit.shared;
195 => if (invokee.st != null && invokee.st.ContainerSpec != null) {
196 invokee = Ops.decont(invokee, tc);
197 shared = true;
198 }
199
200 /* Resolve callsite descriptor. */
main[1] dump tc.curFrame.codeRef.staticInfo.oLexicalNames
tc.curFrame.codeRef.staticInfo.oLexicalNames = {
"$!", "$/", "$_", "$in", "$*DISPATCHER", "&?ROUTINE", "RETURN"
}
main[1] dump tc.curFrame.outer.codeRef.staticInfo.oLexicalNames
tc.curFrame.outer.codeRef.staticInfo.oLexicalNames = {
"%lookup", "$?PACKAGE", "::?PACKAGE", "$_", "&doLookup"
}
main[1] dump tc.curFrame.outer.outer.codeRef.staticInfo.oLexicalNames
tc.curFrame.outer.outer.codeRef.staticInfo.oLexicalNames = {
"$!", "$/", "$_", "GLOBALish", "EXPORT", "$?PACKAGE", "::?PACKAGE", "Foo", "$=pod", "!UNIT_MARKER"
}
main[1] dump tc.curFrame.outer.outer.outer.codeRef.staticInfo.oLexicalNames
com.sun.tools.example.debug.expr.ParseException: Cannot access field of primitive type: null
tc.curFrame.outer.outer.outer.codeRef.staticInfo.oLexicalNames = null
main[1]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment