Skip to content

Jollyday fails with Java 16 #148

Description

@alexoooo

Jollyday uses JAXB to read the configuration XML, this results in illegal access violations.
In Java 16 some of the illegal access violations that used to be flagged as warnings have been escalated to errors.

I was able to get around the issue using XStream instead of JAXB, first exporting the config using Java 15:

ManagerParameter parameter = ManagerParameters.create(calendarPart);
Configuration configuration = HolidayManager.getInstance(parameter).getConfigurationDataSource().getConfiguration(parameter);
String export = new XStream().toXML(configuration);

Then replace the contents of Holidays_[x].xml with the XStream format, and load them back with Java 16:

HolidayManager manager = new DefaultHolidayManager();
manager.setConfigurationDataSource(new XStreamConfigurationDataSource());

ManagerParameter parameter = ManagerParameters.create(calendarPart);
new ConfigurationProviderManager().mergeConfigurationProperties(parameter);
manager.init(parameter);

private static class XStreamConfigurationDataSource implements ConfigurationDataSource {
	@Override
	public Configuration getConfiguration(ManagerParameter managerParameter) {
		URL resourceUrl = managerParameter.createResourceUrl();
		try (InputStream inputStream = resourceUrl.openStream()) {
			return (Configuration) new XStream().fromXML(inputStream);
		}
		catch (IOException e) {
			throw new UncheckedIOException(e);
		}
	}
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions