• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

native method

 
Ranch Hand
Posts: 219
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is this statement true?
native method:
private or protected is a valid modifier for method.int or boolean is a valid return type.It can take any arguments.
 
Ranch Hand
Posts: 411
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
private or protected is a valid modifier for method.
TRUE
int or boolean is a valid return type.
TRUE
It can take any arguments
FALSE - For example it cannot take Vector as an argument
Regards,
Jamal Hasanov
www.j-think.com
 
Ranch Hand
Posts: 2120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please Jamal, can you elaborate a bit more on what kind of objects can be passed to native methods?
Thanks.
------------------------
Correction:
Well I am sorry . I meant what objects cannot be passed to native methods. Sorry for the typo.
[ June 15, 2002: Message edited by: Jose Botella ]
 
Jamal Hasanov
Ranch Hand
Posts: 411
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
C'mon Jose...Don't joke on me:-))) I just wanted to explain it....
Jamal Hasanov
www.j-think.com
 
Thiru Thangavelu
Ranch Hand
Posts: 219
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But for me, Can you explain it bit elaborately Jamal?
[ June 15, 2002: Message edited by: Thiru Thangavelu ]
[ June 15, 2002: Message edited by: Thiru Thangavelu ]
 
Jamal Hasanov
Ranch Hand
Posts: 411
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, Thiru & Jose
There's no concrete rule for parameter type of native methods-it depends what programming language you'll use for native methods.
For example if you wrote native method in C++
void foo(char [] ch,int i) {...}
the implementation of this method in Java will be
native void foo(String s,int i)
In native methods you had to choose appropriate parameter & return types.
If you have some object in C++ or some type in Fortran, you cannot implement it for Java...
And vise versa - suppose you have
void add(Vector users)
method in Java and you want to optimize speed of running, by using native C or C++ method. It will be impossible, in C++ 'cause there's no appropriate object to Vector.
If you have questions, ask me.
Jamal Hasanov
www.j-think.com
 
Thiru Thangavelu
Ranch Hand
Posts: 219
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Jamal,
After reading your reply, the following questions have come up in my mind
1) So, native methods can not arguments for which there is no equivalant datatypes in other languages like the one you mentioned(Vector). Is this statment true or Can you make a little adjustments like using String for char[] array?(I don't know abt other datatypes in other languages, so only I am mentioning String and char[])
2) Concerning the exam, in what depth you need to know about native methods? Most often, I used to see the question "Select the correct way of declaring native methods?"
3) Any links, threads for native methods.
Thanks
 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ,
Native methods are written in non-java language, generally c and c++. You can use only those types which have mapping in Java language.
There are vectors provided as a part of standard c++ library. I ma not sure,why there is no equivalent mapping in java. One of the reason iam guessing ( i am not sure) is in java vectors are objects , but in c ++ they are not.
Native method link :
http://java.sun.com/docs/books/tutorial/native1.1/
 
reply
    Bookmark Topic Watch Topic
  • New Topic