Skip to content

Enable setUnmarshalListener on Binder #1822

@plutext

Description

@plutext

Previously this was likely to work via reflection:

	public void setListener(Binder binder, Listener listener) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
		
		org.glassfish.jaxb.runtime.v2.runtime.BinderImpl binderImpl = (org.glassfish.jaxb.runtime.v2.runtime.BinderImpl )binder;
		
		Method method = binderImpl.getClass().getDeclaredMethod("getUnmarshaller");
		method.setAccessible(true);
		Unmarshaller u  = (Unmarshaller)method.invoke(binderImpl);	
		u.setListener(listener);
	}

Nowadays, the likely outcome is:

java.lang.reflect.InaccessibleObjectException: Unable to make private org.glassfish.jaxb.runtime.v2.runtime.unmarshaller.UnmarshallerImpl org.glassfish.jaxb.runtime.v2.runtime.BinderImpl.getUnmarshaller() accessible: module org.glassfish.jaxb.runtime does not "opens org.glassfish.jaxb.runtime.v2.runtime" to module org.docx4j.JAXB_ReferenceImpl
	at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
	at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
	at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:200)
	at java.base/java.lang.reflect.Method.setAccessible(Method.java:194)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions