Java 7中的ClassValue(ClassValue in Java 7)
在浏览Java 7 API文档时,我偶然发现了一个新的java.lang.ClassValue类,它使用下面的文档:
懒惰地将计算值与(可能)每种类型相关联。 例如,如果动态语言需要为在消息发送调用站点处遇到的每个类构造一个消息分派表,则可以使用
ClassValue
缓存为遇到的每个类而快速执行消息发送所需的信息。任何人都可以更好地解释这个类所解决的问题,也许有些示例代码或者已经使用这个类的开源项目?
更新:我仍然对一些实际的源代码或使用这个新类的例子感兴趣。
我还在mlvm-dev邮件列表上找到了关于一些实施改进的邮件 。 它显然是从使用WeakHashMap到java.lang.Class上的一个新的专用字段,使其更具可扩展性。
While browsing the Java 7 API documentation I stumbled upon the new class java.lang.ClassValue with the following rather minimal documentation:
Lazily associate a computed value with (potentially) every type. For example, if a dynamic language needs to construct a message dispatch table for each class encountered at a message send call site, it can use a
ClassValue
to cache information needed to perform the message send quickly, for each class encountered.Can anyone give a better explanation of what problem this class solves and perhaps some sample code or open source project that already uses this class?
Update: I'm still interested in some actual source code or examples using this new class.
I also found this mail on the mlvm-dev mailing list concerning some implementation improvements. It was apparently changed from using a WeakHashMap to a new private field on java.lang.Class to make it more scalable.
原文:https://stackoverflow.com/questions/7444420
最满意答案
看代码的前面: 应该是这样写: #include#include 不是这样写: #include #include //少了一个 字母c,错! 其次 return 0;应该放在 system("pause");的后面,即: system("pause“); return 0; 建议:如果不是为了考*,不要用VC6.0.
其他回答
第二行有错 应该写成 #include或者 #include 第七行也有错 应该将return 0;写在system("pause");的后面 这里的system("pause");的意思就是“按任意键继续” 其中的pause其实是你在控制台中的命令。 你可以尝试一下,按Win键+R,然后输入cmd,回车 出现控制台,然后你输入pause,看看效果。 其实控制台中的其他命令也可以写在system()中。还有例如cls。
第二行少了个c,其实第二行可以删了的,其它没错
相关问答
更多-
最简单的eclipse运行Hello world[2022-02-16]
我这个是Myeclipse 但是都差不多 下面是截图 自己看吧 首先第一步确定自己要创建的工程 是java工程还是web工程或者什么工程 当然你要最简洁的创建java工程就可以 第二步输入工程名 第三步创建class文件 在src上面右键 第四步 给1写名字 在2上勾选之后选择finish就结束了 -
VC++6.0里的system("pause")怎么用?我是菜鸟刚学会hello world[2022-04-02]
看代码的前面: 应该是这样写: #include #include 不是这样写: #include #include //少了一个 字母c,错! 其次 return 0;应该放在 system("pause");的后面,即: system("pause“); return 0; 建议:如果不是为了考*,不要用VC6.0. -
对于像Main类这样的实用程序类,最好创建一个私有构造函数,以便不让java编译器将其自身写入默认的无参数构造函数Main() 。 Java在将它们发送给方法之前总是制作一个参数的副本。 这里的final关键字只意味着在方法内部变量不能被重新分配。 (请注意,如果您的最终对象在您的情况下为String[] ,那么您仍然可以更改该对象的属性)。 For Utility classes like your Main class, it is better to create a private construc ...
-
Nios 2“Hello World”?(Nios 2 “Hello World”?)[2022-04-07]
该程序正在电路板上运行。 从节目评论... 这个例子将'Hello from Nios II'打印到STDOUT流。 这种情况下的STDOUT流是软件终端。 因此,Nios II板正在运行hello world程序并将输出发送到计算机。 要使用电路板上的屏幕,您必须使用SOPC构建器将LCD显示器包含在配置中,然后直接写入LCD屏幕。 The program IS running on the board. From the program comments... This example prints ' ... -
将你的文件重命名为hello.cu 默认情况下, nvcc会将.c或.cpp文件直接发送到主机编译器,而无需对它们进行任何设备代码检查或编译。 有各种选项可以改变这种行为。 Rename your file to hello.cu nvcc by default sends .c or .cpp files directly to the host compiler without doing any device code inspection or compilation on them. There ...
-
有一篇关于在Rust中编写操作系统的博客,其中的第一步是关于仅使用Rust启动和打印某些内容到屏幕。 这是一个高级主题,因此我不建议从编写操作系统开始,如果您想了解操作系统的工作原理,请执行此操作。 There is an blog about Writing an OS in Rust, where first steps are about booting and printing some stuff to screen using only Rust. It's an advanced topic, ...
-
在你的清单.xml中将target-sdk更改为19.! In your manifest .xml change target-sdk to 19.!
-
正如您在评论中解释的那样,您正在组装代码如下: nasm helloWorld.asm 这个问题是 您没有像可执行文件那样组装它 如果是可执行文件,则在组装后不会链接它 在Linux下,您将把此代码汇编到ELF文件中。 为此,请运行以下命令: nasm -f elf helloWorld.asm ld -m elf_i386 -s -o helloWorld helloWorld.o 第一个命令将代码组装到要构建到ELF文件中的对象( .o )文件中。 第二个命令获取该目标文件并将其转换为ELF(可执行 ...
-
RJB Hello World示例(RJB Hello World Example)[2020-02-11]
你可以尝试以下方法。 它可能有所帮助: Rjb::add_jar( Dir.glob("#{Rails.root}/lib/java_libs/*.jar").join(':')) Rjb::load(Dir.glob("#{Rails.root}/lib/java_libs/*.jar").join(':')) test = Rjb.import('HelloWorld') instance_class = test.new you can try the following. it might he ... -
Java - Hello World错误(Java - Hello World Error)[2022-04-30]
好像你告诉IntelliJ调用类com.company.Main的主要方法。 但是IntelliJ找不到这样的课程。 IntelliJ在com / company文件夹中搜索文件Main.class 可能你想告诉IntelliJ运行“HelloWorld”的主要方法而不是“com.company.Main”...... It seems like you told IntelliJ to call the main method of class com.company.Main. But IntelliJ ...