码迷,mamicode.com
首页 > 编程语言 > 详细

JavaSE8基础 enum 对枚举类进行反编译查看其原理

时间:2017-10-08 16:50:16      阅读:412      评论:0      收藏:0      [点我收藏+]

标签:page   author   version   window   珍惜   south   手册   ipo   查看   

礼悟:
           好好学习多思考,尊师重道存感恩。叶见寻根三返一,活水清源藏于零。
           虚怀若谷良心主,皓月当空自在王。愿给最苦行无悔,诚劝且行且珍惜。


 

 

    os :windows7 x64
    jdk:jdk-8u131-windows-x64
    ide:Eclipse Oxygen Release (4.7.0)

 

 

code:

package blog.jizuiku8;

/**
 * 枚举类,JDK1.5提供的新特性
 * 
 * @author jizuiku
 * @version V17.10.03
 */
public enum Direction {
	North,South,West,East;
}

 

API:
技术分享


XjadCode:

// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   Direction.java

package blog.jizuiku8;


public final class Direction extends Enum
{

	public static final Direction North;
	public static final Direction South;
	public static final Direction West;
	public static final Direction East;
	private static final Direction ENUM$VALUES[];

	private Direction(String s, int i)
	{
		super(s, i);
	}

	public static Direction[] values()
	{
		Direction adirection[];
		int i;
		Direction adirection1[];
		System.arraycopy(adirection = ENUM$VALUES, 0, adirection1 = new Direction[i = adirection.length], 0, i);
		return adirection1;
	}

	public static Direction valueOf(String s)
	{
		return (Direction)Enum.valueOf(blog/jizuiku8/Direction, s);
	}

	static 
	{
		North = new Direction("North", 0);
		South = new Direction("South", 1);
		West = new Direction("West", 2);
		East = new Direction("East", 3);
		ENUM$VALUES = (new Direction[] {
			North, South, West, East
		});
	}
}

  经过 反编译工具查看.class文件后,看到了该特性的运行原理。



Java优秀,值得学习。
学习资源:API手册 + Java源码 + Xjad + 清净的心地。

JavaSE8基础 enum 对枚举类进行反编译查看其原理

标签:page   author   version   window   珍惜   south   手册   ipo   查看   

原文地址:http://www.cnblogs.com/jizuiku/p/7637732.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!