<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ja">
	<id>https://wiki.archlinux.jp/index.php?action=history&amp;feed=atom&amp;title=Java_%E3%81%AE_binfmt_misc%2F%E3%83%A9%E3%83%83%E3%83%91%E3%83%BC%E3%81%AE%E4%BE%8B</id>
	<title>Java の binfmt misc/ラッパーの例 - 版の履歴</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.archlinux.jp/index.php?action=history&amp;feed=atom&amp;title=Java_%E3%81%AE_binfmt_misc%2F%E3%83%A9%E3%83%83%E3%83%91%E3%83%BC%E3%81%AE%E4%BE%8B"/>
	<link rel="alternate" type="text/html" href="https://wiki.archlinux.jp/index.php?title=Java_%E3%81%AE_binfmt_misc/%E3%83%A9%E3%83%83%E3%83%91%E3%83%BC%E3%81%AE%E4%BE%8B&amp;action=history"/>
	<updated>2026-04-30T18:32:27Z</updated>
	<subtitle>このウィキのこのページに関する変更履歴</subtitle>
	<generator>MediaWiki 1.44.3</generator>
	<entry>
		<id>https://wiki.archlinux.jp/index.php?title=Java_%E3%81%AE_binfmt_misc/%E3%83%A9%E3%83%83%E3%83%91%E3%83%BC%E3%81%AE%E4%BE%8B&amp;diff=37041&amp;oldid=prev</id>
		<title>Kusanaginoturugi: add TranslationStatus</title>
		<link rel="alternate" type="text/html" href="https://wiki.archlinux.jp/index.php?title=Java_%E3%81%AE_binfmt_misc/%E3%83%A9%E3%83%83%E3%83%91%E3%83%BC%E3%81%AE%E4%BE%8B&amp;diff=37041&amp;oldid=prev"/>
		<updated>2024-04-17T09:11:23Z</updated>

		<summary type="html">&lt;p&gt;add TranslationStatus&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;ja&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← 古い版&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;2024年4月17日 (水) 18:11時点における版&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;302行目:&lt;/td&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;302行目:&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; 	return 0;&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; 	return 0;&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; }&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; }&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-empty diff-side-deleted&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-empty diff-side-deleted&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{TranslationStatus|Binfmt misc for Java/Wrapper examples|2024-04-17|806243}}&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Kusanaginoturugi</name></author>
	</entry>
	<entry>
		<id>https://wiki.archlinux.jp/index.php?title=Java_%E3%81%AE_binfmt_misc/%E3%83%A9%E3%83%83%E3%83%91%E3%83%BC%E3%81%AE%E4%BE%8B&amp;diff=37040&amp;oldid=prev</id>
		<title>Kusanaginoturugi: add en page link.</title>
		<link rel="alternate" type="text/html" href="https://wiki.archlinux.jp/index.php?title=Java_%E3%81%AE_binfmt_misc/%E3%83%A9%E3%83%83%E3%83%91%E3%83%BC%E3%81%AE%E4%BE%8B&amp;diff=37040&amp;oldid=prev"/>
		<updated>2024-04-17T09:07:32Z</updated>

		<summary type="html">&lt;p&gt;add en page link.&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;ja&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← 古い版&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;2024年4月17日 (水) 18:07時点における版&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;1行目:&lt;/td&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;1行目:&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:システム管理]]&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:システム管理]]&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-empty diff-side-deleted&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[en:Binfmt misc for Java/Wrapper examples]]&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;これらは、{{ic|binfmt_misc}} 経由で [[Java]] プログラムを実行するために使用できるラッパーと C コードの例です。&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;これらは、{{ic|binfmt_misc}} 経由で [[Java]] プログラムを実行するために使用できるラッパーと C コードの例です。&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Kusanaginoturugi</name></author>
	</entry>
	<entry>
		<id>https://wiki.archlinux.jp/index.php?title=Java_%E3%81%AE_binfmt_misc/%E3%83%A9%E3%83%83%E3%83%91%E3%83%BC%E3%81%AE%E4%BE%8B&amp;diff=37034&amp;oldid=prev</id>
		<title>Kusanaginoturugi: 訳出</title>
		<link rel="alternate" type="text/html" href="https://wiki.archlinux.jp/index.php?title=Java_%E3%81%AE_binfmt_misc/%E3%83%A9%E3%83%83%E3%83%91%E3%83%BC%E3%81%AE%E4%BE%8B&amp;diff=37034&amp;oldid=prev"/>
		<updated>2024-04-16T09:59:28Z</updated>

		<summary type="html">&lt;p&gt;訳出&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新規ページ&lt;/b&gt;&lt;/p&gt;&lt;div&gt;[[Category:システム管理]]&lt;br /&gt;
これらは、{{ic|binfmt_misc}} 経由で [[Java]] プログラムを実行するために使用できるラッパーと C コードの例です。&lt;br /&gt;
&lt;br /&gt;
== jarwrapper ==&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 # /usr/local/bin/jarwrapper - the wrapper for binfmt_misc/jar&lt;br /&gt;
 &lt;br /&gt;
 # set path to java using JAVA_HOME if available, otherwise assume it&amp;#039;s on the PATH&lt;br /&gt;
 JAVA_PATH=${JAVA_HOME:+$JAVA_HOME/jre/bin/}java&lt;br /&gt;
 $JAVA_PATH -jar &amp;quot;$@&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== javawrapper ==&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 # /usr/local/bin/javawrapper - the wrapper for binfmt_misc/java&lt;br /&gt;
 &lt;br /&gt;
 if [ -z &amp;quot;$1&amp;quot; ]; then&lt;br /&gt;
 	exec 1&amp;gt;&amp;amp;2&lt;br /&gt;
 	echo Usage: $0 class-file&lt;br /&gt;
 	exit 1&lt;br /&gt;
 fi&lt;br /&gt;
 &lt;br /&gt;
 CLASS=$1&lt;br /&gt;
 FQCLASS=`/usr/local/bin/javaclassname $1`&lt;br /&gt;
 FQCLASSN=`echo $FQCLASS | sed -e &amp;#039;s/^.*\.\([^.]*\)$/\1/&amp;#039;`&lt;br /&gt;
 FQCLASSP=`echo $FQCLASS | sed -e &amp;#039;s-\.-/-g&amp;#039; -e &amp;#039;s-^[^/]*$--&amp;#039; -e &amp;#039;s-/[^/]*$--&amp;#039;`&lt;br /&gt;
 &lt;br /&gt;
 # for example:&lt;br /&gt;
 # CLASS=Test.class&lt;br /&gt;
 # FQCLASS=foo.bar.Test&lt;br /&gt;
 # FQCLASSN=Test&lt;br /&gt;
 # FQCLASSP=foo/bar&lt;br /&gt;
 &lt;br /&gt;
 unset CLASSBASE&lt;br /&gt;
 &lt;br /&gt;
 declare -i LINKLEVEL=0&lt;br /&gt;
 &lt;br /&gt;
 while :; do&lt;br /&gt;
 	if [ &amp;quot;`basename $CLASS .class`&amp;quot; == &amp;quot;$FQCLASSN&amp;quot; ]; then&lt;br /&gt;
 		# See if this directory works straight off&lt;br /&gt;
 		cd -L `dirname $CLASS`&lt;br /&gt;
 		CLASSDIR=$PWD&lt;br /&gt;
 		cd $OLDPWD&lt;br /&gt;
 		if echo $CLASSDIR | grep -q &amp;quot;$FQCLASSP$&amp;quot;; then&lt;br /&gt;
 			CLASSBASE=`echo $CLASSDIR | sed -e &amp;quot;s.$FQCLASSP$..&amp;quot;`&lt;br /&gt;
 			break;&lt;br /&gt;
 		fi&lt;br /&gt;
 		# Try dereferencing the directory name&lt;br /&gt;
 		cd -P `dirname $CLASS`&lt;br /&gt;
 		CLASSDIR=$PWD&lt;br /&gt;
 		cd $OLDPWD&lt;br /&gt;
 		if echo $CLASSDIR | grep -q &amp;quot;$FQCLASSP$&amp;quot;; then&lt;br /&gt;
 			CLASSBASE=`echo $CLASSDIR | sed -e &amp;quot;s.$FQCLASSP$..&amp;quot;`&lt;br /&gt;
 			break;&lt;br /&gt;
 		fi&lt;br /&gt;
 		# If no other possible filename exists&lt;br /&gt;
 		if [ ! -L $CLASS ]; then&lt;br /&gt;
 			exec 1&amp;gt;&amp;amp;2&lt;br /&gt;
 			echo $0:&lt;br /&gt;
 			echo &amp;quot;  $CLASS should be in a&amp;quot; \&lt;br /&gt;
 			     &amp;quot;directory tree called $FQCLASSP&amp;quot;&lt;br /&gt;
 			exit 1&lt;br /&gt;
 		fi&lt;br /&gt;
 	fi&lt;br /&gt;
 	if [ ! -L $CLASS ]; then break; fi&lt;br /&gt;
 	# Go down one more level of symbolic links&lt;br /&gt;
 	let LINKLEVEL+=1&lt;br /&gt;
 	if [ $LINKLEVEL -gt 5 ]; then&lt;br /&gt;
 		exec 1&amp;gt;&amp;amp;2&lt;br /&gt;
 		echo $0:&lt;br /&gt;
 		echo &amp;quot;  Too many symbolic links encountered&amp;quot;&lt;br /&gt;
 		exit 1&lt;br /&gt;
 	fi&lt;br /&gt;
 	CLASS=`ls --color=no -l $CLASS | sed -e &amp;#039;s/^.* \([^ ]*\)$/\1/&amp;#039;`&lt;br /&gt;
 done&lt;br /&gt;
 &lt;br /&gt;
 if [ -z &amp;quot;$CLASSBASE&amp;quot; ]; then&lt;br /&gt;
 	if [ -z &amp;quot;$FQCLASSP&amp;quot; ]; then&lt;br /&gt;
 		GOODNAME=$FQCLASSN.class&lt;br /&gt;
 	else&lt;br /&gt;
 		GOODNAME=$FQCLASSP/$FQCLASSN.class&lt;br /&gt;
 	fi&lt;br /&gt;
 	exec 1&amp;gt;&amp;amp;2&lt;br /&gt;
 	echo $0:&lt;br /&gt;
 	echo &amp;quot;  $FQCLASS should be in a file called $GOODNAME&amp;quot;&lt;br /&gt;
 	exit 1&lt;br /&gt;
 fi&lt;br /&gt;
 &lt;br /&gt;
 if ! echo $CLASSPATH | grep -q &amp;quot;^\(.*:\)*$CLASSBASE\(:.*\)*&amp;quot;; then&lt;br /&gt;
 	# class is not in CLASSPATH, so prepend dir of class to CLASSPATH&lt;br /&gt;
 	if [ -z &amp;quot;${CLASSPATH}&amp;quot; ] ; then&lt;br /&gt;
 		export CLASSPATH=$CLASSBASE&lt;br /&gt;
 	else&lt;br /&gt;
 		export CLASSPATH=$CLASSBASE:$CLASSPATH&lt;br /&gt;
 	fi&lt;br /&gt;
 fi&lt;br /&gt;
 &lt;br /&gt;
 shift&lt;br /&gt;
 # set path to java using JAVA_HOME if available, otherwise assume it&amp;#039;s on the PATH&lt;br /&gt;
 JAVA_PATH=${JAVA_HOME:+$JAVA_HOME/jre/bin/}java&lt;br /&gt;
 $JAVA_PATH $FQCLASS &amp;quot;$@&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== javaclassname (support for javawrapper) ==&lt;br /&gt;
&lt;br /&gt;
This program is used by the &amp;#039;&amp;#039;javawrapper&amp;#039;&amp;#039; script above. Compile it with the command&lt;br /&gt;
 $ gcc -O2 -o javaclassname javaclassname.c&lt;br /&gt;
and move the executable to {{ic|/usr/local/bin}}.&lt;br /&gt;
 /* javaclassname.c&lt;br /&gt;
  *&lt;br /&gt;
  * Extracts the class name from a Java class file; intended for use in a Java&lt;br /&gt;
  * wrapper of the type supported by the binfmt_misc option in the Linux kernel.&lt;br /&gt;
  *&lt;br /&gt;
  * Copyright (C) 1999 Colin J. Watson &amp;lt;cjw44@cam.ac.uk&amp;gt;.&lt;br /&gt;
  *&lt;br /&gt;
  * This program is free software; you can redistribute it and/or modify&lt;br /&gt;
  * it under the terms of the GNU General Public License as published by&lt;br /&gt;
  * the Free Software Foundation; either version 2 of the License, or&lt;br /&gt;
  * (at your option) any later version.&lt;br /&gt;
  *&lt;br /&gt;
  * This program is distributed in the hope that it will be useful,&lt;br /&gt;
  * but WITHOUT ANY WARRANTY; without even the implied warranty of&lt;br /&gt;
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the&lt;br /&gt;
  * GNU General Public License for more details.&lt;br /&gt;
  *&lt;br /&gt;
  * You should have received a copy of the GNU General Public License&lt;br /&gt;
  * along with this program; if not, write to the Free Software&lt;br /&gt;
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA&lt;br /&gt;
  */&lt;br /&gt;
 &lt;br /&gt;
 #include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;
 #include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
 #include &amp;lt;stdarg.h&amp;gt;&lt;br /&gt;
 #include &amp;lt;sys/types.h&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 /* From Sun&amp;#039;s Java VM Specification, as tag entries in the constant pool. */&lt;br /&gt;
 &lt;br /&gt;
 #define CP_UTF8 1&lt;br /&gt;
 #define CP_INTEGER 3&lt;br /&gt;
 #define CP_FLOAT 4&lt;br /&gt;
 #define CP_LONG 5&lt;br /&gt;
 #define CP_DOUBLE 6&lt;br /&gt;
 #define CP_CLASS 7&lt;br /&gt;
 #define CP_STRING 8&lt;br /&gt;
 #define CP_FIELDREF 9&lt;br /&gt;
 #define CP_METHODREF 10&lt;br /&gt;
 #define CP_INTERFACEMETHODREF 11&lt;br /&gt;
 #define CP_NAMEANDTYPE 12&lt;br /&gt;
 &lt;br /&gt;
 /* Define some commonly used error messages */&lt;br /&gt;
 &lt;br /&gt;
 #define seek_error() error(&amp;quot;%s: Cannot seek\n&amp;quot;, program)&lt;br /&gt;
 #define corrupt_error() error(&amp;quot;%s: Class file corrupt\n&amp;quot;, program)&lt;br /&gt;
 #define eof_error() error(&amp;quot;%s: Unexpected end of file\n&amp;quot;, program)&lt;br /&gt;
 #define utf8_error() error(&amp;quot;%s: Only ASCII 1-255 supported\n&amp;quot;, program);&lt;br /&gt;
 &lt;br /&gt;
 char *program;&lt;br /&gt;
 &lt;br /&gt;
 long *pool;&lt;br /&gt;
 &lt;br /&gt;
 u_int8_t read_8(FILE *classfile);&lt;br /&gt;
 u_int16_t read_16(FILE *classfile);&lt;br /&gt;
 void skip_constant(FILE *classfile, u_int16_t *cur);&lt;br /&gt;
 void error(const char *format, ...);&lt;br /&gt;
 int main(int argc, char **argv);&lt;br /&gt;
 &lt;br /&gt;
 /* Reads in an unsigned 8-bit integer. */&lt;br /&gt;
 u_int8_t read_8(FILE *classfile)&lt;br /&gt;
 {&lt;br /&gt;
 	int b = fgetc(classfile);&lt;br /&gt;
 	if(b == EOF)&lt;br /&gt;
 		eof_error();&lt;br /&gt;
 	return (u_int8_t)b;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 /* Reads in an unsigned 16-bit integer. */&lt;br /&gt;
 u_int16_t read_16(FILE *classfile)&lt;br /&gt;
 {&lt;br /&gt;
 	int b1, b2;&lt;br /&gt;
 	b1 = fgetc(classfile);&lt;br /&gt;
 	if(b1 == EOF)&lt;br /&gt;
 		eof_error();&lt;br /&gt;
 	b2 = fgetc(classfile);&lt;br /&gt;
 	if(b2 == EOF)&lt;br /&gt;
 		eof_error();&lt;br /&gt;
 	return (u_int16_t)((b1 &amp;lt;&amp;lt; 8) | b2);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 /* Reads in a value from the constant pool. */&lt;br /&gt;
 void skip_constant(FILE *classfile, u_int16_t *cur)&lt;br /&gt;
 {&lt;br /&gt;
 	u_int16_t len;&lt;br /&gt;
 	int seekerr = 1;&lt;br /&gt;
 	pool[*cur] = ftell(classfile);&lt;br /&gt;
 	switch(read_8(classfile))&lt;br /&gt;
 	{&lt;br /&gt;
 	case CP_UTF8:&lt;br /&gt;
 		len = read_16(classfile);&lt;br /&gt;
 		seekerr = fseek(classfile, len, SEEK_CUR);&lt;br /&gt;
 		break;&lt;br /&gt;
 	case CP_CLASS:&lt;br /&gt;
 	case CP_STRING:&lt;br /&gt;
 		seekerr = fseek(classfile, 2, SEEK_CUR);&lt;br /&gt;
 		break;&lt;br /&gt;
 	case CP_INTEGER:&lt;br /&gt;
 	case CP_FLOAT:&lt;br /&gt;
 	case CP_FIELDREF:&lt;br /&gt;
 	case CP_METHODREF:&lt;br /&gt;
 	case CP_INTERFACEMETHODREF:&lt;br /&gt;
 	case CP_NAMEANDTYPE:&lt;br /&gt;
 		seekerr = fseek(classfile, 4, SEEK_CUR);&lt;br /&gt;
 		break;&lt;br /&gt;
 	case CP_LONG:&lt;br /&gt;
 	case CP_DOUBLE:&lt;br /&gt;
 		seekerr = fseek(classfile, 8, SEEK_CUR);&lt;br /&gt;
 		++(*cur);&lt;br /&gt;
 		break;&lt;br /&gt;
 	default:&lt;br /&gt;
 		corrupt_error();&lt;br /&gt;
 	}&lt;br /&gt;
 	if(seekerr)&lt;br /&gt;
 		seek_error();&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void error(const char *format, ...)&lt;br /&gt;
 {&lt;br /&gt;
 	va_list ap;&lt;br /&gt;
 	va_start(ap, format);&lt;br /&gt;
 	vfprintf(stderr, format, ap);&lt;br /&gt;
 	va_end(ap);&lt;br /&gt;
 	exit(1);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 int main(int argc, char **argv)&lt;br /&gt;
 {&lt;br /&gt;
 	FILE *classfile;&lt;br /&gt;
 	u_int16_t cp_count, i, this_class, classinfo_ptr;&lt;br /&gt;
 	u_int8_t length;&lt;br /&gt;
 &lt;br /&gt;
 	program = argv[0];&lt;br /&gt;
 &lt;br /&gt;
 	if(!argv[1])&lt;br /&gt;
 		error(&amp;quot;%s: Missing input file\n&amp;quot;, program);&lt;br /&gt;
 	classfile = fopen(argv[1], &amp;quot;rb&amp;quot;);&lt;br /&gt;
 	if(!classfile)&lt;br /&gt;
 		error(&amp;quot;%s: Error opening %s\n&amp;quot;, program, argv[1]);&lt;br /&gt;
 &lt;br /&gt;
 	if(fseek(classfile, 8, SEEK_SET))  /* skip magic and version numbers */&lt;br /&gt;
 		seek_error();&lt;br /&gt;
 	cp_count = read_16(classfile);&lt;br /&gt;
 	pool = calloc(cp_count, sizeof(long));&lt;br /&gt;
 	if(!pool)&lt;br /&gt;
 		error(&amp;quot;%s: Out of memory for constant pool\n&amp;quot;, program);&lt;br /&gt;
 &lt;br /&gt;
 	for(i = 1; i &amp;lt; cp_count; ++i)&lt;br /&gt;
 		skip_constant(classfile, &amp;amp;i);&lt;br /&gt;
 	if(fseek(classfile, 2, SEEK_CUR))	/* skip access flags */&lt;br /&gt;
 		seek_error();&lt;br /&gt;
 &lt;br /&gt;
 	this_class = read_16(classfile);&lt;br /&gt;
 	if(this_class &amp;lt; 1 || this_class &amp;gt;= cp_count)&lt;br /&gt;
 		corrupt_error();&lt;br /&gt;
 	if(!pool[this_class] || pool[this_class] == -1)&lt;br /&gt;
 		corrupt_error();&lt;br /&gt;
 	if(fseek(classfile, pool[this_class] + 1, SEEK_SET))&lt;br /&gt;
 		seek_error();&lt;br /&gt;
 &lt;br /&gt;
 	classinfo_ptr = read_16(classfile);&lt;br /&gt;
 	if(classinfo_ptr &amp;lt; 1 || classinfo_ptr &amp;gt;= cp_count)&lt;br /&gt;
 		corrupt_error();&lt;br /&gt;
 	if(!pool[classinfo_ptr] || pool[classinfo_ptr] == -1)&lt;br /&gt;
 		corrupt_error();&lt;br /&gt;
 	if(fseek(classfile, pool[classinfo_ptr] + 1, SEEK_SET))&lt;br /&gt;
 		seek_error();&lt;br /&gt;
 &lt;br /&gt;
 	length = read_16(classfile);&lt;br /&gt;
 	for(i = 0; i &amp;lt; length; ++i)&lt;br /&gt;
 	{&lt;br /&gt;
 		u_int8_t x = read_8(classfile);&lt;br /&gt;
 		if((x &amp;amp; 0x80) || !x)&lt;br /&gt;
 		{&lt;br /&gt;
 			if((x &amp;amp; 0xE0) == 0xC0)&lt;br /&gt;
 			{&lt;br /&gt;
 				u_int8_t y = read_8(classfile);&lt;br /&gt;
 				if((y &amp;amp; 0xC0) == 0x80)&lt;br /&gt;
 				{&lt;br /&gt;
 					int c = ((x &amp;amp; 0x1f) &amp;lt;&amp;lt; 6) + (y &amp;amp; 0x3f);&lt;br /&gt;
 					if(c) putchar(c);&lt;br /&gt;
 					else utf8_error();&lt;br /&gt;
 				}&lt;br /&gt;
 				else utf8_error();&lt;br /&gt;
 			}&lt;br /&gt;
 			else utf8_error();&lt;br /&gt;
 		}&lt;br /&gt;
 		else if(x == &amp;#039;/&amp;#039;) putchar(&amp;#039;.&amp;#039;);&lt;br /&gt;
 		else putchar(x);&lt;br /&gt;
 	}&lt;br /&gt;
 	putchar(&amp;#039;\n&amp;#039;);&lt;br /&gt;
 	free(pool);&lt;br /&gt;
 	fclose(classfile);&lt;br /&gt;
 	return 0;&lt;br /&gt;
 }&lt;/div&gt;</summary>
		<author><name>Kusanaginoturugi</name></author>
	</entry>
</feed>