Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does <init> and (Native Method) mean?

What do the symbols indicate and what does the (Native method) say about the java.io.FileStream.open method?

Exception in thread "main" java.io.FileNotFoundException: line23 (No such file or directory)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:135)
at java.io.FileInputStream.<init>(FileInputStream.java:95)
at java.io.FileReader.<init>(FileReader.java:64) at Helper.readFile(Foo5.java:74)
at Bar2.main(Bar2.java:32)
like image 796
sadfrogger Avatar asked Jul 23 '13 06:07

sadfrogger


People also ask

What does native method mean in Java?

Native methods are Java™ methods that start in a language other than Java. Native methods can access system-specific functions and APIs that are not available directly in Java. The use of native methods limits the portability of an application, because it involves system-specific code.

What is native method stack?

Native Method Stacks. An implementation of the Java Virtual Machine may use conventional stacks, colloquially called "C stacks," to support native methods (methods written in a language other than the Java programming language).

What is native method library?

Native Method Libraries are libraries that are written in other programming languages, such as C, C++, and assembly. These libraries can be loaded through JNI. So, the picture you posted is saying that JNI allows access to Native Method Libraries.

How do you call a native method in Java?

A native method is a Java method (either an instance method or a class method) whose implementation is also written in another programming language such as C/C++. Moreover, a method marked as native cannot have a body and should end with a semicolon: [ public | protected | private] native [return_type] method ();


2 Answers

When you see < init > in a stacktrace, it refers to the constructor of the class.

Native Method means that the method is not implemented in Java, but in another low-level language like C or C++. In this case, open() is a method that requires low-level functions, which are different from OS to OS.

like image 156
morgano Avatar answered Oct 18 '22 03:10

morgano


The native method is implemented within the JVM (Java Virtual Machine). The Java developer isn't supposed to worry about their implementation as they relate to the inner working of the virtual machine.

In here java.io.FileStream.open() issuch an operation.

like image 24
Ruchira Gayan Ranaweera Avatar answered Oct 18 '22 03:10

Ruchira Gayan Ranaweera