2000/06/19

| コメント(0) | トラックバック(0)

くまざわ書店でグイン21〜30購入。

リフレクションとクラスローダの組み合わせ試験:

import java.io.*;
import java.lang.reflect.*;
public class CLS extends ClassLoader {
	public static void main(String[] args) throws Throwable {
		CLS cl = new CLS();
		Class c = cl.findClass("Sample");
		Method main = c.getMethod("main" , new Class[] { String[].class });
		main.invoke(null, new Object[] { args } );
	}
	public Class findClass(String name) {
		try {
			File file = new File("D:\\temp\\" + name + ".class");
			FileInputStream in = new FileInputStream(file);
			byte[] buff = new byte[(int)file.length()];
			in.read(buff);
			in.close();
			return defineClass(name, buff, 0, buff.length);
		} catch (IOException ex) {
			ex.printStackTrace();
		}
		return null;
	}
}

トラックバック(0)

トラックバックURL: http://www.septigram.jp/mt/mt-tb.cgi/34

コメントする

月別 アーカイブ

ウェブページ

Powered by Movable Type 5.04

このブログ記事について

このページは、wyvernが2000年6月19日 00:00に書いたブログ記事です。

ひとつ前のブログ記事は「2000/06/18」です。

次のブログ記事は「2000/06/20」です。

最近のコンテンツはインデックスページで見られます。過去に書かれたものはアーカイブのページで見られます。