Discussion:
Inline::Java and DIRECTORY config option
Sisyphus
2012-05-15 08:39:29 UTC
Permalink
Hi all,
There's a thread on perlmonks
( http://www.perlmonks.org/index.pl?node_id=970385 ) in which it's claimed
that the following code silently ignores the DIRECTORY specification, and
(creates and) uses the ./_Inline directory:

#################################
use warnings;
use Inline Java => "STUDY",
STUDY => [],
AUTOSTUDY => 1,
STARTUP_DELAY => 40,
PORT => 14567,
JNI => 1,
EXTRA_JAVA_ARGS => '-Xmx800m',
DIRECTORY => "/u/narlab/InlineLib/";

use Inline::Java qw(study_classes
cast
caught);

use Inline Java => <<'EOJ';

public class Test {
public static void init() {
System.out.println("test");
}
}
EOJ

my $t = Test->new();
$t->init();

#################################

I assume the claim is correct (I have no reason to doubt it), but I can't
actually verify it for myself as I no longer have a working Inline::Java
installation.

Is it right that DIRECTORY gets silently ignored like that ?
If that's a misuse of the DIRECTORY option, should there at least be a
warning ? (My immediate thoughts are that it should be a fatal error if
DIRECTORY is being misused.)

I'm assuming that this is the sole responsibility of Inline::Java, but
please let me know if Inline itself is in some way at fault, or could do
something that would improve the situation.

Cheers,
Rob
David Oswald
2012-05-15 10:47:29 UTC
Permalink
Hi  all,
There's a thread on perlmonks
( http://www.perlmonks.org/index.pl?node_id=970385 ) in which it's claimed
that the following code silently ignores the DIRECTORY specification, and
#################################
use warnings;
use Inline Java => "STUDY",
         STUDY => [],
         AUTOSTUDY => 1,
         STARTUP_DELAY => 40,
         PORT => 14567,
         JNI => 1,
         EXTRA_JAVA_ARGS => '-Xmx800m',
         DIRECTORY => "/u/narlab/InlineLib/";
I saw that thread and was sort of interested in seeing how it turned
out. I figured it might make its way back to this list.

One thought: Shouldn't it be:

Config => DIRECTORY => "u/narlab/InlineLib";

I mean I don't see where the code specifies this is a config option,
but maybe that's not necessary.

Inline::CPP handles all of the configuration directives it feels it
needs to, and propagates back to Inline::C those it feels it doesn't
need to handle differently from Inline::C. Here is how that's done:

# Filter out the parameters we treat differently than Inline::C,
# forwarding unknown requests back up to Inline::C.
my @propagate = _handle_config_options( $o, @config_options );
$o->SUPER::validate(@propagate) if @propagate;

I understand Inline::Java is a different beast, and can't reasonably
assume that configuration options that it doesn't handle could be
handled by a super-class. I see that in Inline::Java's 'validate'
function it specifically enumerates those options it understands.
DIRECTORY isn't one of them. Its code is supposed to croak if it
finds a parameter that it doesn't specifically enumerate.

It would be interesting to run that snippet you posted with the DEBUG
mode of Inline::Java set, and watch the output. It might be that
'validate' isn't seeing DIRECTORIES the way it's being set in the
snippet you provided.

I'm away from my development systems today, and don't have
Inline::Java installed anyway (and if I did, wouldn't know what to do
with it since I don't know the first thing about Java). But perhaps
someone who is qualified could test that snippet under DEBUG mode, and
try to trace out whether validate() is even seeing DIRECTORY.
--
David Oswald
daoswald-***@public.gmane.org
Sisyphus
2012-05-16 05:56:07 UTC
Permalink
----- Original Message -----
From: "David Oswald" <daoswald-***@public.gmane.org>
To: "Sisyphus" <sisyphus1-sFbbPxZDHXw0n/***@public.gmane.org>
Cc: "inline" <inline-***@public.gmane.org>
Sent: Tuesday, May 15, 2012 8:47 PM
Subject: Re: Inline::Java and DIRECTORY config option
Post by David Oswald
Hi all,
There's a thread on perlmonks
( http://www.perlmonks.org/index.pl?node_id=970385 ) in which it's claimed
that the following code silently ignores the DIRECTORY specification, and
#################################
use warnings;
use Inline Java => "STUDY",
STUDY => [],
AUTOSTUDY => 1,
STARTUP_DELAY => 40,
PORT => 14567,
JNI => 1,
EXTRA_JAVA_ARGS => '-Xmx800m',
DIRECTORY => "/u/narlab/InlineLib/";
I saw that thread and was sort of interested in seeing how it turned
out. I figured it might make its way back to this list.
Config => DIRECTORY => "u/narlab/InlineLib";
Somewhere in that perlmonks thread I suggested doing that, and the op
confirmed that works.

But it's the absence of warning (or croaking) in the above version of his
script that has me wondering.

I would think that Patrick might want to do something about that - and I
think it should be addressable without having Inline do anything
differently.

That is, I think this is entirely an Inline::Java issue - but if I'm wrong
about that and Inline *does* need to do something differently, then it's
probably better that I know about it :-)

Cheers,
Rob
Patrick LeBoutillier
2012-05-17 22:19:34 UTC
Permalink
Hi all,
Hi  all,
There's a thread on perlmonks
( http://www.perlmonks.org/index.pl?node_id=970385 ) in which it's claimed
that the following code silently ignores the DIRECTORY specification, and
#################################
use warnings;
use Inline Java => "STUDY",
         STUDY => [],
         AUTOSTUDY => 1,
         STARTUP_DELAY => 40,
         PORT => 14567,
         JNI => 1,
         EXTRA_JAVA_ARGS => '-Xmx800m',
         DIRECTORY => "/u/narlab/InlineLib/";
use Inline::Java qw(study_classes
                  cast
                  caught);
use Inline Java =>  <<'EOJ';
public class Test {
   public static void init() {
      System.out.println("test");
  }
}
EOJ
  my $t = Test->new();
  $t->init();
#################################
I assume the claim is correct (I have no reason to doubt it), but I can't
actually verify it for myself as I no longer have a working Inline::Java
installation.
Actually that's not exactly correct: in fact both folders are used. In
this script Inline::Java
is "use"d 3 times. The DIRECTORY is only specified at one place, so
only that instance
uses the specified DIRECTORY. Just because the first usage doesn't
actually have code
specified doesn't mean there's not some being generated behind the scenes...


If you set

use Inline Java => Config => DIRECTORY => '/home/me/here';

at the top of the script, Inline applies it to all instances.


I think this behavior is normal and I think other Inline::* modules
will behave like this
as well if you specify multiple "use"s. Can anyone confirm/deny this?


Patrick
Is it right that DIRECTORY gets silently ignored like that ?
If that's a misuse of the DIRECTORY option, should there at least be a
warning ? (My immediate thoughts are that it should be a fatal error if
DIRECTORY is being misused.)
I'm assuming that this is the sole responsibility of Inline::Java, but
please let me know if Inline itself is in some way at fault, or could do
something that would improve the situation.
Cheers,
Rob
--
=====================
Patrick LeBoutillier
Rosemère, Québec, Canada
Loading...