ochafik/nativelibs4java — Issue #204: org.anarres.cpp.DeferredFileReader#files static Set<File>
Author: ustamansangat
Created: 2011-11-21 15:13:32+00:00
State: open

I want to invoke maven-jnaerator-plugin more than one time on the same set of C header files; once for BridJ and once for JNA.
However this fails because of the following:

public class DeferredFileReader extends Reader {
...	static java.util.HashSet files = new java.util.HashSet();

I think, the set is used so that each header file, even if included by multiple other header files, would be parsed only once.

However, this means for my usecase, I will need to run the maven-jnaerator-plugin on a forked JVM, which the plugin doesn't support a configuration for. Currently, I am doing the following in my own maven plugin before calling com.ochafik.lang.jnaerator.JNAerator.main():
Class clazz = Class.forName("org.anarres.cpp.DeferredFileReader");
Field files_set = clazz.getDeclaredField("files");
files_set.setAccessible(true);
((Set) files_set.get(null)).clear();