如何以编程方式确定当前类的Java字节码版本? [英] How to determine the Java byte code version of the current class programatically?

查看:86
本文介绍了如何以编程方式确定当前类的Java字节码版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到的情况是,部署平台是Java 5,开发是在Java 6下使用Eclipse进行的,在该环境下,我们已经建立了在给定项目上开始工作时创建新工作区的过程。因此,所需的步骤之一是将编译器级别设置为Java 5,这常常被人们遗忘。

I have a situation where the deployment platform is Java 5 and the development happens with Eclipse under Java 6 where we have established a procedure of having a new workspace created when beginning work on a given project. One of the required steps is therefore setting the compiler level to Java 5, which is frequently forgotten.

我们有一台运行部署平台的测试机,可以在其中运行代码我们在PC上进行构建并进行初始测试,但是如果我们忘记切换编译器级别,则该程序将无法运行。我们有一个构建服务器,可以创建发给客户的东西,效果很好,但这是用于不需要构建服务器并且会增加不必要等待的开发。

We have a test machine running the deployment platform where we can run the code we build and do initial testing on our PC's, but if we forget to switch the compiler level the program cannot run. We have a build server for creating what goes to the customer, which works well, but this is for development where the build server is not needed and would add unnecessary waits.

问题是: CAN 我以编程方式确定当前类的字节码版本,因此我的代码可以在本地PC上进行测试时已经打印出警告?

The question is: CAN I programmatically determine the byte code version of the current class, so my code can print out a warning already while testing on my local PC?

编辑:请注意,该要求适用于当前课程。可通过classloadeer使用吗?还是必须找到当前类的类文件,然后进行调查?

Please note the requirement was for the current class. Is this available through the classloadeer? Or must I locate the class file for the current class, and then investigate that?

推荐答案

看看问题: Java API,以找出

这篇关于如何以编程方式确定当前类的Java字节码版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆