Can a method implemented from interface be native ?

This is a bit of a SCJP question.
interface One
public void someMethod();
public class One_impl implements One
public native void someMethod();
Assuming that the native method is not provided in any local library, an attempt to compile and run the above lines
of code will cause
1. Compilation error - implimentations can never be native.
2. Compilation error - method not found in local libraries.
3. Runtime Exception - method not found in local libraries.
4. Compilation successfull but runtime error is thrown if and only if the method someMethod of class One_impl is
called
My question is can a implemented method be native ?
I am totally blank about native methods in Java.(Does this dismiss the right to put a question and study native methods in Java first ?)
Thanks.

ejp wrote:
My question is can a implemented method be native ?Yes.
I am totally blank about native methods in Java. (Does this dismiss the right to put a question and study native methods in Java first ?)It does suggest that you could have read the JLS first.Maybe reading native methods in JLS would clear things for me.
Thanks.

Similar Messages

  • Using SEO_METHOD_ACTIVATE with methods implemented from Interface

    Hi,
    I'm trying to create a class and activate it using some ABAP code. I began by copying a template class into a new class called ZKMOD_COPY.
    Now I want to activate this class. I tried SEO_METHOD_ACTIVATE but all it does is set the flag to 'A' in the table. It doesn't really activate the whole class I see in SE24.
    Going through the forums, I came across ABAP Objects where someone said to call these in order: SEO_ATTRIBUTE_ACTIVATE, SEO_EVENT_ACTIVATE,  SEO_METHOD_ACTIVATE, SEO_TYPE_ACTIVATE
    Now my class does not contain any attributes, events or types. It contains just one method, so I suppose except SEO_METHOD_ACTIVATE I don't really need the others.
    Now this method (called EXIT) is implemented from an Interface IF_RSCNV_EXIT. In the class definition of ZKMOD_COPY, it shows this method by the name IF_RSCNV_EXIT~EXIT.
    The problem is that I'm not able to activate this method. I can't figure out what parameters to give in CIFKEYand  MTDKEYS
    I tried all permutations of "zkmod_copy", "if_rscnv_exit" as classes, "exit" and "if_rscnv_exit~exit" as the methods, but it kept throwing exceptions like not specified or not existing. Debugging the FM also did not give me any clues.
    So what I really need is, what parameters should I give there? Alternatively, is there any way I can programmatically activate my class? This may sound a silly question, since I'm a BI guy with not too much ABAP knowledge, but I'd be really grateful if someone could help out with this.

    Matt,
    We have some Customer Exits in BI. I'm trying to develop a kind of program that will generate the code for a customer exit class. So probably I would have an FM take some params, create the class with some static member attributes (not yet fully designed), so that it is ready to be used as a customer exit.
    It's all still nebulous - I'm finding the various things that I feel I will need.
    CIFKEYS I think is the -> IF_RSCNV_EXIT
    MTDKEYS-CLSNAME is IF_RSCNV_EXIT
    MTDKEYS-CMPNAME is EXIT.
    In this, the name of the class ZKMOD_COPY is not used anywhere. But IF_RSCNV_EXIT is an interface, it can be implemented by any number of classes. So shouldn't the class name (ZKMOD_COPY) be mentioned somewhere? How would the system know which implementation of IF_RSCNV_EXIT should be activated?
    At present I'm not in front of a system; I'll try this on Monday and get back to you. Thanks for the help anyway, Matthew!

  • How can I access instances from Interface Builder?

    Hello!
    How can I access instances build from the Interface Builder? For example, i know how to access Controller classes = just setting the class in the view identity. But I am missing some "connection" to my navigation controller. IB uses one, but in my code, i dont have one.
    All my xibs file owners have as their identity class a View or TableView Controller. But shouldnt they have a navigation controller as identy if the View or TableView is using a navigation Controller?
    thank you..

    thank you, .. i know.. the problem is, that i have different xib files, but i am not sure how i can connect them with their navigation controller / tabbarcontroller.
    it seems, that
    NSLog(@"pushing next view..");
    [[self navigationController] pushViewController:nextViewController animated:YES];
    is not enough. On the console, i can read pushing next view.. but it doesnt come up to the screen.

  • Invoking methods extracted from a string?!?

    Hi everybody. I hope the subject is not confusing. What I'm really looking for is some Perl-like behaviour in Java. In Perl its possible to execute subroutines (basicly methods) extracted from a string ("&sub()"). Is there anything similar in Java?
    What I would like to do is to process a string and if it has a method (object.getTime()), the method will be called and the return value stored in its place.
    Please let me know if more explanation is needed.
    Thanks in advance for all the help!
    Leo.

    I use a language called MUMPS where you can do that as well - execute strings as commands etc. I don't know much about Reflection but it looks like you can get method (Objects) from strings and execute them as well ...

  • Can subclass use a method in supercalss as the implementation of interface?

    Assume P is the superclass of S. S implements interface I. Both P and I have the same method m. Must I implement m in S?
    Thanks.

    It depends.
    If m is public then it is already inherited so you don't have to unless you want a overriding implementation.
    If m is private, it is not, so you have to.
    If it is protected, the Super Class method cannot hide the public method in the interface, so again, you have to.
    HTH.
    -o12

  • Return Collection or Set from interface methods?

    When designing abstract entities, like interfaces, abstract classes and utility classes, that hence shouldn't assume too much about neither implementation nor usage, I've been thinking a lot about whether it is better practice to use return types that are as (semantically) specific as possible, or as abstract as possible.
    Consider as an example a method in an interface that returns a set of units. It can be declared at two levels of abstraction - with Collection or Set as the return type.
    public Set getUnits();
    public Collection getUnits();
    The users of the interface instances do not have knowledge of the implementation. The implementations of the interface do not have knowledge of the users.
    That means, some implementations may be utilizing the non-duplicate property of the collection and implement it as a HashSet. Another implementation may also need special ordering and therefore implements it as a LinkedList.
    To specify Set in the interface forces the implementations - either to implement using Sets, or to incur a possibly very significant overhead by converting the internal representation to a Set for the method's return value.
    To specify Collection in the interface does not force anything on the implementations, and the contract that no duplicate elements occur can still be clearly specified (and obvious in the context). On the other hand, the users of the interface lose the Set semantics they might like to make use of, for instance O(1) random access is reasonable to expect from most Set implementations. But this isn't certain, so is it a strong argument?
    Any thoughts?

    Hi,
    I've had to make a similar decision recently, where I'm creating implementations of a generic time-series database, each of which consists of a number of measuring 'stations', which are returned via a method. My initial design of the database interface had the method:
    Set getStationSet();This seemed the most obvious solution, as there would certainly be no duplicate stations defined by a given database. However, I subsequently changed this to
    Collection getStations();for a number of reasons.
    Some databases return the stations in a specified order (the order in which the users of that database are most familar with). If the return type is a Set it forced the use of a TreeSet (assuming I don't write my own SortedSet implementation), which for some (large) databases imposes quite an overhead.
    Also, most database client code just iterates through the returned Set/Collection, sees whether a station meets a certain criteria, and uses it if so. Most code (in my example at least) simply does not need Set behaviour. Any code that does can simply use
    Set s = new HashSet( getStations() );which is hardly a major coding effort for clients using the interface.
    Subsequent coding indicates I've made the right choice. I would definitely say you should return a Collection and simply state in the associated documentation that the collection wont contain any duplicates and it can be put in a Set, or SortedSet, if required.
    In general, I also think it makes sense for interfaces to be as generic (or abstract) as possible.
    Ol.

  • Can Enum parameterized type implement an interface?

    I am trying to define a class that is parameterized with an Enum and the parameterized Enum must implement an interface. Here is some code:public interface MatchingEnum<E> {
        String match(); // This interface is not yet complete
    public class EnumField<E extends Enum<E> & MatchingEnum<E>> {
        private E enumeration;
        public EnumField(E enumeration) {
            this.enumeration = enumeration;
        private static class Test {
            EnumField<TestType> c;
        public enum TestType implements MatchingEnum<TestType> { One, Two, Three;
            public String match() {
                return null;
    }The problem is that the compiler complains that "classes cannot directly extend java.lang.Enum". If I delete the interface for the parameterized type(below) it compiles fine. Why can't the compiler handle this? Does specifying an Interface for an Enum bounds (E) force it to directly extend Enum? If so, why does the actual Enum compile?public class EnumField<E extends Enum<E>> {Blah, blah, blah... // This compiles
    public class EnumField<E extends Enum<E> & MatchingEnum<E>> {Blah, blah blah... // This does NOT compile

A: Can Enum parameterized type implement an interface?

Compiled from "EnumField.java"
public class com.dartcontainer.mdc.picaps.textui.screen.widget.EnumField extends java.lang.Object{
public com.dartcontainer.mdc.picaps.textui.screen.widget.EnumField(java.util.List);
  Code:
   0:   aload_0
   1:   invokespecial   #2; //Method java/lang/Object."<init>":()V
   4:   aload_0
   5:   aload_1
   6:   putfield        #1; //Field enumeration:Ljava/util/List;
   9:   return
public static void main(java.lang.String[]);
  Code:
   0:   new     #3; //class com/dartcontainer/mdc/picaps/textui/screen/widget/EnumField$Test
   3:   dup
   4:   aconst_null
   5:   invokespecial   #4; //Method com/dartcontainer/mdc/picaps/textui/screen/widget/EnumField$Test."<init>":(Lcom/dartcontainer/mdc/picaps/textui/screen/widget/EnumField$1;)V
   8:   astore_1
   9:   getstatic       #5; //Field java/lang/System.out:Ljava/io/PrintStream;
   12:  new     #6; //class java/lang/StringBuilder
   15:  dup
   16:  invokespecial   #7; //Method java/lang/StringBuilder."<init>":()V
   19:  ldc     #8; //String t.m =
   21:  invokevirtual   #9; //Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
   24:  aload_1
   25:  getfield        #10; //Field com/dartcontainer/mdc/picaps/textui/screen/widget/EnumField$Test.m:Ljava/lang/String;
   28:  invokevirtual   #9; //Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
   31:  invokevirtual   #11; //Method java/lang/StringBuilder.toString:()Ljava/lang/String;
   34:  invokevirtual   #12; //Method java/io/PrintStream.println:(Ljava/lang/String;)V
   37:  return
static java.util.List access$100(com.dartcontainer.mdc.picaps.textui.screen.widget.EnumField);
  Code:
   0:   aload_0
   1:   getfield        #1; //Field enumeration:Ljava/util/List;
   4:   areturn
}

Compiled from "EnumField.java"
public class com.dartcontainer.mdc.picaps.textui.screen.widget.EnumField extends java.lang.Object{
public com.dartcontainer.mdc.picaps.textui.screen.widget.EnumField(java.util.List);
  Code:
   0:   aload_0
   1:   invokespecial   #2; //Method java/lang/Object."<init>":()V
   4:   aload_0
   5:   aload_1
   6:   putfield        #1; //Field enumeration:Ljava/util/List;
   9:   return
public static void main(java.lang.String[]);
  Code:
   0:   new     #3; //class com/dartcontainer/mdc/picaps/textui/screen/widget/EnumField$Test
   3:   dup
   4:   aconst_null
   5:   invokespecial   #4; //Method com/dartcontainer/mdc/picaps/textui/screen/widget/EnumField$Test."<init>":(Lcom/dartcontainer/mdc/picaps/textui/screen/widget/EnumField$1;)V
   8:   astore_1
   9:   getstatic       #5; //Field java/lang/System.out:Ljava/io/PrintStream;
   12:  new     #6; //class java/lang/StringBuilder
   15:  dup
   16:  invokespecial   #7; //Method java/lang/StringBuilder."<init>":()V
   19:  ldc     #8; //String t.m =
   21:  invokevirtual   #9; //Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
   24:  aload_1
   25:  getfield        #10; //Field com/dartcontainer/mdc/picaps/textui/screen/widget/EnumField$Test.m:Ljava/lang/String;
   28:  invokevirtual   #9; //Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
   31:  invokevirtual   #11; //Method java/lang/StringBuilder.toString:()Ljava/lang/String;
   34:  invokevirtual   #12; //Method java/io/PrintStream.println:(Ljava/lang/String;)V
   37:  return
static java.util.List access$100(com.dartcontainer.mdc.picaps.textui.screen.widget.EnumField);
  Code:
   0:   aload_0
   1:   getfield        #1; //Field enumeration:Ljava/util/List;
   4:   areturn
}

  • Creating shared library of native method implementation using gcc

    Hi
    I am using Dev-C++ IDE for writing and compiling C Programs. It supports gcc.
    I have to build a shared library of a native method implementation using gcc compiler.
    In JNI tutorial build script is given for VC++ which is as follows
    cl -Ic:\java\include -Ic:\java\include\win32
    -LD HelloWorldImp.c -Fehello.dll
    Similarly I wanted build script for gcc compiler.
    Thanks
    Shailesh

    Here is an example of building a library from one module with CygWin's gcc:
    # Must set JAVA_HOME and LIBRARY_MODULE before
    gcc -mno-cygwin -D__int64="long long" -I $JAVA_HOME/include/win32 -I $JAVA_HOME/include -shared -Wl,--kill-at -o $LIBRARY_MODULE.dll $LIBRARY_MODULE.c

  • Can a class implements more than one interface?

    Hello
    Can a class implements more than one interface?
    Thanks

    Of course, this doesn't mean that it won't be a problem though. If the two interfaces have methods with the same signature, but different return types, you won't be able to implement them together. I.E.
    interface InterfaceA {
      public int doSomething(String myString);
    interface InterfaceB {
      public String doSomething(String myString);
    // Now the classes
    // Gives error "Duplicate method doSomething(String) in type ClassA"
    public class ClassA implements InterfaceA, InterfaceB {
      public int doSomething(String myString) {
        System.out.println("A");
        return 0;
      public String doSomething(String myString) {
        System.out.println("B");
        return 0;
    // Gives error "The return type is incompatible with InterfaceB.doSomething(String)"
    public class ClassB implements InterfaceA, InterfaceB {
      public int doSomething(String myString) {
        System.out.println("A");
        return 0;
    // Gives error "The return type is incompatible with InterfaceA.doSomething(String)"
    public class ClassC implements InterfaceA, InterfaceB {
      public String doSomething(String myString) {
        System.out.println("B");
        return 0;
    }

  • Regarding Interface methods implementation

    Hi,
    I have a interface with 3 methods.
    public interface test{
    public void A();
    public void B();
    public void C();
    public class IntImpl implements test{
    public void B(){
    //implementation
    Can we implement an interface with out implementing all the methods of interface .instead implementing a few methods in the interface?
    i came to know that we can do the above one with out any exceptions? So any of you can resolve this issue ..
    Thanks in advance
    Sri

    Can we implement an interface with out implementing
    all the methods of interface .instead implementing a
    few methods in the interface?In other words: can we implement an interface without implementing it?
    The answer should be obvious.
    i came to know that we can do the above one with out
    any exceptions? Sure, it's quite easy, you already did it. The stuff above won't compile, hence it won't throw an exception when running.
    Or you can also avoid compiler errors by declaring IntImpl as abstract. Which means you didn't implement the interface though.

  • Class implementing two interfaces with same methods

    interface Foo {
    public void execute();
    interface Bar {
    public void execute();
    class Dam implements Foo, Bar {
    public void execute() {
    //Which interface's execute method is being called here?
    How do I make the Damn class have different implemenations for the execute method of the Foo and the Bar interfaces?

    hi,
    //Which interface's execute method is being calledinterfaces' method are neither called to be executed by the JVM because they're not concrete implementation but only signature declaration.
    How do I make the Damn class have different
    implemenations for the execute method of the Foo and
    the Bar interfaces?this can't be done if the signatures are the same, but if they're not, for instance
    public void execute( int i )
    public void execute( String s )
    then you can have two implementation...anyway, what's the point if the signature are the same ? if you really want them to do different things why wouldn't you name them differently ?
    raphaele

  • How can I know a class which implements Runnable interface has terminated?

    Hello! I have a class which has implements Runnable interface, while I want to execute some operation when the thread has terminate in multithread enviroment.How can I know the thread has terminated?Does it give out some signal?Cant I just call my operation at the end of the run() method?

    I want to execute some operation when
    the thread has terminate in multithread enviroment....
    Cant I just call my operation at the end
    of the run() method?Sure. Before run() ends, invoke that other operation.
    How
    can I know the thread has terminated?Does it give out
    some signal?Not that I'm aware of, but you can do what you described above, or I believe a different object can call isAlive on the thread.

  • How to consume a method on the interface controller from another component?

    Hello,
    I have a project which contains two Components, A & B.
    I have exposed a method at the interface controller of Component A. How can I consume it from Component B?

    Hi,
       First add ComponentA as a used webdynpro component in ComponentB. Then open the Interface Controller of B and switch to Properties Tab. Select Add in the "Required Controllers" section. From the dialog that appears, select A's interface controller. Then you can access A's method from B's interface controller as:
    wdThis.wdGetAComponentInterface().<method>;
    Regards,
    Satyajit.

  • Can't download anything from app store or itunes. everytime i try to install an app i get "there is abilling problem with a previous purchase. please update ur payment method". i have recently changed my address and visa debit card. please help

    can't download anything from app store or itunes. everytime i try to install an app i get this error "there is a billing problem with a previous purchase. please update ur payment method". i have recently changed my visa debit card and home adress and when i make these changes i still get the same error.
    will u please help me out?

    Are you listing the billing address for the card correctly? The address in the iTunes/MAS account must match the address on your bill exactly.

  • Is there a quick fix option for implementing the unimplemented methods for an interface?

    Hi guys,
    It's a useful feature and it seems to exist in raw Eclipse.  I'm aware of the Source -> Override/Implement methods, but this is clunky when you could hover over an interface and hit Ctrl+1 and auto-implement all methods  for that interface (which seems to be pretty much most use cases for me).  At the moment the quick-fix only seems to have renaming options.  Is there something wrong with my configuration?
    If not, is there a way to make feature requests?  :-))
    Thanks!
    Jarrod

    I have safari on my iPone and like it there... thought that I would give it a try. Well, IE just started to slow to a paint drying speed and then wouldn't load anything. Safari was installed but crashed in threee seconds each occuarnce. No reason, no error message.
    I downloaded (eventually) Firefox... loaded it, chose my extentions and have never had a problem with it since. I unloaded 5 times (gave up on) Safari, reset IE, reinstalled the extentions for that and now it is working after cleaning all of the files, passwords, forms autocomplete, temp files, etc.
    Firefox works and all of my freinds and kids use it. That is why it is so good. Remember, if your car worked like your PC you wold junk it right away. Reliability is not in the MS dictionary. It is something that you have to add via tons of fixes, add-ons and program balancing so that conflicts don't occer. I want my MAC, I want my, I want my MAC...

  • Maybe you are looking for

    • K8D Master-F 9131 problem with BIOS 1.2 and Raidcore BC4852

      The board does not start the Raidcore BIOS with motherboard 9131 BIOS 1.2 installed. It works OK wih BIOS 1.1. Raidcore 4852 FW is V130. (tested V110 = same problem) Bios found here: http://www.msi.com.tw/program/support/download/dld/spt_dld_detail.p

    • The description for Event ID 8306 from source Microsoft-SharePoint Products-SharePoint Foundation cannot be found

      hi, can anyone please help me with the following: The description for Event ID 8306 from source Microsoft-SharePoint Products-SharePoint Foundation cannot be found. Either the component that raises this event is not installed on your local computer o

    • File Name Schema

      Dear All, I am working on Idoc-XI-File scenario. Currently I am getting an output file with the name "xi_timestamp" but now I want to change the timestamp with the "Delivery No" which is there in the flat file. Kindly suggest how this can be done. Wa

    • Delete Hidden User Accounts

      My girlfriend has a Powerbook G4 Titanium 867MHz and is running Panther 10.3.9. She had purchased it used and has had it for quite some time now. Ever since she bought it, it has had a user account labeled "Other" at the opening Log-in screen. She ha

    • Alter index coalesce nologging

      Hi, Is nologging superfluous when used with index coalesce? Thanks for help