本文介绍了Java中的合成类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是Java中的合成类?为什么要使用它?如何使用它?

What is a Synthetic Class in Java? Why should it be used? and How can I use it?

推荐答案

例如,当你有一个switch语句时,java创建一个变量, $。如果你想看到一个例子,窥探一个类中有一个switch语句的java反射。当类中至少有一个switch语句时,您将看到这些变量。

For example, When you have a switch statement, java creates a variable that starts with a $. If you want to see an example of this, peek into the java reflection of a class that has a switch statement in it. You will see these variables when you have at least one switch statement anywhere in the class.

要回答你的问题,我不相信你能够访问(反射)合成类。

To answer your question, I don't believe you are able to access(other than reflection) the synthetic classes.

如果你正在分析一个你不知道的类(通过反射),并需要知道这个类的非常具体和低级的东西,你可能最终使用Java反射方法,合成类。这里唯一的使用是获取更多关于类的信息,以便在代码中使用它。

If you are analyzing a class that you don't know anything about (via reflection) and need to know very specific and low-level things about that class, you may end up using Java reflection methods that have to do with synthetic classes. The only "use" here is get more information about the class in order to use it appropriately in your code.

(如果你这样做,你可能正在构建一些其他开发者可以使用的框架)。

(If you're doing this, you're probably building a framework of some sorts that other developers could use. )

否则,如果你不使用反射,我没有实际使用合成类,我知道。

Otherwise, if you are not using reflection, there are no practical uses of synthetic classes that I know of.

这篇关于Java中的合成类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 13:35