{"id":210,"date":"2004-12-10T18:45:36","date_gmt":"2004-12-11T00:45:36","guid":{"rendered":"http:\/\/www.mooreds.com\/wordpress\/?p=210"},"modified":"2008-04-23T07:18:05","modified_gmt":"2008-04-23T13:18:05","slug":"useful-tools-javap","status":"publish","type":"post","link":"https:\/\/www.mooreds.com\/wordpress\/archives\/210","title":{"rendered":"Useful tools: javap"},"content":{"rendered":"<p>javap lets you examine java class files and jar files in a number of ways.  See this <a href=\"http:\/\/java.sun.com\/j2se\/1.5.0\/docs\/tooldocs\/solaris\/javap.html\">web page<\/a> for more information.  For me, it&#8217;s an API reference.  I use it in two ways:<\/p>\n<p>1.  When I&#8217;m coding, and I need to know the exact syntax of a method, I shell out: <code>javap java.util.StringTokenizer<\/code>.  (Yes, I know that any modern IDE will do this for you without shelling out, but javap will work anywhere java is installed and with any editing tool.  You trade portability for convenience.)  One large catch is that inherited methods are not shown:<\/p>\n<div><code> <\/code><\/p>\n<pre>$ javap java.io.BufferedReader\r\nCompiled from \"BufferedReader.java\"\r\npublic class java.io.BufferedReader extends java.io.Reader{\r\npublic int read();\r\nthrows java\/io\/IOException\r\nstatic {};\r\npublic void close();\r\nthrows java\/io\/IOException\r\npublic void reset();\r\nthrows java\/io\/IOException\r\npublic boolean markSupported();\r\npublic boolean ready();\r\nthrows java\/io\/IOException\r\npublic void mark(int);\r\nthrows java\/io\/IOException\r\npublic long skip(long);\r\nthrows java\/io\/IOException\r\npublic int read(char[],int,int);\r\nthrows java\/io\/IOException\r\npublic java.io.BufferedReader(java.io.Reader);\r\npublic java.io.BufferedReader(java.io.Reader,int);\r\npublic java.lang.String readLine();\r\nthrows java\/io\/IOException\r\njava.lang.String readLine(boolean);\r\nthrows java\/io\/IOException\r\n}<\/pre>\n<\/div>\n<p>Running javap on <code>java.io.BufferedReader<\/code> does not show the method <code>read(char[])<\/code>, <a href=\"http:\/\/java.sun.com\/j2se\/1.4.2\/docs\/api\/java\/io\/BufferedReader.html#methods_inherited_from_class_java.io.Reader\">inherited from <code>java.io.Reader<\/code><\/a>.  (This example is from the J2SE 1.4 libraries.)<\/p>\n<p>2.  Sometimes, the javadoc is too up-to-date (or your jar files are too old) to answer questions about an API.  For example, I&#8217;m working on a project with <a href=\"http:\/\/portals.apache.org\/jetspeed-1\/\">Jetspeed<\/a> which depends on <a href=\"http:\/\/jakarta.apache.org\/turbine\/\">Turbine<\/a> version 2.2.  Unfortunately, this is an extremely old version of Turbine (release <a href=\"http:\/\/archive.apache.org\/dist\/jakarta\/turbine\/2.2\/\">16-Aug-2003<\/a>), and the javadoc doesn&#8217;t appear to be available.  (<strong>Updated Dec 11: It looks like the <a href=\"http:\/\/jakarta.apache.org\/turbine\/turbine\/turbine-2.2.0\/apidocs\/index.html\">Turbine 2.2 javadoc<\/a> is indeed online.  Whoops.<\/strong>)  <a href=\"http:\/\/ant.apache.org\/manual\/CoreTasks\/javadoc.html\">Generating the javadoc with ant<\/a> is certainly an possibility, and if I found myself going time and again to verify the API of Turbine 2.2, I&#8217;d do that.  But for a quick one- or two-off question about an API that no web search turns up, javap can be very handy.<\/p>\n<p>In short, if you have a quick question about an API, javap can help you out.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>javap lets you examine java class files and jar files in a number of ways. See this web page for more information. For me, it&#8217;s an API reference. I use [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,6,33],"tags":[],"class_list":["post-210","post","type-post","status-publish","format-standard","hentry","category-java","category-programming","category-useful-tools"],"_links":{"self":[{"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/posts\/210","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/comments?post=210"}],"version-history":[{"count":0,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/posts\/210\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/media?parent=210"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/categories?post=210"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/tags?post=210"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}