tpalfy commented on code in PR #6703:
URL: https://github.com/apache/nifi/pull/6703#discussion_r1031433551
##########
nifi-nar-bundles/nifi-asn1-bundle/nifi-asn1-services/src/main/java/org/apache/nifi/jasn1/JASN1Reader.java:
##########
@@ -219,8 +236,55 @@ private void compileAsnToClass(String... asnFilePaths) {
asnCompilerArguments.add("-o");
asnCompilerArguments.add(asnOutDir.toString());
+ HashMap<String, AsnModule> modulesByName = new HashMap<>();
+
+ Exception parseException = null;
+ for (String asn1File : asnFilePaths) {
+ logger.info("Parsing " + asn1File);
+ try {
+ AsnModel model = getJavaModelFromAsn1File(asn1File);
+ modulesByName.putAll(model.modulesByName);
+ } catch (FileNotFoundException e) {
+ logger.error("Couldn't find " + asn1File, e);
+ parseException = e;
+ } catch (TokenStreamException | RecognitionException e) {
+ logger.error("Error while parsing " + asn1File, e);
+ parseException = e;
+ } catch (Exception e) {
+ logger.error("Couldn't parse " + asn1File, e);
+ parseException = e;
+ }
+ }
+
+ if (parseException != null) {
+ throw new ProcessException("Couldn't parse asn files.",
parseException);
+ }
+
try {
-
com.beanit.asn1bean.compiler.Compiler.main(asnCompilerArguments.toArray(new
String[0]));
+ Constructor<BerClassWriter> berClassWriterConstructor =
BerClassWriter.class.getDeclaredConstructor(
+ HashMap.class,
+ String.class,
+ String.class,
+ Boolean.TYPE,
+ Boolean.TYPE,
+ Boolean.TYPE
+ );
+
+ berClassWriterConstructor.setAccessible(true);
Review Comment:
The constructor is package private.
The only alternative I see is to create a "fake"
`com.beanit.asn1bean.compiler` package within the NiFi module and put a factory
there. Would that be better? (Although if we want to prepare for Java 16+ I
guess there's no other choice.)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]