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
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ public final class AccessAdvisor {
internalCallerFilter.addOrGetChildren("sun.util.**", ConfigurationFilter.Inclusion.Exclude);
// Bundles calls Bundles.of
internalCallerFilter.addOrGetChildren("sun.util.resources.Bundles", ConfigurationFilter.Inclusion.Include);
// Class.forName calls in CalendarSystem.forName
internalCallerFilter.addOrGetChildren("sun.util.calendar.CalendarSystem", ConfigurationFilter.Inclusion.Include);

excludeInaccessiblePackages(internalCallerFilter);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright (c) 2025, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.oracle.svm.core.jdk;

import java.util.GregorianCalendar;

import org.graalvm.nativeimage.hosted.RuntimeReflection;

import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature;
import com.oracle.svm.core.feature.InternalFeature;

import sun.util.calendar.JulianCalendar;

@AutomaticallyRegisteredFeature
public class CalendarFeature implements InternalFeature {
@Override
public void beforeAnalysis(BeforeAnalysisAccess access) {
// GregorianCalendar might use JulianCalendar via reflection
access.registerReachabilityHandler(a -> {
RuntimeReflection.register(JulianCalendar.class);
RuntimeReflection.registerForReflectiveInstantiation(JulianCalendar.class);
}, GregorianCalendar.class);
}
}
1 change: 1 addition & 0 deletions web-image/mx.web-image/suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
"java.base": [
"sun.nio.ch",
"sun.security.provider",
"sun.util.calendar",
"jdk.internal.misc",
"jdk.internal.util",
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -22,7 +22,8 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.oracle.svm.core.jdk;

package com.oracle.svm.webimage.substitute;

import java.util.Calendar;
import java.util.GregorianCalendar;
Expand All @@ -43,39 +44,38 @@
*/

@TargetClass(java.util.Calendar.class)
final class Target_java_util_Calendar {
final class Target_java_util_Calendar_Web {

@Substitute
private static Calendar createCalendar(TimeZone zone, Locale aLocale) {
return new GregorianCalendar(zone, aLocale);
}
}

@TargetClass(sun.util.calendar.CalendarSystem.class)
final class Target_sun_util_calendar_CalendarSystem {
@TargetClass(CalendarSystem.class)
final class Target_sun_util_calendar_CalendarSystem_Web {

@Substitute
private static CalendarSystem forName(String calendarName) {
if ("gregorian".equals(calendarName)) {
return Util_sun_util_calendar_CalendarSystem.GREGORIAN;
return Util_sun_util_calendar_CalendarSystem_Web.GREGORIAN;
} else if ("japanese".equals(calendarName)) {
return Util_sun_util_calendar_CalendarSystem.JAPANESE;
return Util_sun_util_calendar_CalendarSystem_Web.JAPANESE;
} else if ("julian".equals(calendarName)) {
return Util_sun_util_calendar_CalendarSystem.JULIAN;
return Util_sun_util_calendar_CalendarSystem_Web.JULIAN;
} else {
throw VMError.unsupportedFeature("CalendarSystem.forName " + calendarName);
}
}
}

final class Util_sun_util_calendar_CalendarSystem {

final class Util_sun_util_calendar_CalendarSystem_Web {
// The static fields are initialized during native image generation.
static final CalendarSystem GREGORIAN = CalendarSystem.forName("gregorian");
static final CalendarSystem JAPANESE = CalendarSystem.forName("japanese");
static final CalendarSystem JULIAN = CalendarSystem.forName("julian");
}

/** Dummy class to have a class with the file's name. */
public final class CalendarSubstitutions {
public final class WebImageCalendarSubstitutions {
}