B4Alpha-Aft3r0mega / javacpp

Automatically exported from code.google.com/p/javacpp
GNU General Public License v2.0
0 stars 0 forks source link

Nullpointer in Loader.load() #38

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Loading float pointers.
2.
3.

What is the expected output? What do you see instead?

Expecting a floatpointer to successfully allocate, but instead I see a 
NullPointer exception.

What version of the product are you using? On what operating system?

JavaCpp 0.6 on Mac Os X

Please provide any additional information below

import com.googlecode.javacpp.FloatPointer;
import static com.googlecode.javacpp.Loader.load;

public class TestFloatPointer
{

    static {
        load();
    }

    public static void main(String[] args)
    {
        System.out.println("Testing float pointer");
        FloatPointer fp = new FloatPointer(10);
        System.out.println("Built fp of length "+fp.sizeof());

    }
}

---->

Exception in thread "main" java.lang.ExceptionInInitializerError
Caused by: java.lang.NullPointerException
    at com.googlecode.javacpp.Loader.findLibrary(Loader.java:611)
    at com.googlecode.javacpp.Loader.load(Loader.java:590)
    at com.googlecode.javacpp.Loader.load(Loader.java:541)
    at eclipsecode.floatpointer.TestFloatPointer.<clinit>(TestFloatPointer.java:14)
Java Result: 1

Original issue reported on code.google.com by ah4...@gmail.com on 17 Oct 2013 at 12:55

GoogleCodeExporter commented 8 years ago
Thanks for reporting! I've fixed that in this revision:
http://code.google.com/p/javacpp/source/detail?r=88d011c350b5bff956c27b83caf45b6
86e8b45df
On error, it should now throw a more meaningful exception, but it still won't 
work without any `native` functions. May I ask if you actually want to use 
`FloatPointer` alone without any custom `native` functions??

Original comment by samuel.a...@gmail.com on 20 Oct 2013 at 1:53

GoogleCodeExporter commented 8 years ago
Thanks for quick response and for the bug fix! No, it was just a test case. I 
was trying to find a bug that popped up while using floatpointer to send depth 
data from java to the c++ point cloud library (pcl). 

I think there may have been some problems finding native libraries within 
netbeans. 

Original comment by ah4...@gmail.com on 23 Oct 2013 at 11:03

GoogleCodeExporter commented 8 years ago
Could you provide more information about what's going on with NetBeans?

BTW, for better portability, the native libraries should be placed in the 
CLASSPATH along the Java class file. This way JavaCPP can use Java to locate 
the library files, and we don't have to rely on the native system.

Original comment by samuel.a...@gmail.com on 26 Oct 2013 at 6:29

GoogleCodeExporter commented 8 years ago
-Could you provide more information about what's going on with NetBeans?

I never got my head around it properly. I ended up deleting the Netbeans cache 
and it the issue was resolved, so..  

-BTW, for better portability, the native libraries should be placed in the 
CLASSPATH along the Java class file.

That sounds like a good idea, but my javacpp build is linking against cpp 
libraries that are installed system level with flags like:
   <arg line="-Xcompiler -L/usr/local/lib"/>
in build.xml. I am open to suggestions but, when linking against large 
libraries, its ponderous to place them in the classpath right?

Original comment by ah4...@gmail.com on 26 Oct 2013 at 6:38

GoogleCodeExporter commented 8 years ago
The files need to be copied, so we lose a little of time there, but with JAR 
compression, we gain a little bit of disk space...

Obviously if you already have something to install everything on all the OS's 
you are targeting, that's fine too!

Original comment by samuel.a...@gmail.com on 26 Oct 2013 at 6:44

GoogleCodeExporter commented 8 years ago
In any case, I've included the fix in JavaCPP 0.7! Again, thanks for reporting

Original comment by samuel.a...@gmail.com on 7 Jan 2014 at 1:24