首页 \ 问答 \ Java 7中的ClassValue(ClassValue in Java 7)

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
更新时间:2024-03-06 17:03

最满意答案

看代码的前面:

应该是这样写:
#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,其实第二行可以删了的,其它没错

相关问答

更多
  • 我这个是Myeclipse 但是都差不多 下面是截图 自己看吧 首先第一步确定自己要创建的工程 是java工程还是web工程或者什么工程 当然你要最简洁的创建java工程就可以 第二步输入工程名 第三步创建class文件 在src上面右键 第四步 给1写名字 在2上勾选之后选择finish就结束了
  • 看代码的前面: 应该是这样写: #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 ...
  • 该程序正在电路板上运行。 从节目评论... 这个例子将'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::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 ...
  • 好像你告诉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 ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。