Hello all, I recently came across the following piece of code in https://svn.apache.org/repos/asf/hive/trunk/contrib/src/java/org/apache/hadoop/hive/contrib/serde2/s3/S3LogDeserializer.java :
*static* *{* StackTraceElement*[]* sTrace *=* *new* Exception*().*getStackTrace*();* sTrace*[*0*].*getClassName*();* *}* * * One question: What is this used for? >From what I can tell its dead code. Also there is similar code at http://javasourcecode.org/html/open-source/hive/hive-0.9.0/org/apache/hadoop/hive/serde2/TestSerDe.java.html : static { StackTraceElement <http://javasourcecode.org/html/open-source/jdk/jdk-6u23/java/lang/StackTraceElement.java.html>[] sTrace = new Exception <http://javasourcecode.org/html/open-source/jdk/jdk-6u23/java/lang/Exception.java.html>().getStackTrace(); String <http://javasourcecode.org/html/open-source/jdk/jdk-6u23/java/lang/String.java.html> className = sTrace[0].getClassName(); try { SerDeUtils.registerSerDe(shortName(), Class.forName(className)); // For backward compatibility: this class replaces the following class. SerDeUtils.registerSerDe("org.apache.hadoop.hive.serde.TestSerDe", Class .forName(className)); } catch (Exception <http://javasourcecode.org/html/open-source/jdk/jdk-6u23/java/lang/Exception.java.html> e) { throw new RuntimeException <http://javasourcecode.org/html/open-source/jdk/jdk-6u23/java/lang/RuntimeException.java.html>(e); } } Which seems to do something, however I can't tell the difference between the above and simple hard coding the class name; other than you can blindly copy paste this code without changing that hard coded class name? Any help in understanding this? Thanks, Brandon