Cool bug (or feature)

Hi everyone,

after messing around trying to get bullet to work, I noticed the following strange behaviour:

The following code (which I am tempted to use) causes an exception:

public Main() {
	super(
		new StatsAppState(),
		new FlyCamAppState(),
		new AudioListenerState(),
		new DebugKeysAppState(),
		new BulletAppState()
	);
}

Exception:

Exception in thread "main" java.lang.UnsatisfiedLinkError: com.jme3.bullet.PhysicsSpace.createPhysicsSpace(FFFFFFIZ)J
	at com.jme3.bullet.PhysicsSpace.createPhysicsSpace(Native Method)
	at com.jme3.bullet.PhysicsSpace.create(PhysicsSpace.java:155)
	at com.jme3.bullet.PhysicsSpace.<init>(PhysicsSpace.java:148)
	at com.jme3.bullet.BulletAppState.startPhysics(BulletAppState.java:164)
	at com.jme3.bullet.BulletAppState.stateAttached(BulletAppState.java:211)
	at com.jme3.app.state.AppStateManager.attach(AppStateManager.java:133)
	at com.jme3.app.LegacyApplication.<init>(LegacyApplication.java:118)
	at com.jme3.app.SimpleApplication.<init>(SimpleApplication.java:104)
    ...

This code, on the other hand, does work flawlessly:

public Main() {
	super(
		new StatsAppState(),
		new FlyCamAppState(),
		new AudioListenerState(),
		new DebugKeysAppState()
	);
}

public void simpleInitApp() {
	stateManager.attach(new BulletAppState());
}

This is part of my build.gradle (irrelevant things like lemur or logging shortened as …):

apply plugin: 'java'
apply plugin: 'application'
apply plugin: 'eclipse'
apply plugin: 'idea'

...

repositories {
    ...
}

ext.jmeVersion = '3.1.0-beta1'  // maybe needs another version

project(":assets") {
    ...
}


dependencies {
	...
	//jme
	compile "org.jmonkeyengine:jme3-core:$jmeVersion"
	compile "org.jmonkeyengine:jme3-desktop:$jmeVersion"
	compile "org.jmonkeyengine:jme3-lwjgl:$jmeVersion"
	
	//compile "org.jmonkeyengine:jme3-android-native:$jmeVersion"
	//compile "org.jmonkeyengine:jme3-android:$jmeVersion"
	//compile "org.jmonkeyengine:jme3-bullet-native-android:$jmeVersion"
	//compile "org.jmonkeyengine:jme3-blender:$jmeVersion"
	//compile "org.jmonkeyengine:jme3-bullet-native:$jmeVersion"
	compile "org.jmonkeyengine:jme3-bullet:$jmeVersion"
	//compile "org.jmonkeyengine:jme3-effects:$jmeVersion"
	//compile "org.jmonkeyengine:jme3-jogg:$jmeVersion"
	//compile "org.jmonkeyengine:jme3-jogl:$jmeVersion"
	//compile "org.jmonkeyengine:jme3-lwjgl3:$jmeVersion"
	//compile "org.jmonkeyengine:jme3-networking:$jmeVersion"
	//compile "org.jmonkeyengine:jme3-plugins:$jmeVersion"
	//compile "org.jmonkeyengine:jme3-terrain:$jmeVersion"
	
	...

    runtime project(':assets')
}

task wrapper(type: Wrapper) {
}

task createDirs << {
    ...
}

Is this a known bug? Is it solved in later versions?

PS:
and why are there two bullets? Which one do I even need? My current choice was a complete guess


UPDATE:
Using version '3.1.0-stable' does not help

You need bullet and bullet native!

Still fails after I do:

compile "org.jmonkeyengine:jme3-bullet-native:$jmeVersion"
compile "org.jmonkeyengine:jme3-bullet:$jmeVersion"

Same exception

I did gradle clean, gradle build, Refresh Gradle Project (Eclipse), and gradle run (both in Eclipse and cmd).

Hmmm… It seems like this is caused by BulletAppState. Maybe BulletAppState needs someting which is not available before simpleInit() ??? Sorry, I can’t help here… :frowning:

Not sure what’s causing it, but UnsatisfiedLinkError means that the JVM isn’t finding the native Bullet library.

Move BulletAppState to simpleInit().

This is because native libraries are only loaded when the app instance is created. You could load them manually before if you want this to work badly.