Giter Site home page Giter Site logo

Lost Java types about perlito HOT 5 CLOSED

fglock avatar fglock commented on August 18, 2024
Lost Java types

from perlito.

Comments (5)

fglock avatar fglock commented on August 18, 2024

The extension syntax
package Java::Object { import => 'java.lang.Object' };
is currently only supported in pre-compilation mode (that is, using -Cjava).

This is in the documentation (although it could be more clear):
Java extensions are disabled inside eval-string (only plain-perl)

The direction of development for Java extensions is not clear yet.

The current plan is to do something closer to the Nashorn API,
https://docs.oracle.com/javase/8/docs/technotes/guides/scripting/prog_guide/javascript.html#A1147187
but something like JRuby is also possible, https://github.com/jruby/jruby/wiki/CallingJavaFromJRuby
or Jython, http://www.jython.org/jythonbook/en/1.0/JythonAndJavaIntegration.html

Alternately, it would also be possible to make the current extension syntax "official" and go ahead with the integration in eval-string

from perlito.

dionys avatar dionys commented on August 18, 2024

The JRuby/Jython way looks good:

use java::lang::Object;

but there are many pitfalls in the implementation (namespace conflicts, etc.).

You also may using Perl-ish way, like use if pragma, e.g.:

use java 'java::lang::Object', as => 'Object';

from perlito.

fglock avatar fglock commented on August 18, 2024

I've added some more support for Java objects in the eval-string runtime,
https://github.com/fglock/Perlito/blob/master/README-perlito5-Java.md#java-fields-methods-and-constructors
It is work-in-progress, there is no "new syntax" yet (the examples are using Java::inline).

I think since the runtime supports the basic operations, we can experiment with several variants of the syntax.

from perlito.

fglock avatar fglock commented on August 18, 2024

There are some new features available:
https://github.com/fglock/Perlito/blob/master/README-perlito5-Java.md#java-perl-module

Java is a Perl module: src5/lib/Perlito5X/Java/Java.pm

from perlito.

fglock avatar fglock commented on August 18, 2024

Typed variables now work in eval-string:

$ jrunscript -cp . -l Perl5
perl> package Java::Object { import => 'java.lang.Object' };
import
perl> my Java::Object $obj = Java::Object->new();
Object(0x4b44655e)

Note that some restrictions apply - https://github.com/fglock/Perlito/blob/master/README-perlito5-Java.md#using-typed-variables

from perlito.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.