Declare deprecated a method

Hello,
I need to declare deprecated a method into my classes and simply I don't know how. I've tried to use a javadoc comment @deprecated but after I compile I don't receive the message that this method is deprecated.
Thanx

Check "What happens when an API is Deprecated"
http://java.sun.com/products/jdk/1.1/docs/guide/misc/deprecation/deprecation.html
and read the note, that says if you compile the class with the deprecated method along with classes that uses this method, then you won't get a warning. :)

Similar Messages

  • Enum declaration in a method

    An enum can be declared inside or outside a class, but can't be declared in a method.
    Can anyone tell that what is the problem with it. for what reason this restriction exist?
    Thanks in advance

    Karanjit is right. Nested interfaces and enums both are implicitly static. And their Constants are always (also when defined in top level) implicitly static. As we can't have static types inside a method we can't define enum in a method.
    I read in "Sun Certified Programmer for Java 5 Study Guide" written by Bert Bates and Kathy Sierra that if we have following enum:
    enum CoffeeSize { BIG, HUGE, OVERWHELMING }then we can think of this enum as a kind of class, that looks something (but not exactly) like this:
    class CoffeeSize {
         public static final CoffeeSize BIG = new CoffeeSize("BIG", 0);
         public static final CoffeeSize HUGE = new CoffeeSize("HUGE", 1);
         public static final CoffeeSize OVERWHELMING = new CoffeeSize(
                   "OVERWHELMING", 2);
         public CoffeeSize(String enumName, int index) {
              // stuff here
         public static void main(String[] args) {
              System.out.println(CoffeeSize.BIG);
    }Also see this code which is compilable:
    class HaveEnum {
         enum Colours {
              BLACK, WHITE
         static class StaClass {
              public static final StaClass sc = new StaClass();
         class InstClass {
              public final InstClass ic = new InstClass(); // can't be declared static
    public class General {
         public static void main(String[] args) {
              HaveEnum.StaClass hes = HaveEnum.StaClass.sc; // (1)
              HaveEnum.Colours col = HaveEnum.Colours.BLACK; // (2)
              HaveEnum he = new HaveEnum(); // (3)
              HaveEnum.InstClass hei = he.new InstClass().ic; // (4)
    }We can have enum constant BLACK in General class (at (2)) in similar way as StaClass constant sc (at (1)). If enum Colours were instant type like InstClass inner class then for having BLACK constant in General we would have to first instantiate HaveEnum class (like at (3)) and then using its object reference we could get BLACK constant (something like this) (like for InstClass at (4)):
    HaveEnum he = new HaveEnum();
    HaveEnum.Colours col = he.new Colours().BLACK;Note that main() method will throw StackOverflowError at runtime because (4) tries to recursively create another InstClass object.

  • Variables declared in static methods

    Hi,
    I've got a question. Are variables (primitive and Objects) declared inside
    static methods stored in a same memory space or are the stored separately?
    I'm creating a helper class that contains static methods that canno be placed in any object in my object map.
    For example
    public static String SampleMethod(String passedString)
    String str = new String(passedString);
    ...do some more processing and sleeping
    return str;
    Let's say Object1 and Object2 make a call to SampleMethod. Object1 passes "Object1" and right before the Object1's SampleMethod returns str, Object2 makes a call passing "Object2". What would be the value of str for Object1's SampleMethodCall?
    Thanks :)

    If speaking about class members, then static members are stored in one place and are properties of the class, when non-staic members are stored in an object's memory and a properties of an object.
    However in your sample it's not the case.
    Local variables of a method are most likely allocated on registers or on stack (thus being rather properties of the call to a method).
    Thus in your case calls to SampleMethod done by Object1 and Object2 simultaneously (if you managed to do this in two different threads) will use different memory (most likely in threads' own stacks).
    As for calls to "new String" inside your method, the new string memory will be allocated dynamically each time the new operator is called, thus producing two different objects. The references to them will be stored in two local variables of two independent calls.
    Finally, Object1 will get a copy of "Object1" and Object2 will get a copy of "Object2", as expected.
    Vit

  • Why we should not declare a business method as final in EJBs - THX

    Why we should not declare a business method as final in EJBs - THX

    'cause it makes no sense at all and doesn't boost performance.
    regards
    dan
    scpj2

  • Error - No defining declaration found for implementing declaration of partial method

    Hi,
    I am quite  new to c# and using lightswitch to create a webform. However, I have to write a code as per the webform logic and requirement and now getting error on this part -
    partial
    voidgridDeleteSelected_Execute(StringID)
    The error is -  No defining declaration found for implementing declaration of partial
    method
    Could someone please tell how this error can be resolved ? Please find the code attached below.
    Thanks.
    using System;
    using System.Linq;
    using System.IO;
    using System.IO.IsolatedStorage;
    using System.Collections.Generic;
    using Microsoft.LightSwitch;
    using Microsoft.LightSwitch.Framework.Client;
    using Microsoft.LightSwitch.Presentation;
    using Microsoft.LightSwitch.Presentation.Extensions;
    namespace LightSwitchApplication
    public partial class EditableServicesGrid
    partial void gridDeleteSelected_CanExecute(ref bool result)
    partial void gridDeleteSelected_Execute(String ID)
    if (!string.IsNullOrEmpty(ID))
    string sqldelete = "Update services set DELETED_FLG = 'Y' WHERE ID IN ( " + ID + ")";

    partial
    voidgridDeleteSelected_Execute(StringID)
    The error is -  No defining declaration found for implementing declaration of partial
    method
    Could someone please tell how this error can be resolved ? Please find the code attached below.
    Could you explanation what your requirement is? detailed information is necessary.

  • Global Variable Declaration in ProcessRequest Method

    Hi All,
    i need to declare a variable(Global) in Process request Method and then i need to pass this variable value in ProcessRequest Method of Another Page.
    it is possible to declare a Global Variable in ProcessRequest Method.
    Process Request Method:
    if(pageContext.getSessionValue("varBatchID")!=null && pageContext.getSessionValue("varCustomerID")!=null)
    System.out.println("Second Else From Drill Down");
    String strCustID=pageContext.getSessionValue("varCustomerID").toString();
    String strBatchID=pageContext.getSessionValue("varBatchID").toString();
    System.out.println("CustomerID:"+strCustID);
    System.out.println("strngBatchID:"+strBatchID);
    Serializable[] parameters={strCustID,strBatchID};
    OAMessageStyledTextBean oamessagestyledtextbean=(OAMessageStyledTextBean)createWebBean(pageContext,"strCustID");
    oamessagestyledtextbean.setText(pageContext,"strCustID");
    pageContext.getApplicationModule(webBean).invokeMethod("backTocusttrxn",parameters);
    pageContext.removeSessionValue("varCustomerID");// Here i need to close this session Value and at the same time i need to pass this session value to another page PR Method. SO For that i need to Declare a variable(Global) and pass that variable value to another page.
    pageContext.removeSessionValue("varBatchID");
    Could you please any one give me the solution for this.
    Thanks,
    Mallik.

    Hi ,
    Create transaction variable and pass your value into that and get the same in other CO using below code,
    pageContext.putTransactionValue("IrcSelectedPersonId",value)
    pageContext.getTransactionValue("IrcSelectedPersonId");
    Regards,
    Vijay Reddy.

  • Deprecated Thread Methods

    My organization has recently come from the Microsoft world into the J2EE world. In .Net, Microsoft has an abort method on threads that is similar to the Java's stop method. Unfortunately, the stop method has been deprecated.
    While I have read the information on why this method is dangerous, I don't understand why the method has been removed. If I have a situation that warrants killing a thread (such as in the case of an application server that hosts other threads of execution), why remove it from the platform? While I agree with Sun's article on seeking out alternative methods, there are still exceptions where a thread just needs to be interrupted so that it can get out of a deadlock, endless loop or blocking I/O.
    Since the stop method is deprecated, is there an equivalent VM call that I can interface from native code?
    I must say that I feel a bit like I'm being mothered by Sun.

    From your comments, you make a strong argument that suggests there's no need for a VM-level stop function.
    This puzzles me because operating systems implement kill methods to terminate rogue processes, yet they remain efficient and manage to keep things clean. Granted, multiple processes don't generally share memory structures but certainly the OS, on their behalf, shares memory structures. I'm puzzled as to why similar desires/features aren't present in the JRE.
    Regardless, short of running multiple JRE instances, each managing just one piece of work, the current deprecated status of the stop method renders Java without the ability to stop something that's gone wild unless the application is specifically pre-programmed to anticipate this behavior. (Of course that's a bit of a catch 22 in and of itself but...)
    There is also a subscription to the notion that my company or company x can write perfect software that never hangs a Java-based application server. I feel that this is impractical -- especially when what businesses ask of IT continues to get more complex.
    At this point perhaps it's fair to reveal the underlying reasons for my up-to-now, hypothetical questions. In my situation, company x is actually Sun. They failed to expose a socket timeout on their implementation of HTTPUrlConnection. I suppose that pretty much removes the luster from the argument that I, or anyone else, can write perfect software when the inventors of Java are themselves, imperfect. Of course, like you said and the JDK documents, the stop method will not abort a blocking socket read anyway (...although there's no reason why it couldn't except for more flawed design decisions...)
    I've certainly investigated alternative packages but I'm just chasing a moving target. HTTPUrlConnection today, class x tomorrow. That's why I was wanting something at the framework level to provide a trap door so that recovery without terminating the JRE is possible.

  • How do I declare a native method outside of the main class?

    Hi
    This is a JNI particular question.
    I am having a problem with generating the header .h file after executing javah. The file is generated correctly but is empty under certain circumstances.
    This is the 'empty file:
    =================
    /* DO NOT EDIT THIS FILE - it is machine generated */
    #include <jni.h>
    /* Header for class gui_GuiMain */
    #ifndef Includedgui_GuiMain
    #define Includedgui_GuiMain
    #ifdef __cplusplus
    extern "C" {
    #endif
    #ifdef __cplusplus
    #endif
    #endif
    This is what it should look like:
    =========================
    /* DO NOT EDIT THIS FILE - it is machine generated */
    #include <jni.h>
    /* Header for class gui_GuiMain */
    #ifndef Includedgui_GuiMain
    #define Includedgui_GuiMain
    #ifdef __cplusplus
    extern "C" {
    #endif
    * Class: gui_GuiMain
    * Method: getValueOIDTestMIB
    * Signature: ()V
    JNIEXPORT void JNICALL Java_gui_GuiMain_getValueOIDTestMIB
    (JNIEnv *, jobject);
    #ifdef __cplusplus
    #endif
    #endif
    The header file becomes "empty" when the native function getValueOIDTestMIB is declared in a different class than what my main() function is declared in.
    For example something like this will work:
    class Main
    public native void getValueOIDTestMIB
    static {
    System.loadLibrary("libsnmp++");
    //............some more functions etc.............
    public static void main(String[] args)
    //............some more stuff...........................
    But when I declare this:
    public native void getValueOIDTestMIB
    static {
    System.loadLibrary("libsnmp++");
    outside the class, in another class within the same package, nothing happens.
    I am probabily doing something stupid. Can somebody help or give me some guidance to where I should look. I come from a C++ background, not a guru in Java.
    Thanks

    You need to run javah and give it as a parameter the full class name of the class which contains the native methods.
    For example (if your class is called A and its package is a.b.c)
    javah -jni a.b.c.A

  • I need a solution for the deprecated readLine() method .

    import java.io.*;
    import java.net.*;
    class UC {
    public static void main(String args[]) throws Exception
    DataInputStream inFromUser = new DataInputStream(System.in);
    DatagramSocket clientSocket = new DatagramSocket();
    InetAddress IPAddress = InetAddress.getByName("hostname");
    byte[] sendData = new byte[1024];
    byte[] receiveData = new byte[1024];
    while(true)
    String[] sentence = inFromUser.readLine(); /* It says the readLine() method is deprecated. what is the solution for this? */
              sentence.getSubstringBytes(sentence,0, sentence.length(), sendData, 0);
    //sentence.getBytes(0, sentence.length(), sendData, 0);
    DatagramPacket sendPacket = new DatagramPacket(sendData, sendData.length, IPAddress, 9876);
    clientSocket.send(sendPacket);
    DatagramPacket receivePacket
    = new DatagramPacket(receiveData, receiveData.length);
    clientSocket.receive(receivePacket);
    String modifiedSentence =
    new String(receivePacket.getData());
    System.out.println("FROM SERVER:" + modifiedSentence);
         public void getSubstringBytes(String sentence,int space,int Size,byte[] sendData,int space)
                   byte[] bytes=sentence.getBytes();
                   System.arraycopy(bytes,0,sendData,0,sentence.length()-0);
    }

    Sorry, It should be the BufferedReader , not BufferedInputStream.

  • Declared Web Dynpro method's javadoc not updating

    Hello all,
    I declared a method in a custom controller, and changed the Javadoc to something more meaningful than the usual "declared method.". Now I'm trying to call this method from another controller. That in itself works fine, but when using NWDS' auto-complete feature, I still see the old, initial Javadoc.
    I've tried building the project, reloading+rebuilding it, I even tried restarting the entire NWDS, all without success. Am I missing something? What does it take to get the NWDS to use the updated javadoc?
    Thanks in advance,
    Kars.

    Hi,
    if i am not wrong the JDK need to support the new java doc, mean to say are you using right jdk version for that. Coz javadoc.exe need to support.
    plz give a try to this setting:-
    Go to window-> preferences->jav->javadoc->javadoc command in that set the path for the javadoc.exe.
    Hope this may help you.
    Regards,
    Deepak

  • PDFDocMerger API Deprecated mergePDFDocs Method

    All,
    We are trying to use the supplied PDFDocMerger API and running into some issues. When I look at the documentation it states that the mergePDFDocs method is deprecated; I do not see a replacement method. Is the documentation lacking updates and there is a new method to use or does the API simply not work anymore? I would really appreciate any insight into this issue as I need to merge PDFs and don't want to go outside the supplied API's.
    Thanks in Advance,
    Josh

    Ok, just looked over the documentation one more time and realized process() replaces it.
    Edited by: user11201963 on Aug 7, 2009 9:25 AM

  • Wildcards in type declarations or only methods?

    Can you declare wildcards in type declarations such as:
    public class ListManager<List<?>> {
    }When I try this, I get the following compiler errror:
    C:\dev\hcj\tiger\src>c:\j2sdk1.5.0\bin\javac -source 1.5 oreilly/hcj/tiger/*.java
    oreilly/hcj/tiger/ListManager.java:21: > expected
    public class ListManager<List<?>> {
                                 ^
    oreilly/hcj/tiger/ListManager.java:31: '{' expected
    ^
    2 errorsWhat am I doing wrong [if anything]?
    TIA
    -- Kraythe

    public class ListManager<List<?>> {
    }When I try this, I get the following compiler errror:Hmm .. I was thinking about this. .. What i was trying to declare was a class that would use as a parameter any declaration of a List. So what I want is a class that will take List<Integer> and List<String> and so on. So the result would be to use it like this:
    public void someMehtod() {
        ListManager<List<String>> strListMger = ...
        ListManager<List<Integer>> strListMger = ...
    }So if not with the wildcard, how is this accoplished (if it can be accomplished at all).
    I would also like to do something like:
    public class ListManager<Type extends List<?>> {
    }In this manner I would at least have access to the type. Except the extends is a misnomer since i want type to be any List<> type.

  • Unable to declare Task T method in Interface

    I have a class Employee which inherits from abstract class
    MyAbstractClass<T>
    Employee : MyAbstractClass<Employee>, IEmployee
    There is a method on abstract class which operates on runtime type T supplied to abstract class :
    public async Task<T> AddSomething()
    T x = SomeAsyncMethod();
    return T ;
    The problem is how can I expose this method on IEmployee as the type T is decided at run time , I tried following but it did not work , please suggest
    public interface IEmployee
    // Task<Type> AddSomething();
    // Task <object> AddSomething();

    This is a duplicate of your
    previous post. Could you delete this question and update the other question if there was something missing?
    -Igor

  • Error with declaring a method with array variable

    Hi,
    I had implemented this:
    import java.awt.*;
    import javax.swing.*;
    public class Oefening1
         public static void main(String args[])
              int array[]= new int[10];
              int getal;
              JTextArea outputArea = new JTextArea();
              Container container = getContentPane();
              container.add(outputArea);
              public void invoerRij(int array[10])
                   output +=" ";
                   for(int counter = 0; counter <10;counter++){
                        output +="Geef een getal in"+"\n"+array[counter]+"\n";
                        outputArea.setText(output);
    I had comilated this code while the compiler gave errors like these:
    A:\Oefening1.java:15: illegal start of expression
              public void invoerRij(int array[10])
    ^
    A:\Oefening1.java:24: ';' expected
    ^
    A:\Oefening1.java:12: cannot resolve symbol
    symbol : method getContentPane ()
    location: class Oefening1
              Container container = getContentPane();
    ^
    3 errors
    Tool completed with exit code 1
    Now i have read my book and finded out that the declaration of a method always starts with public.
    Can anyone halp me solving these probs? Thanks
    Crazydj1

    The problem is that you didn't close the previous method definition.
    Compiler error messages (in any language) often mistakenly report false errors on perfectly valid code immediately following the actual error.
    When you post code on these forums, please wrap in in &#91;code]&#91;/code] tags.

  • Deprecated methods

    The following method has been deprecated. Does anyone know what it is replaced with? Also, is there a list of what has been deprecated and what the replacement method is and how to implement the replacement method?
    •     Warning(1886,24): setSelectedItemToStringConverter(oracle.bali.inspector.editor.ToStringConverter) in oracle.bali.inspector.PropertyEditorFactory2 has been deprecated
    Thanks

    Hi,
    such documentation should be part of the JavaDoc unless the developer deprecating the method forgot to mention it. There is no other documentation than that to provide the information. The JavaDocs say:
    * @deprecated use {@link #setEditorComponentInfo(EditorComponentInfo)} instead.
    So its in the same class
    Frank
    ps.: Hope you know what you do because I am not sure bali classes are open for public consumption

Maybe you are looking for

  • Mac book keeps restsrting before it boot up

    AFTER UPGRADE TO MAVERICS MAC BOOK PRO TAKES MORE TIME TO BOOT UP AND KEEPS RESTARTING

  • 8800 battery drains unpredicta​bly

    Hi, my 8800 seems to be fine on a full charge for a few hours, then it will drop charge quickly over an hour or two, down to 50% or less.  Sometimes, overnight after a full charge in the afternoon, the 8800 is dead in the morning.  All it receives ov

  • Not include digital booklets in smart playlists?

    I don't know if there's any way to do this, but I have smart playlists created, which are based on certain genres, or only include certain artists - but they always include the digital booklets from these artists, and I can't just get rid of the digi

  • Moving a user back and forth between different computers.

    My wife and I both have a MBP. When we are travelling together we like to take only one computer and would like to be able to move one user to the one computer we take, so we can both log in to our own desktop etc. When coming home we would than migr

  • Can I create recovery disks using my laptop HD as external drive?

    My Thinkpad T420 hard drive crashed in a really bad way. I can't load windows (7) and windows repair says it can't help me. I removed my hard drive and put it in a usb enclosure and connected it to a different pc. I can see the recovery folder/drive