@@ -680,7 +680,7 @@ public LocalDate asDate(@Shared("getClassNode") @Cached GetLazyClassNode getClas
680
680
int year = castToIntNode .execute (lib .readMember (this , "year" ));
681
681
int month = castToIntNode .execute (lib .readMember (this , "month" ));
682
682
int day = castToIntNode .execute (lib .readMember (this , "day" ));
683
- return LocalDate . of (year , month , day );
683
+ return createLocalDate (year , month , day );
684
684
} catch (UnsupportedMessageException | UnknownIdentifierException ex ) {
685
685
throw UnsupportedMessageException .create ();
686
686
}
@@ -693,7 +693,7 @@ public LocalDate asDate(@Shared("getClassNode") @Cached GetLazyClassNode getClas
693
693
int year = castToIntNode .execute (lib .readMember (this , "tm_year" ));
694
694
int month = castToIntNode .execute (lib .readMember (this , "tm_mon" ));
695
695
int day = castToIntNode .execute (lib .readMember (this , "tm_mday" ));
696
- return LocalDate . of (year , month , day );
696
+ return createLocalDate (year , month , day );
697
697
} catch (UnsupportedMessageException | UnknownIdentifierException ex ) {
698
698
throw UnsupportedMessageException .create ();
699
699
}
@@ -739,7 +739,7 @@ public LocalTime asTime(@Shared("getClassNode") @Cached GetLazyClassNode getClas
739
739
int min = castToIntNode .execute (lib .readMember (this , "minute" ));
740
740
int sec = castToIntNode .execute (lib .readMember (this , "second" ));
741
741
int micro = castToIntNode .execute (lib .readMember (this , "microsecond" ));
742
- return LocalTime . of (hour , min , sec , micro );
742
+ return createLocalTime (hour , min , sec , micro );
743
743
} catch (UnsupportedMessageException | UnknownIdentifierException ex ) {
744
744
throw UnsupportedMessageException .create ();
745
745
}
@@ -752,7 +752,7 @@ public LocalTime asTime(@Shared("getClassNode") @Cached GetLazyClassNode getClas
752
752
int hour = castToIntNode .execute (lib .readMember (this , "tm_hour" ));
753
753
int min = castToIntNode .execute (lib .readMember (this , "tm_min" ));
754
754
int sec = castToIntNode .execute (lib .readMember (this , "tm_sec" ));
755
- return LocalTime . of (hour , min , sec );
755
+ return createLocalTime (hour , min , sec , 0 );
756
756
} catch (UnsupportedMessageException | UnknownIdentifierException ex ) {
757
757
throw UnsupportedMessageException .create ();
758
758
}
@@ -834,7 +834,7 @@ public ZoneId asTimeZone(@Shared("getClassNode") @Cached GetLazyClassNode getCla
834
834
Object delta = lib .invokeMember (tzinfo , "utcoffset" , new Object []{this });
835
835
if (delta != PNone .NONE ) {
836
836
int seconds = castToIntNode .execute (lib .readMember (delta , "seconds" ));
837
- return ZoneId . ofOffset ( "UTC" , ZoneOffset . ofTotalSeconds ( seconds ) );
837
+ return createZoneId ( seconds );
838
838
}
839
839
}
840
840
} catch (UnsupportedMessageException | UnknownIdentifierException | ArityException | UnsupportedTypeException ex ) {
@@ -847,7 +847,7 @@ public ZoneId asTimeZone(@Shared("getClassNode") @Cached GetLazyClassNode getCla
847
847
Object delta = lib .invokeMember (tzinfo , "utcoffset" , new Object []{PNone .NONE });
848
848
if (delta != PNone .NONE ) {
849
849
int seconds = castToIntNode .execute (lib .readMember (delta , "seconds" ));
850
- return ZoneId . ofOffset ( "UTC" , ZoneOffset . ofTotalSeconds ( seconds ) );
850
+ return createZoneId ( seconds );
851
851
}
852
852
}
853
853
} catch (UnsupportedMessageException | UnknownIdentifierException | ArityException | UnsupportedTypeException ex ) {
@@ -864,10 +864,10 @@ public ZoneId asTimeZone(@Shared("getClassNode") @Cached GetLazyClassNode getCla
864
864
Object tm_gmtoffset = lib .readMember (this , "tm_gmtoff" );
865
865
if (tm_gmtoffset != PNone .NONE ) {
866
866
int seconds = castToIntNode .execute (tm_gmtoffset );
867
- return ZoneId . ofOffset ( "UTC" , ZoneOffset . ofTotalSeconds ( seconds ) );
867
+ return createZoneId ( seconds );
868
868
}
869
869
if (tm_zone instanceof String ) {
870
- return ZoneId . of ((String ) tm_zone );
870
+ return createZoneId ((String ) tm_zone );
871
871
}
872
872
}
873
873
} catch (UnsupportedMessageException | UnknownIdentifierException ex ) {
@@ -878,6 +878,26 @@ public ZoneId asTimeZone(@Shared("getClassNode") @Cached GetLazyClassNode getCla
878
878
throw UnsupportedMessageException .create ();
879
879
}
880
880
881
+ @ TruffleBoundary
882
+ private ZoneId createZoneId (int utcDeltaInSeconds ) {
883
+ return ZoneId .ofOffset ("UTC" , ZoneOffset .ofTotalSeconds (utcDeltaInSeconds ));
884
+ }
885
+
886
+ @ TruffleBoundary
887
+ private ZoneId createZoneId (String zone ) {
888
+ return ZoneId .of (zone );
889
+ }
890
+
891
+ @ TruffleBoundary
892
+ private LocalTime createLocalTime (int hour , int min , int sec , int micro ) {
893
+ return LocalTime .of (hour , min , sec , micro );
894
+ }
895
+
896
+ @ TruffleBoundary
897
+ private LocalDate createLocalDate (int year , int month , int day ) {
898
+ return LocalDate .of (year , month , day );
899
+ }
900
+
881
901
@ GenerateUncached
882
902
public abstract static class PKeyInfoNode extends Node {
883
903
private static final int NONE = 0 ;
0 commit comments