javah failing with Invalid byte tag in constant pool: 18

1,851 views
Skip to first unread message

Daniel Wexler

unread,
Jun 2, 2015, 5:29:04 PM6/2/15
to mave...@googlegroups.com

Adding C++ JNI using nar-maven-plugin to an existing Spring Tools Suite (STS) project using Java 1.8.0_45, Maven 3.3.3, nar-maven-plugin 3.2.3 on OSX Yosemite 10.10.3, I get the following error for the javah goal:

[ERROR] Failed to execute goal com.github.maven-nar:nar-maven-plugin:3.2.3: \
        nar-javah (default-nar-javah) on project archivist: \
        JAVAH: Class could not be inspected: Invalid byte tag in constant pool: 18 -> [Help 1]

I've paired down my native class to the basics:

package com.zorroa.archivist.processors;
public class CaffeProcessor {
    public final native int test();
    CaffeProcessor() {
        System.out.println(test());
    }
}

Here are the diffs for my pom.xml from the existing STS version:

diff --git a/pom.xml b/pom.xml
index a62a27e..08fe118 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
   <groupId>com.zorroa</groupId>
   <artifactId>archivist</artifactId>
   <version>1.0.0</version>
-  <packaging>jar</packaging>
+  <packaging>nar</packaging>

   <name>zorroa-archivist</name>
   <description>Demo project for Spring Boot</description>
@@ -102,15 +102,55 @@
     <artifactId>hazelcast</artifactId>
     <version>3.4.2</version>
   </dependency>
-
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>4.7</version>
+      <scope>test</scope>
+    </dependency>
   </dependencies>

   <build>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <groupId>@project.groupId@</groupId>
+          <artifactId>nar-maven-plugin</artifactId>
+          <version>@project.version@</version>
+        </plugin>
+      </plugins>
+    </pluginManagement>
     <plugins>
       <plugin>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-maven-plugin</artifactId>
       </plugin>
+      <plugin>
+        <groupId>com.github.maven-nar</groupId>
+        <artifactId>nar-maven-plugin</artifactId>
+        <extensions>true</extensions>
+        <configuration>
+          <cpp>
+            <debug>true</debug>
+          </cpp>
+          <libraries>
+            <library>
+              <type>jni</type>
+              <narSystemPackage>com.zorroa.archivist.processors</narSystemPackage>
+            </library>
+          </libraries>
+          <javah>
+            <includes>
+              <include></include>
+            </includes>
+          </javah>
+          <tests>
+            <test>
+              <name>Caffe</name>
+            </test>
+          </tests>
+        </configuration>
+      </plugin>
     </plugins>
   </build>
 </project>

I have run javah via "mvn nar:nar-javah" successfully for the nar-maven-plugin it examples 0003, 0005, and 0007. Any debugging tips, workarounds are greatly appreciated.

Curtis Rueden

unread,
Jun 3, 2015, 8:01:42 AM6/3/15
to Daniel Wexler, NAR Maven plugin
Hi Daniel,

> Invalid byte tag in constant pool: 18

This is a limitation of Apache BCEL with Java 8:

The issue is fixed, but BCEL 6.0 has not yet been released.

You might be able to work around it by adding a dep to nar-maven-plugin on org.apache.bcel:bcel:6.0-SNAPSHOT, but I don't know whether it's backwards compatible with 5.2 or not. Worth a shot.

Or you could use Java 7 when building for now.

Regards,
Curtis


--
You received this message because you are subscribed to the Google Groups "NAR Maven plugin" group.
To unsubscribe from this group and stop receiving emails from it, send an email to maven-nar+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

ccj...@us.ibm.com

unread,
Jul 27, 2016, 12:39:06 PM7/27/16
to NAR Maven plugin
Reply all
Reply to author
Forward
0 new messages