Native implementation of an abstract method

Hassam Abdelillah :

Is it permitted in Java to have a an abstract method within a class and then have it's implementation in an other with a native language using JNI.

example:

abstract class Mommy {
abstract protected void call();
}
class Son extends Mommy {
 native protected void call() /*
'native code'
*/
}

What is the expected behaviour is it a runtime error that may occurs or everything is fine with "workaround" ?

Stephen C :

What is the expected behaviour is it a runtime error that may occurs or everything is fine with "workaround" ?

Provided that you implement the native method (correctly) and load the native library containing the implementation, then everything works.

I wonder if bug prone or against any good/best practices?

Nope, and nope.

Or at least, it is not more bug prone or more against "best practice" than any use of native code.

By the way, you really ought to read James Bach's "No Best Practices" article before you bandy around dodgy terms like "best practice".

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=472571&siteId=1