当前位置: 技术问答>java相关
下载jdk类库的源文件
来源: 互联网 发布时间:2015-10-18
本文导语: 请问大虾:我很想看看jdk1.3或jdk1.4的类文件的源文件,即他们的.java文件,请问,又哪位同志知道在那里下载????? 在线等待,重分相送 | w | 用反射 下面的代码你可试...
请问大虾:我很想看看jdk1.3或jdk1.4的类文件的源文件,即他们的.java文件,请问,又哪位同志知道在那里下载?????
在线等待,重分相送
在线等待,重分相送
|
w
|
用反射
下面的代码你可试一下:
/**
@version 1.01 2000-04-11
@author Cay Horstmann
*/
import java.lang.reflect.*;
import javax.swing.*;
public class ReflectionTest
{
public static void main(String[] args)
{
// read class name from command line args or user input
String name;
if (args.length > 0)
name = args[0];
else
name = JOptionPane.showInputDialog
("Class name (e.g. java.util.Date): ");
try
{
// print class name and superclass name (if != Object)
Class cl = Class.forName(name);
Class supercl = cl.getSuperclass();
System.out.print("class " + name);
if (supercl != null && supercl != Object.class)
System.out.print(" extends " + supercl.getName());
System.out.print("n{n");
printConstructors(cl);
System.out.println();
printMethods(cl);
System.out.println();
printFields(cl);
System.out.println("}");
}
catch(ClassNotFoundException e) { e.printStackTrace(); }
System.exit(0);
}
/**
Prints all constructors of a class
@param cl a class
*/
public static void printConstructors(Class cl)
{
Constructor[] constructors = cl.getDeclaredConstructors();
for (int i = 0; i
下面的代码你可试一下:
/**
@version 1.01 2000-04-11
@author Cay Horstmann
*/
import java.lang.reflect.*;
import javax.swing.*;
public class ReflectionTest
{
public static void main(String[] args)
{
// read class name from command line args or user input
String name;
if (args.length > 0)
name = args[0];
else
name = JOptionPane.showInputDialog
("Class name (e.g. java.util.Date): ");
try
{
// print class name and superclass name (if != Object)
Class cl = Class.forName(name);
Class supercl = cl.getSuperclass();
System.out.print("class " + name);
if (supercl != null && supercl != Object.class)
System.out.print(" extends " + supercl.getName());
System.out.print("n{n");
printConstructors(cl);
System.out.println();
printMethods(cl);
System.out.println();
printFields(cl);
System.out.println("}");
}
catch(ClassNotFoundException e) { e.printStackTrace(); }
System.exit(0);
}
/**
Prints all constructors of a class
@param cl a class
*/
public static void printConstructors(Class cl)
{
Constructor[] constructors = cl.getDeclaredConstructors();
for (int i = 0; i