(RFE) Intoduce a new keyword Self

The Self keyword represent the type of the current Class.
Example :
class A {
public static void main(String[] args) {
System.out.println(Self.class); // print A
Note that It's not equivalent to this.getClass().
The Self keyword permit to resolve two problems :
1) methods of class from API create before 1.5 that return an Object like clone()
in Date couldn't return a Date (or the current class) because it could exist
a class that inherits from Date a redefine clone().
Usage as a type :
- Self could not be used as a parameter type.
- Seft could be used as a return type.
Rules during overriding test :
- Self is a subtype of Self
- Self is equals to the greater supertypes in the class hierachy that
defined the method.
class Object {
Self clone() {...}
class Date extends Object {
Self clone() {....} // ok, Self is a subtype of Self
class MyLegacyDate extends Date {
Object clone() {...} // ok, Self is equals to Object
2) there is no way to get the current class object (Class), to initialize a logger
by example. I propose the notation "Self.class".
R�mi Forax

I choose the option 3:
the code : > Bar bar=bar.getRubbed(); won't compile because getRubbed() return a Foo. (a Self from Foo) .What about
<T extends Bar> void rub(T t) {
    Bar b = t.getRubbed()
Maybe Bar should be declared abstract because it does not implement Bar getRubbed() ...
About the clone() method, it should be noted that (according to the JavaDocs) it not an absolute requirement that
o.getClass() == o.clone().getClass().
Therefor, using Self as the return type of clone() would not be appropriate.

Similar Messages

  • Is there a way to create new keywords that are NOT subcategories of other keywords in PSE Organizer?

    I would like to create a new keyword in the Organizer that is not a subcategory of OTHER.
    Specifically I would like to create the keyword PETS, which could in turn have subcategories of different pets.
    Currently the only way I can do this is to create PETS as a subcategory of OTHER which I would prefer not to do.
    If this can be done, please advise me (in detail) how this can be done.
    I am using PSE13 with Windows 8.1 (64-bit) as my OS.
    Thank you, in advance, for your assistance.

    Hi,
    Have you tried selecting New Category from the drop down list?
    Brian

  • How to reference a class without using the new keyword

    I need to access some information from a class using the getter, but I don't want to use the new keyword because it will erase the information in the class. How can I reference the class without using the new keyword.
    ContactInfo c = new ContactInfo(); // problem is here because it erases the info in the class
    c.getFirstName();

    quedogf94 wrote:
    I need to access some information from a class using the getter, but I don't want to use the new keyword because it will erase the information in the class. How can I reference the class without using the new keyword.
    ContactInfo c = new ContactInfo(); // problem is here because it erases the info in the class
    c.getFirstName();No.
    Using new does not erase anything. There's nothing to erase. It's brand new. It creates a new instance, and whatever that constructor puts in there, is there. If you then change the contents of that instance, and you want to see them, you have to have maintained a reference to it somewhere, and access that instance's state through that reference.
    As already stated, you seem to be confused between class and instance, at the very least.
    Run this. Study the output carefully. Make sure you understand why you see what you do. Then, if you're still confused, try to rephrase your question in a way that makes some sense based on what you've observed.
    (And not that accessing a class (static) member through a reference, like foo1.getNumFoos() is syntactically legal, but is bad form, since it looks like you're accessing an instance (non-static) member. I do it here just for demonstration purposes.)
    public class Foo {
      private static int numFoos; // class variable
      private int x; // instance varaible
      public Foo(int x) {
        this.x = x;
        numFoos++;
      // class method
      public static int getNumFoos() {
        return numFoos;
      // instance method 
      public int getX() {
        return x;
      public static void main (String[] args) {
        System.out.println ("Foo.numFoos is " + Foo.getNumFoos ());
        System.out.println ();
        Foo foo1 = new Foo(42);
        System.out.println ("Foo.numFoos is " + Foo.getNumFoos ());
        System.out.println ("foo1.numFoos is " + foo1.getNumFoos ());
        System.out.println ("foo1.x is " + foo1.getX ());
        System.out.println ();
        Foo foo2 = new Foo(666);
        System.out.println ("Foo.numFoos is " + Foo.getNumFoos ());
        System.out.println ("foo1.numFoos is " + foo1.getNumFoos ());
        System.out.println ("foo1.x is " + foo1.getX ());
        System.out.println ("foo2.numFoos is " + foo2.getNumFoos ());
        System.out.println ("foo2.x is " + foo2.getX ());
        System.out.println ();
    }

  • RV120W- How to create new unique self-signed certificate?

    Hello,
    how to create new unique self-signed certificate on RV120W? I can create request for singning by external CA, but I cannot create new unique self-signed certificate itself. Any idea? Did I miss something? Many thanks!
    Abudef

    So basically RV120W does not support self-signed certificate? It only allows to generate private key and certificate signin request. There is no chance to replace default generic ssl/vpn certifice within router itself? Could you please give me an advice, how to sign that request by some "CA"? I mean no commercial CA, I need something free running under Windows os. Many thanks!

  • Cannot Resolve Symbol on New Keyword

    I done something stupid, but what?
    I've defined a new class, in a new file that shares a package but cant instantiate it because the 'new' keyword apparently cant be resolved.
    In the Main file I have ( last line shows the problem )..
    package myprojects.a2a;
    import java.awt.*;
    import java.awt.event.*;
    class A2A extends Frame {
         public A2A() {
              addWindowListener(new WindowAdapter() {
                   public void windowClosing(WindowEvent e) {
                        dispose();
                        System.exit(0);
         public static void main(String args[]) {
              System.out.println("Starting A2A...");
              A2A mainFrame = new A2A();
              mainFrame.setSize(400, 400);
              mainFrame.setTitle("A2A");
              mainFrame.setVisible(true);
              clsWeapon a = new clsWeapon("Sword");
    and in the clsClass file I have...
    public class clsWeapon {
         int ShortRange;
         int MediumRange;
         int LongRange;
         StringBuffer WName;
         int Value;
         int CloseCombatValue;
         int UnionPointsValue;
         int ConfedPointsValue;
         public clsWeapon(){
         public clsWeapon(String args[]) {
              if(args[0]=="Sword"){

    clsWeapon a = new clsWeapon("Sword");clsWeapon a = new clsWeapon(new String[] {"Sword"});

  • IPhoto 8 and Make New Keywords

    Folks;
    I don't yet have iPhoto '08. I was wondering if it has support for:
    ...make new keyword name "XYZ"
    Can anyone verify this?
    It baffles me why this feature has been missing for so long!
    Steve

    Keywords are in the current (iLife '08) dictionary, and I vaguely recall it being in older versions, too.
    Maybe you don't know how to access them.
    Since photos may have multiple keywords, and each keyword has a name and a value, you can't just 'set keyword'. Keywords are elements of a photo, not a property.
    Consequently you manipulate them using something like:
    Get:
    tell application "iPhoto"
    get every keyword of photo 1
    end tell
    Set:
    tell application "iPhoto"
    tell photo 1
    make new keyword at end of keywords with properties {name: "my new keyword"}
    end tell
    end tell
    in other words, to create a new keyword you have to be specific, both about where to create it (at the end of the list of keywords associated with the current photo or album) and what data it should have.

  • Bridge freezes after adding a new keyword & wont allow the keywords to work

    when I am in bridge and working away - ill create a new keyword -so select new keyword, type in the name and then hit enter etc... when I go the new keyword which I have just created - it wont allow me to check the box (so tick it & allocate it to an image OR any image) - I must re-start bridge and then it works...
    is anyone else having this issue?
    im using Bridge CS 3 - 2.1.1.9
    thanks in advance!
    amy

    Yes, where you click is critical, and it varies from word to word sometimes, seems to be a little to right of where you expect.
    According the the knowledgebase, compacting cache gets rid of files that are not associated with anything anymore.
    CS2 used all 3 (Ctrl, Alt, Shift) keys, but CS3 and 4 can use just the Ctrl key to reset preferences.

  • Bridge New keywords are not shown on startup

    Hi,
    I have some images, (in folder X) which I tagged with NEW keywords I created.
    When I reopen bridge, these new keywords are not shown by default.
    In ordert to see the above keyword, in the keyword panned, i have to navigate to folder X.
    Is this a normal behavoure for bridge?
    Is there a way to show all the new user ekywords on startup?
    I am working with bridgew CS6, win7 x64.

    I have some images, (in folder X) which I tagged with NEW keywords I created.
    When I reopen bridge, these new keywords are not shown by default.
    I think you use Photoshop or other application to add keywords?
    The Bridge keyword panel offers you the option to create your own keyword list with parent keywords and sub keywords in it. You can also import an existing keyword list using the little menu icon top right in the keyword panel. And export for back up or new version and/or computer.
    If you have Bridge pointed to a file the keywords do show in the list but as italic instead of normal. This means the file has a keyword that is not in the list of Bridge itself. You can make it persistent by using right mouse click on the keyword and after this it shows always in the panel regardless if you point to the file with the keyword or not.
    So if you want to make the most of your search function and using keywords you should start to build your own list. This can be done in Bridge but also in a simple text application. Just try to add some different keywords with a couple of sub keywords to the metadata panel and when done use the export function. This provides you with a good example of how to make your own list in a text application that you then cam import again.
    Off course before staring to create a long list in a text application be sure to start with a short list and see if importing succeeds…

  • Need help understanding NEW keyword

    I can create a string array a couple of different ways.
    Method one:
          Dim i As Integer
          Dim sarr1(4) As String
          For i = 0 To sarr1.Length - 1
             sarr1(i) = "12345"
          Next
    Method two:     
         Dim sarr2 = New String() {"12345", "12345", "12345", "12345", "12345"}
    Are these two methods equivalent?
    If I try to declare the arrays by either of the following methods, I get errors.
    Method three:
           Dim sarr3 As New String(4)
           error: Value of type 'Integer' cannot be converted to '1-dimensional array of Char'.
    Method four:
            Dim sarr4(4) As New String()
            error: Arrays cannot be declared with 'New'.
    Why isn't method four equivalent to method two except for the initialization?     
    Regards, Mike

    Method 1 and 2 are basically the same. We didn't always have array initializers in the language (method2). That has only been around the past couple of years. Prior to that you had to do some sort of loop to initialize the array like your method 1. Method
    2 was added just to make it easier from a syntax point of view. It certainly looks cleaner and you can read one line of code and know what the array is and what its contents are.
    The reason method 2 and method 4 are different is because in method 2, you are performing an assignment. It is using type inference so it might not be as clear, but method 2 could be fully written out as
    Dim sarr2() As String = New String() {"12345", "12345", "12345", "12345", "12345"}
    In which case you can see that it isn't really using the new keyword for the declaration, but for the right side instantiation of a string array, which is then assigned to the declared array variable.
    Matt Kleinwaks - MSMVP MSDN Forums Moderator - www.zerosandtheone.com

  • How do constructors work without new keyword?

    Hi guys,
    I'm developing UI5 applicaitons.
    I use jsview to build the UI.
    In one of the pages, I need a dialog to popup.
    So define a dialog in createContent funciton of the view:
            var dialog = new sap.m.Dialog(this.createId('idDlg'), {
                content: [
                    new sap.m.Input()
                beginButton: new sap.m.Button({
                    text: 'OK',
                    press: [oController.onOKPressed, oController]
                endButton: new sap.m.Button({
                    text: 'Cancel',
                    press: [oController.onCancelPressed, oController]
    But afterwards, I find there's no need to declare a variable to store the dialog instance, so I remove it, it still works:
            new sap.m.Dialog(this.createId('idDlg'), {
                content: [
                    new sap.m.Input()
                beginButton: new sap.m.Button({
                    text: 'OK',
                    press: [oController.onOKPressed, oController]
                endButton: new sap.m.Button({
                    text: 'Cancel',
                    press: [oController.onCancelPressed, oController]
    And after that, I'm using jslint to check code statically, lint tells me do not use new for side effects, so I remove the new keyword, it still works:
            sap.m.Dialog(this.createId('idDlg'), {
                content: [
                    new sap.m.Input()
                beginButton: new sap.m.Button({
                    text: 'OK',
                    press: [oController.onOKPressed, oController]
                endButton: new sap.m.Button({
                    text: 'Cancel',
                    press: [oController.onCancelPressed, oController]
    So I'm wondering why the constructor still works even without new?
    what will the above code do?
    And what's the difference between with and without new?
    Regards,
    Aaron.

    Let me give you a simle example. say you've a constructor
    var Constructor = function(name){
         this.name = name;
    You create an instance of constructor as,
    var oInstance = new Constructor("My Instance);
    the Constructor will get executed with the context 'this' as 'oInstance'.
    oInstance.name // My Instance
    var oInstance = Constructor("My Instance);
    the Constructor will get executed with the context 'this' as 'window'.
    oInstance.name // Type Error
    window.name // My Instance

  • The new keyword and the newInstance method

    Hi friends
    Can any one tell me the difference between creating an instance of a class by the new keyword and creating an instance of a class by the newInstance method in java.
    Also how do I decide which method to use for a given condition?

    Hi friends
    Can any one tell me the difference between creating an
    instance of a class by the new keyword and creating an
    instance of a class by the newInstance method in java.
    Also how do I decide which method to use for a given
    condition?Hello,
    in the todays java technology newsletter there was a interesting and useful task for the newInstance-method.
    You can compile any class at runtime and start this program with newInstance.
    If you want to develop your own IDE it would be very useful ;)
    import java.awt.*;
       import java.awt.event.*;
       import javax.swing.*;
       import java.io.*;
       import java.lang.reflect.*;
       public class RunIt extends JFrame {
         JPanel contentPane;
         JScrollPane jScrollPane1 = new JScrollPane();
         JTextArea source = new JTextArea();
         JPanel jPanel1 = new JPanel();
         JLabel classNameLabel = new JLabel("Class Name");
         GridLayout gridLayout1 = new GridLayout(2,1);
         JTextField className = new JTextField();
            JButton compile = new JButton("Go");
      Font boldFont = new java.awt.Font("SansSerif", 1, 11);
         public RunIt() {
           super("Editor");
           setDefaultCloseOperation(EXIT_ON_CLOSE);
           contentPane = (JPanel) this.getContentPane();
           this.setSize(400, 300);
           classNameLabel.setFont(boldFont);
           jPanel1.setLayout(gridLayout1);
           compile.setFont(boldFont);
           compile.setForeground(Color.black);
           compile.addActionListener(new ActionListener() {
             public void actionPerformed(ActionEvent e) {
               try {
                 doCompile();
               } catch (Exception ex) {
                 System.err.println(
                       "Error during save/compile: " + ex);
                 ex.printStackTrace();
           contentPane.add(jScrollPane1, BorderLayout.CENTER);
           contentPane.add(jPanel1, BorderLayout.NORTH);
           jPanel1.add(classNameLabel);
           jPanel1.add(className);
           jScrollPane1.getViewport().add(source);
           contentPane.add(compile, BorderLayout.SOUTH);
         public static void main(String[] args) {
           Frame frame = new RunIt();
           // Center screen
           Dimension screenSize =
             Toolkit.getDefaultToolkit().getScreenSize();
           Dimension frameSize = frame.getSize();
           if (frameSize.height > screenSize.height) {
             frameSize.height = screenSize.height;
           if (frameSize.width > screenSize.width) {
             frameSize.width = screenSize.width;
           frame.setLocation(
             (screenSize.width - frameSize.width) / 2,
             (screenSize.height - frameSize.height) / 2);
           frame.show();
         private void doCompile() throws Exception {
           // write source to file
           String sourceFile = className.getText() + ".java";
           FileWriter fw = new FileWriter(sourceFile);
           fw.write(source.getText());
           fw.close();
           // compile it
           int compileReturnCode =
             com.sun.tools.javac.Main.compile(
                 new String[] {sourceFile});
           if (compileReturnCode == 0) {
             // run it
             Object objectParameters[] = {new String[]{}};
             Class classParameters[] =
                         {objectParameters[0].getClass()};
             Class aClass =
                       Class.forName(className.getText());
             Object instance = aClass.newInstance();
             Method theMethod = aClass.getDeclaredMethod(
                                  "main", classParameters);
             theMethod.invoke(instance, objectParameters);
       }regards,
    Tim

  • Creating newinstance() vs new keyword

    Hi guys
    I have 2 questions
    1) i have been wondering about the different ways to instantiate an class, what the main difeerence between using a new keyword and newInstance() to instantiate an object, in what cases we use newInstance() or there any other ways to instantiate class apart from the above 2
    2) also what is private constuctor, what is main purpose, when do we use that in our program
    good answers are appreciated

    For question number2:
    You have the private constructor if you want to be
    sure you control how many objects are created.That's certainly not the only reason, and is not a reason in-and-of-itself.
    However, I'm not going to regurgitate the reasons - do some research on the net for "Java private constructor"

  • When I apply a new keyword, it deletes the previous

    I'm having a big problem in applying keywords to my images on bridge. I built a very extensive keyword tree and imported into bridge. When I try to aplly multiples keywords, my nightmare begins.
    First, it's extremely slow!
    Second and even worse, it writes the first keyword and to write the next one it deletes the previous! So, if  mark 10 differente keywords, I will end up only with the last.
    Am I doing something wrong? It must have a way to write ALL the keywords I want
    I'm using PS CS5 / Mac snow leopard.
    thanks in advance for any support!

    I think I didn't let it clear, but it is happening when I try to tag multiples images with multiples keywords at the same time.
    That is the way Bridge handles keywords, you select one and it needs to save it. Background saving is not a strong point of Bridge and there is your problem. As soon as it is saving the keywords and you start to add a new one it forgets the current task and starts with a new one.
    You can select a few keywords (I sometimes manage 5 or 6) in one go but as soon Bridge starts saving them to the files (the activity bar bottom left starts working) you must let it do its job until finished. I agree it could have been better but on the other hand you can select multiple files in one go and save it in one go, only not as much keywords as you would like to see in one time.
    First time saving often takes longer then the next ones, speed is obvious also depending on the file size, the bigger the file the longer the saving time

  • Keyword synonyms created as new keywords on import

    I just exported a large batch of images sized for submission to Alamy.  I had the images that were created by the export, imported back into Lightroom. 
    The problem.  All the keyword synonyms that were exported in the images, created new stand alone keywords in the keyword list - bad.
    I had all my keywords nicely organized into 12 neat groups.  Now I have a couple of hundred top level keywords because of the synonyms.
    Can this be prevented?
    thanks
    bill

    When a keyword is exported in an image, its synonyms are also exported by default.  Sincere there is no industry standard governing synonyms, LR exports them as top-level keywords.   And then when you reimport the exported image, those top-level keywords get added to your catalog.
    You can stop the synonyms from being exported by right-clicking their containing keyword in the Keyword List pane, selecting Edit Keyword Tag, and unchecking Export Synonyms.  Unfortunately, you'll have to do that with each keyword that contains synonyms -- there is no batch editing of keywords.

  • Spotlight can't see my new keywords!

    I've got some photos in iPhoto from vacations. They've got keywords of where they're from. If I type in "Myrtle" in spotlight, I get all of the pics from our trip to Myrtle Beach.
    I recently took a trip to Cunningham falls State Park in Maryland. I imported all of the pics into iPhoto and keyworded them. But if I go to spotlight, and type in "Cunningham" none of the pics come up. I checked the spelling. I waited a few days wondering if it takes time for the computer to realize it needs to index these. I tried a couple of other keywords for some other recently entered photos and no dice.
    This isn't a major issue, but still it should work! I can't say for sure if this started specifically when I updated to iLife 6 or not, because I can't remember precisely when I did that.
    I've tried the terminal trick found at the link below to no avail.
    http://discussions.apple.com/thread.jspa?messageID=1727966&#1727966
    Does anyone have any other suggestions on what may be causing it / how to fix it?
    Thanks,
    Dan P.

    HI Dan,
    I was just searching through the forum and saw your post. I just got the new 24" iMac for Christmas and after migrating everything over I noticed that Spotlight was not finding my keyword photos in iPhoto. I tried every trick in the book found in these forums and nothing worked. I have iPhoto Library Manager on my computer and found that it has a command to make iPhoto reindex a library. It worked like a charm! Within minutes, Spotlight found every photo in the library with my keyword search.
    iPhoto Library Manager
    iPhoto Library Manager documentation

Maybe you are looking for

  • Content viewer app ipad space usage

    I am using the Adobe Content Viewer app on the iPad for DPS. The four apps/folios I have downloaded in the viewer are 7mb, 195mb, 634mb and 486mb (1.2GB). But when I go to my iPad Settings/Usage it says the content viewer app is using 6.5GB in total.

  • Frozen screen on imac 20"

    hello, i installed diablo2 on my comp yesterday, it worked fine for me. a lil jerky when in a crowd of monsters. anyhow my friend was playing while i left the room. when i came back he said the comp froze when he tried to save and exit diablo2. i tri

  • Inserting HTML in JEditorPane

    Extremely frustrating trying to work with the HTML editing model (JEditorPane - content type text/html). I am using 1.4.2_06. Tying some basic actions to buttons or keystrokes is no problem (eg bold, italic etc.) but the most NB things like being abl

  • RV325 System Log Entries - Kernel - kernel: wrong ip[0],not_list[0]

    Hello, I have a RV325 Router. Entries in the System Log are mysterious to me and all my search results and reading are not relevant. The Event-Type is - "Kernel", and the Message is "kernel: wrong ip[0],not_list[0]" The Log entries occur every few mi

  • Character length of an editable fields

    hi frnz,    I have created an editable field in an ALV report.My client wants the character length of this editable field as 1000.I have made the data type as 'STRINGS' and length as '1000', but still in this editable field i am able to feed only upt