<div dir="ltr">Hi everyone , <br><br>This is my first proposal to Java open JDK , so I'm not sure I'm in the right place.<br><br>I propose that Java will include a static equivalent to '"this" keyword. like this "this#" to return the class is static scope.<br>
<br>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. <br><br>Example :<br><br>private static Logger logger = Logger.getLogger("com.Customer"); <-- hardcoded class name !<br>
// or private static Logger logger = Logger.getLogger(Customer.class.getName()); <--
Still hardcoded class <br><br>public static void getCustomerName(){<br>...<br>logger.log(...);<br>}<br clear="all"><br>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:<br>
<br><br>private static Logger logger = Logger.getLogger(this.getClass().getName());<br><br>But I'm proposing ?<br><br>private static Logger logger = Logger.getLogger(this#.class.getName()); <-- this way you can copy & paste that at any class, right ? <br>
<br><br><br>As you can see "this#" will return my class in a static scope. <br><br>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.<br>
<br>Best Regards,<br>Alaa Murad<br><br><br>
<br><br><br>-- <br>Alaa Murad<br>E-Service Development Department<br>Bank ALJazira<br>Website: <a href="http://www.alaamurad.com">http://www.alaamurad.com</a><br>Email: <a href="mailto:alaa@alaamurad.com">alaa@alaamurad.com</a><br>
<br>
</div>