• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Question about native methods (Dan C example)

 
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

[B]

Compile-time errors are generated at which lines?
a. 1
b. 2
c. 3
d. 4
e. 5
f. None of the above.
[/B]


In looking at this, I went through each implementation to see if it violated the rules for implementing an interface. All subclasses are concrete (non-abstract), so the question is: does each class implement public void m1()?
Classes D, E, and F do. What about class G? It looks like an abstract method. I chose answer e, because it looks like a lack of implementation.
My answer is wrong. The real answer is below (don't look yet).
My question: How do native methods work?

(anwser: i. none of the above)
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A native method is implemented in a module which the JVM has to load before calling the method. The module is implemented in a language such as C, C++, PL/1 (yes, on IBM 390).
There's something here that explains it all.
 
Ranch Hand
Posts: 203
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Unless you call the native method in your code JVM wouldn't even verify if the library in which the native method has implementation is included or not.
So as long as you are not calling the native method every thing is OK. You can declare a method as native.
 
Fire me boy! Cool, soothing, shameless self promotion:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic