line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package PJVM::ClassLoader; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
110999
|
use strict; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
129
|
|
4
|
3
|
|
|
3
|
|
17
|
use warnings; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
91
|
|
5
|
|
|
|
|
|
|
|
6
|
3
|
|
|
3
|
|
19
|
use File::Spec; |
|
3
|
|
|
|
|
11
|
|
|
3
|
|
|
|
|
92
|
|
7
|
3
|
|
|
3
|
|
5900
|
use File::Slurp qw(slurp); |
|
3
|
|
|
|
|
62455
|
|
|
3
|
|
|
|
|
294
|
|
8
|
|
|
|
|
|
|
|
9
|
3
|
|
|
3
|
|
4156
|
use IO::Scalar; |
|
3
|
|
|
|
|
78056
|
|
|
3
|
|
|
|
|
143
|
|
10
|
|
|
|
|
|
|
|
11
|
3
|
|
|
3
|
|
1658
|
use PJVM::Class; |
|
3
|
|
|
|
|
13
|
|
|
3
|
|
|
|
|
31
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
14
|
|
|
|
|
|
|
|
15
|
3
|
|
|
|
|
75
|
use Object::Tiny qw( |
16
|
|
|
|
|
|
|
classpath |
17
|
3
|
|
|
3
|
|
283
|
); |
|
3
|
|
|
|
|
8
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub new { |
20
|
4
|
|
|
4
|
0
|
556
|
my ($pkg, $args) = @_; |
21
|
|
|
|
|
|
|
|
22
|
4
|
50
|
|
|
|
19
|
$args = {} unless ref $args eq "HASH"; |
23
|
|
|
|
|
|
|
|
24
|
4
|
|
|
|
|
22
|
my $classpath; |
25
|
4
|
50
|
|
|
|
17
|
if ($args->{classpath}) { |
26
|
4
|
100
|
|
|
|
36
|
die "argument 'classpath' must be an array reference" unless ref $args->{classpath} eq "ARRAY"; |
27
|
3
|
|
|
|
|
7
|
$classpath = $args->{classpath}; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
3
|
|
|
|
|
14
|
my $self = bless { |
31
|
|
|
|
|
|
|
classpath => $classpath, |
32
|
|
|
|
|
|
|
}, $pkg; |
33
|
|
|
|
|
|
|
|
34
|
3
|
|
|
|
|
10
|
return $self; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub load_class { |
38
|
4
|
|
|
4
|
0
|
2133
|
my ($self, $fqcn) = @_; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# Find the class to load |
41
|
4
|
|
|
|
|
8
|
my $path; |
42
|
4
|
|
|
|
|
8
|
for my $cp (@{$self->classpath}) { |
|
4
|
|
|
|
|
131
|
|
43
|
4
|
|
|
|
|
132
|
my $pt = File::Spec->catfile($cp, "${fqcn}.class"); |
44
|
4
|
100
|
|
|
|
101
|
if (-e $pt) { |
45
|
3
|
|
|
|
|
9
|
$path = $pt; |
46
|
3
|
|
|
|
|
8
|
last; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
4
|
100
|
|
|
|
26
|
die "Can't find '${fqcn}.class' in my classpath" unless $path; |
51
|
|
|
|
|
|
|
|
52
|
3
|
50
|
|
|
|
223
|
open(my $io, "<:raw", $path) || die $!; |
53
|
3
|
|
|
|
|
15
|
my $class = $self->read_class($io); |
54
|
3
|
|
|
|
|
40
|
close($io); |
55
|
|
|
|
|
|
|
|
56
|
3
|
|
|
|
|
25
|
return $class; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub read_class { |
60
|
3
|
|
|
3
|
0
|
8
|
my ($self, $io) = @_; |
61
|
3
|
|
|
|
|
29
|
return PJVM::Class->new_from_io($io); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
1; |
65
|
|
|
|
|
|
|
__END__ |