From alaamurad at gmail.com Mon Mar 8 00:04:05 2010 From: alaamurad at gmail.com (ALAA MURAD) Date: Mon, 8 Mar 2010 11:04:05 +0300 Subject: Static this ! Message-ID: <63bb12331003080004h3b2843c6i29ff7c44619b774@mail.gmail.com> Hi everyone , This is my first proposal to Java open JDK , so I'm not sure I'm in the right place. I propose that Java will include a static equivalent to '"this" keyword. like this "this#" to return the class is static scope. I had this needs because of the logger as every time you want to use the static class inside the class itself you need to hard code that. Example : private static Logger logger = Logger.getLogger("com.Customer"); <-- hardcoded class name ! // or private static Logger logger = Logger.getLogger(Customer.class.getName()); <-- Still hardcoded class public static void getCustomerName(){ ... logger.log(...); } As you can see, that I had to hardcoded the "com.Customer", if my logger was non-static , it would have been easy and I would just did the following: private static Logger logger = Logger.getLogger(this.getClass().getName()); But I'm proposing ? private static Logger logger = Logger.getLogger(this#.class.getName()); <-- this way you can copy & paste that at any class, right ? As you can see "this#" will return my class in a static scope. I came to this problem because I had to copy & paste (private static Logger logger = Logger.getLogger("Some Class Name ...");) and rewrite the class name !!! into hundreds of classes. Best Regards, Alaa Murad -- Alaa Murad E-Service Development Department Bank ALJazira Website: http://www.alaamurad.com Email: alaa at alaamurad.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.openjdk.java.net/pipermail/compiler-grammar-dev/attachments/20100308/d4e8c37c/attachment.html