@@ -133,6 +133,9 @@ public final class ObjectKlass extends Klass {
133
133
@ CompilationFinal //
134
134
private volatile int initState = LOADED ;
135
135
136
+ @ CompilationFinal //
137
+ private EspressoException linkError ;
138
+
136
139
@ CompilationFinal volatile KlassVersion klassVersion ;
137
140
138
141
// instance and hidden fields declared in this class and in its super classes
@@ -157,7 +160,7 @@ public final class ObjectKlass extends Klass {
157
160
public static final int LOADED = 0 ;
158
161
public static final int LINKING = 1 ;
159
162
public static final int VERIFYING = 2 ;
160
- public static final int FAILED_VERIFICATION = 3 ;
163
+ public static final int FAILED_LINK = 3 ;
161
164
public static final int VERIFIED = 4 ;
162
165
public static final int PREPARED = 5 ;
163
166
public static final int LINKED = 6 ;
@@ -597,7 +600,7 @@ private void checkLoadingConstraints() {
597
600
@ Override
598
601
public void ensureLinked () {
599
602
if (!isLinked ()) {
600
- checkErroneousVerification ();
603
+ checkErroneousLink ();
601
604
if (CompilerDirectives .isCompilationConstant (this )) {
602
605
CompilerDirectives .transferToInterpreterAndInvalidate ();
603
606
}
@@ -611,20 +614,30 @@ private void doLink() {
611
614
try {
612
615
if (!isLinkingOrLinked ()) {
613
616
initState = LINKING ;
614
- if (getSuperKlass () != null ) {
615
- getSuperKlass ().ensureLinked ();
616
- }
617
- for (ObjectKlass interf : getSuperInterfaces ()) {
618
- interf .ensureLinked ();
617
+ try {
618
+ if (getSuperKlass () != null ) {
619
+ getSuperKlass ().ensureLinked ();
620
+ }
621
+ for (ObjectKlass interf : getSuperInterfaces ()) {
622
+ interf .ensureLinked ();
623
+ }
624
+ } catch (EspressoException e ) {
625
+ setErroneousLink (e );
626
+ throw e ;
619
627
}
620
628
verify ();
621
- prepare ();
629
+ try {
630
+ prepare ();
631
+ } catch (EspressoException e ) {
632
+ setErroneousLink (e );
633
+ throw e ;
634
+ }
622
635
initState = LINKED ;
623
636
}
624
637
} finally {
625
638
getInitLock ().unlock ();
626
639
}
627
- checkErroneousVerification ();
640
+ checkErroneousLink ();
628
641
}
629
642
630
643
void initializeImpl () {
@@ -636,7 +649,7 @@ void initializeImpl() {
636
649
637
650
@ HostCompilerDirectives .InliningCutoff
638
651
private void doInitialize () {
639
- checkErroneousVerification ();
652
+ checkErroneousLink ();
640
653
checkErroneousInitialization ();
641
654
if (CompilerDirectives .isCompilationConstant (this )) {
642
655
CompilerDirectives .transferToInterpreterAndInvalidate ();
@@ -660,9 +673,6 @@ private void recursiveInitialize() {
660
673
661
674
// region Verification
662
675
663
- @ CompilationFinal //
664
- private EspressoException verificationError ;
665
-
666
676
private boolean isVerifyingOrVerified () {
667
677
return initState >= VERIFYING ;
668
678
}
@@ -671,20 +681,20 @@ boolean isVerified() {
671
681
return initState >= VERIFIED ;
672
682
}
673
683
674
- private void checkErroneousVerification () {
675
- if (initState == FAILED_VERIFICATION ) {
676
- throw verificationError ;
684
+ private void checkErroneousLink () {
685
+ if (initState == FAILED_LINK ) {
686
+ throw linkError ;
677
687
}
678
688
}
679
689
680
- private void setErroneousVerification (EspressoException e ) {
681
- initState = FAILED_VERIFICATION ;
682
- verificationError = e ;
690
+ private void setErroneousLink (EspressoException e ) {
691
+ initState = FAILED_LINK ;
692
+ linkError = e ;
683
693
}
684
694
685
695
private void verify () {
686
696
if (!isVerified ()) {
687
- checkErroneousVerification ();
697
+ checkErroneousLink ();
688
698
getInitLock ().lock ();
689
699
try {
690
700
if (!isVerifyingOrVerified ()) {
@@ -693,15 +703,15 @@ private void verify() {
693
703
try {
694
704
verifyImpl ();
695
705
} catch (EspressoException e ) {
696
- setErroneousVerification (e );
706
+ setErroneousLink (e );
697
707
throw e ;
698
708
}
699
709
initState = VERIFIED ;
700
710
}
701
711
} finally {
702
712
getInitLock ().unlock ();
703
713
}
704
- checkErroneousVerification ();
714
+ checkErroneousLink ();
705
715
}
706
716
}
707
717
0 commit comments