Skip to content

Javacpp does not export package required by presets #483

@reckart

Description

@reckart

Presets such as the openblas preset in recent versions inherit from org.bytedeco.javacpp.presets.javacpp:

@Properties(inherit = javacpp.class, global = "org.bytedeco.openblas.global.openblas_nolapack", value = {
...
public class openblas_nolapack implements LoadEnabled, InfoMapper {

In an OSGI context, this leads to a ClassNotFoundException being thrown as part of loading the class annotations:

java.lang.ClassNotFoundException: org.bytedeco.javacpp.presets.javacpp cannot be found by <MY-BUNDLE>

I only discover the above exception by putting a breakpoint in the constructor of the TypeNotPresentExceptionProxy...
Otherwise, here is a stack trace showing the annotation loading:

Thread [AsyncThread-1] (Suspended (breakpoint at line 41 in TypeNotPresentExceptionProxy))	
	owns: Nd4j  (id=180)	
	owns: ConcurrentHashMap$ReservationNode<K,V>  (id=181)	
	TypeNotPresentExceptionProxy.<init>(String, Throwable) line: 41	
	AnnotationParser.parseClassValue(ByteBuffer, ConstantPool, Class<?>) line: 429	
	AnnotationParser.parseClassArray(int, ByteBuffer, ConstantPool, Class<?>) line: 724	
	AnnotationParser.parseArray(Class<?>, ByteBuffer, ConstantPool, Class<?>) line: 531	
	AnnotationParser.parseMemberValue(Class<?>, ByteBuffer, ConstantPool, Class<?>) line: 355	
	AnnotationParser.parseAnnotation2(ByteBuffer, ConstantPool, Class<?>, boolean, Class<Annotation>[]) line: 286	
	AnnotationParser.parseAnnotations2(byte[], ConstantPool, Class<?>, Class<Annotation>[]) line: 120	
	AnnotationParser.parseAnnotations(byte[], ConstantPool, Class<?>) line: 72	
	Class<T>.createAnnotationData(int) line: 3521	
	Class<T>.annotationData() line: 3510	
	Class<T>.createAnnotationData(int) line: 3526	
	Class<T>.annotationData() line: 3510	
	Class<T>.createAnnotationData(int) line: 3526	
	Class<T>.annotationData() line: 3510	
	Class<T>.getAnnotation(Class<A>) line: 3415	
	Loader.checkPlatform(Class<?>, Properties) line: 1010	
	Loader.load(Class, Properties, boolean) line: 1161	
	Loader.load() line: 1123	
	Nd4jCpu.<clinit>() line: 13	
	Class<T>.forName0(String, boolean, ClassLoader, Class<?>) line: not available [native method]	
	Class<T>.forName(String) line: 264	
	NativeOpsHolder.<init>() line: 85	
	NativeOpsHolder.<clinit>() line: 35	
	NativeOpExecutioner.<init>() line: 91	
	NativeConstructorAccessorImpl.newInstance0(Constructor<?>, Object[]) line: not available [native method]	
	NativeConstructorAccessorImpl.newInstance(Object[]) line: 62	
	DelegatingConstructorAccessorImpl.newInstance(Object[]) line: 45	
	Constructor<T>.newInstance(Object...) line: 423	
	Class<T>.newInstance() line: 442	
	Nd4j.initWithBackend(Nd4jBackend) line: 5215	
	Nd4j.initContext() line: 5129	
	Nd4j.<clinit>() line: 226	
...

As far as I can tell is because the org.bytedeco.javacpp.presets is actually not exported from the JavaCPP JAR:

Export-Package: org.bytedeco.javacpp;uses:="org.bytedeco.javacpp.annot
 ation";version="1.5.5",org.bytedeco.javacpp.annotation;version="1.5.5
 ",org.bytedeco.javacpp.indexer;uses:="org.bytedeco.javacpp";version="
 1.5.5",org.bytedeco.javacpp.tools;uses:="javax.management";version="1
 .5.5"

Unfortunately, the 1.5.2 JavaCPP also hast some issue with OSGi that I currently do not remember. So I have to combine JavaCPP 1.5.4 with openblas 0.3.7-1.5.2 because the latter is the last version that comes without the inherit = javacpp.class... but of course then I get warnings telling me that it is probably a bad idea to mix JavaCPP 1.5.4 with a lib that was build against the older 1.5.2 version.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions