use of com.ibm.dtfj.javacore.parser.framework.parser.IParserController in project openj9 by eclipse.
the class JavaCoreReader method generateImage.
/**
* @param input
*
* @throws UnsupportedSourceException
* @throws ParserException
* @throws IOException
*/
public Image generateImage(InputStream input) throws IOException {
try {
byte[] head = new byte[256];
input.read(head);
ByteArrayInputStream headByteStream = new ByteArrayInputStream(head);
Charset cs = getJavaCoreCodePage(headByteStream);
SequenceInputStream stream = new SequenceInputStream(headByteStream, input);
// Use default charset if none found
// Charset.defaultCharset is 5.0, so not usable for 1.4
Reader reader = cs != null ? new InputStreamReader(stream, cs) : new InputStreamReader(stream);
List frameworkSections = new DTFJComponentLoader().loadSections();
IParserController parserController = new ParserController(frameworkSections, fImageBuilderFactory);
parserController.addErrorListener(new IErrorListener() {
private Logger logger = Logger.getLogger(ImageFactory.DTFJ_LOGGER_NAME);
public void handleEvent(String msg) {
// map errors onto Level.FINE so that DTFJ is silent unless explicitly changed
logger.fine(msg);
}
});
J9TagManager tagManager = J9TagManager.getCurrent();
return parserController.parse(fComponents.getScannerManager(reader, tagManager));
} catch (ParserException e) {
IOException e1 = new IOException("Error parsing Javacore");
e1.initCause(e);
throw e1;
}
}
Aggregations