PJVM/Runtime/Native/java/lang/Object.pm untested

filter: Statementstmt 0.0% 0 / 33 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 13 Podpod 0.0% 0 / 7 totaltotal 0.0% 0 / 53 CC 1 SCAR 6.9
CC
1
Cov
0%
new
2.0
j_new
2.0
j_clone
2.0
CRAP 2.0
1 package PJVM::Runtime::Native::java::lang::Object;
2  
3 use strict;
4 use warnings;
5  
6 use Scalar::Util qw(refaddr);
7  
8 use PJVM::Access qw(:flags);
9 use PJVM::Runtime qw(:stack);
10 use PJVM::Runtime::Class;
11  
12 sub new {
13 my $class = PJVM::Runtime::Class->new(
14 qname => "java/lang/Object",
15 methods => {
16 # Constructor
17 "#()V" => \&j_new,
18  
19 # protected Object clone()
20 "clone#()Ljava/lang/Object;" => \&j_clone,
21
22 # boolean equals(Object)
23 "equals#(Ljava/lang/Object;)Z" => \&j_equals,
24
25 # protected void finalize()
26 "finalize#()V" => \&j_finalize,
27
28 # Class getClass()
29 "getClass#()Ljava/lang/Class;" => \&j_get_class,
30
31 # int hashCode()
32 "hashCode#()I" => \&j_hash_code,
33
34 },
35 methods_access => {
36 "#()V" => ACC_PUBLIC,
37 "clone#()Ljava/lang/Object;" => ACC_PROTECTED,
38 "equals#(Ljava/lang/Object;)Z" => ACC_PUBLIC,
39 "finalize#()V" => ACC_PROTECTED,
40 "getClass#()Ljava/lang/Class;" => ACC_PUBLIC,
41 },
42 );
43
44 return $class;
45 }
46  
47 sub j_new {
48 }
49  
50 # Methods bound to Java space, refere to $self as $this to follow Java conventions
51 sub j_clone {
52 my $this = rt_pop_stack;
53 # TODO: check interface and throw java/lang/CloneNotSupportedException if
54 # not class does not implement java/lang/Cloneable
55  
56 # Performs a shallow clone
57 my $clone = $this->clone();
58  
59 rt_push_stack $clone;
60
61 1;
62 }
63  
64 sub j_equals {
65 my $this = rt_pop_stack;
66 my $that = rt_pop_stack;
67
68 rt_push_stack refaddr $this == refaddr $that;
69 }
70  
71 sub j_finalize {
72 }
73  
74 sub j_get_class {
75 my $this = rt_pop_stack;
76 rt_push_stack $this->class();
77 }
78  
79 sub j_hash_code {
80 my $this = rt_pop_stack;
81 rt_push_stack refaddr $this;
82 }
83  
84 1;
85 __END__