Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/java/org/perlonjava/core/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public final class Configuration {
* Automatically populated by Gradle/Maven during build.
* DO NOT EDIT MANUALLY - this value is replaced at build time.
*/
public static final String gitCommitId = "217705588";
public static final String gitCommitId = "ad0d59ddc";

/**
* Git commit date of the build (ISO format: YYYY-MM-DD).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.perlonjava.runtime.runtimetypes.*;

import java.lang.invoke.MethodHandle;
import java.net.URL;

/**
* Abstract base class for Perl modules in the Java environment.
Expand Down Expand Up @@ -35,10 +36,26 @@ public PerlModuleBase(String moduleName, boolean setInc) {
/**
* Initializes the Perl module by setting the %INC hash to indicate
* that the module is loaded.
* If a .pm stub file exists in the JAR, use the jar:PERL5LIB path format
* so that code opening %INC entries can find a real file.
*/
private void initializeModule() {
String pmFileName = moduleName.replace("::", "/") + ".pm";
String incValue;

// Check if there's a .pm file in the bundled lib (JAR)
String resourcePath = "/lib/" + pmFileName;
URL resource = PerlModuleBase.class.getResource(resourcePath);
if (resource != null) {
// Use jar:PERL5LIB path format - this can be opened by the runtime
incValue = GlobalContext.JAR_PERLLIB + "/" + pmFileName;
} else {
// No .pm stub file - use simple name (backwards compatible)
incValue = moduleName + ".pm";
}

// Set %INC to indicate the module is loaded
GlobalVariable.getGlobalHash("main::INC").put(moduleName.replace("::", "/") + ".pm", new RuntimeScalar(moduleName + ".pm"));
GlobalVariable.getGlobalHash("main::INC").put(pmFileName, new RuntimeScalar(incValue));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/main/perl/lib/B.pm
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ package B;
use strict;
use warnings;

our $VERSION = '1.00_perlonjava';
our $VERSION = '1.88';

# Export functionality
use Exporter 'import';
Expand Down
62 changes: 62 additions & 0 deletions src/main/perl/lib/Clone.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package Clone;

use strict;
use warnings;

require Exporter;

our @ISA = qw(Exporter);
our @EXPORT;
our @EXPORT_OK = qw( clone );

our $VERSION = '0.49';

# PerlOnJava: Fall back to Clone::PP since we can't load XS
my $loaded = 0;

eval {
require XSLoader;
XSLoader::load('Clone', $VERSION);
$loaded = 1;
};

if (!$loaded) {
# Fall back to pure Perl implementation
require Clone::PP;
*clone = \&Clone::PP::clone;
}

1;
__END__

=head1 NAME

Clone - recursively copy Perl datatypes

=head1 SYNOPSIS

use Clone 'clone';

my $data = {
set => [ 1 .. 50 ],
foo => {
answer => 42,
object => SomeObject->new,
},
};

my $cloned_data = clone($data);

=head1 DESCRIPTION

This module provides a C<clone()> method which makes recursive
copies of nested hash, array, scalar and reference types,
including tied variables and objects.

PerlOnJava uses Clone::PP (pure Perl implementation) as the backend.

=head1 SEE ALSO

L<Clone::PP>, L<Storable>

=cut
6 changes: 3 additions & 3 deletions src/main/perl/lib/ExtUtils/MM_Unix.pm
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ sub get_version {
$line = $1 if $line =~ m{^(.+)}s;

# Directly extract version from common patterns
# Pattern 1: $VERSION = '1.23' or $VERSION = "1.23"
if ($line =~ /\$VERSION\s*=\s*['"]([^'"]+)['"]/) {
# Pattern 1: $VERSION = '1.23' or $Package::VERSION = '1.23'
if ($line =~ /\$[\w:]*VERSION\s*=\s*['"]([^'"]+)['"]/) {
return $1;
}
# Pattern 2: $VERSION = 1.23 (bare number)
if ($line =~ /\$VERSION\s*=\s*([\d._]+)/) {
if ($line =~ /\$[\w:]*VERSION\s*=\s*([\d._]+)/) {
return $1;
}
# Pattern 3: version->new('v1.2.3') or version->declare('v1.2.3')
Expand Down
64 changes: 64 additions & 0 deletions src/main/perl/lib/UNIVERSAL.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package UNIVERSAL;

# Stub for UNIVERSAL module - actual implementation is in Java (Universal.java)
# This file exists so %INC has a real file path that can be opened by tests

use strict;
use warnings;

our $VERSION = '1.17';

# The Java implementation (Universal.java) provides:
# - can($method) - check if object/class can perform method
# - isa($class) - check if object/class is or inherits from class
# - DOES($role) - check if object/class does a role (same as isa)
# - VERSION([$require]) - get/check package version

1;

__END__

=head1 NAME

UNIVERSAL - base class for ALL classes (blessed references)

=head1 SYNOPSIS

$obj->isa('ClassName');
$obj->can('method');
$obj->DOES('RoleName');
$obj->VERSION;

ClassName->isa('ParentClass');
ClassName->can('method');
ClassName->VERSION($required);

=head1 DESCRIPTION

UNIVERSAL is the base class which all blessed references inherit from.
This is the PerlOnJava implementation.

=head1 METHODS

=over 4

=item $obj->isa(TYPE)

Returns true if $obj is blessed into package TYPE or inherits from TYPE.

=item $obj->can(METHOD)

Returns a reference to the method if $obj can perform METHOD, false otherwise.

=item $obj->DOES(ROLE)

Returns true if $obj does the role ROLE. In PerlOnJava, this is equivalent to isa().

=item $obj->VERSION([REQUIRE])

Returns the version of the package $obj is blessed into. If REQUIRE is given,
dies if the version is less than REQUIRE.

=back

=cut
17 changes: 16 additions & 1 deletion src/main/perl/lib/open.pm
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
package open;

# placeholder
# Stub for open pragma - sets default I/O layers
# PerlOnJava implementation by Flavio S. Glock

use strict;
use warnings;

our $VERSION = '1.14';

# The open pragma sets default PerlIO layers for input/output
# In PerlOnJava, UTF-8 is the default encoding

sub import {
my $class = shift;
# For now, accept but ignore layer specifications
# PerlOnJava defaults to UTF-8 encoding
}

1;
38 changes: 38 additions & 0 deletions src/main/perl/lib/re.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package re;

# Stub for re pragma - actual implementation is in Java (Re.java)
# This file exists for version detection by MM->parse_version()

use strict;
use warnings;

our $VERSION = "0.48";

# The Java implementation (Re.java) handles:
# - use re '/a', '/aa', '/u' - regex character class modifiers
# - use re 'strict' - enable experimental regex warnings
# - re::is_regexp($ref) - check if reference is compiled regex

1;

__END__

=head1 NAME

re - Perl pragma to alter regular expression behaviour

=head1 SYNOPSIS

use re '/a'; # ASCII-restrict \w, \d, \s, \b
use re '/aa'; # ASCII-restrict including case folding
use re '/u'; # Unicode semantics
use re 'strict'; # Enable experimental regex warnings

if (re::is_regexp($ref)) { ... }

=head1 DESCRIPTION

This is the PerlOnJava implementation of the C<re> pragma.
See L<perldoc re> for the full Perl documentation.

=cut
Loading