当前位置: 首页 > news >正文

openjdk17 C++源码是怎么给java字段赋值的

##java源码

public class OtherClass {public static int CONSTANT_O=9876;public int o=1234;public void dddd(){String dddd = "dddd";//System.out.println(dddd);System.out.println(dddd+CONSTANT_O);}}

public int o=1234;

在openjdk17中 C++源码怎么执行这段代码的,字节码sipush ,putfield      #2

##字节码

 public OtherClass();descriptor: ()Vflags: (0x0001) ACC_PUBLICCode:stack=2, locals=1, args_size=10: aload_01: invokespecial #1                  // Method java/lang/Object."<init>":()V4: aload_05: sipush        12348: putfield      #2                  // Field o:I11: returnLineNumberTable:line 1: 0line 4: 4

##C++源码

// This function is the interface to the assembly code. It returns the resolved
// cpCache entry.  This doesn't safepoint, but the helper routines safepoint.
// This function will check for redefinition!
JRT_ENTRY(void, InterpreterRuntime::resolve_from_cache(JavaThread* current, Bytecodes::Code bytecode)) {switch (bytecode) {case Bytecodes::_getstatic:case Bytecodes::_putstatic:case Bytecodes::_getfield:case Bytecodes::_putfield:resolve_get_put(current, bytecode);break;case Bytecodes::_invokevirtual:case Bytecodes::_invokespecial:case Bytecodes::_invokestatic:case Bytecodes::_invokeinterface:resolve_invoke(current, bytecode);break;case Bytecodes::_invokehandle:resolve_invokehandle(current);break;case Bytecodes::_invokedynamic:resolve_invokedynamic(current);break;default:fatal("unexpected bytecode: %s", Bytecodes::name(bytecode));break;}
}
JRT_ENDvoid InterpreterRuntime::resolve_get_put(JavaThread* current, Bytecodes::Code bytecode) {// resolve fieldfieldDescriptor info;LastFrameAccessor last_frame(current);constantPoolHandle pool(current, last_frame.method()->constants());methodHandle m(current, last_frame.method());bool is_put    = (bytecode == Bytecodes::_putfield  || bytecode == Bytecodes::_nofast_putfield ||bytecode == Bytecodes::_putstatic);bool is_static = (bytecode == Bytecodes::_getstatic || bytecode == Bytecodes::_putstatic);{JvmtiHideSingleStepping jhss(current);JavaThread* THREAD = current; // For exception macros.LinkResolver::resolve_field_access(info, pool, last_frame.get_index_u2_cpcache(bytecode),m, bytecode, CHECK);} // end JvmtiHideSingleStepping// std::cout << "@@@@yym%%%%field" << info.name()->as_C_string() << ":offset:" << info.offset() << std::endl;// check if link resolution caused cpCache to be updatedConstantPoolCacheEntry* cp_cache_entry = last_frame.cache_entry();if (cp_cache_entry->is_resolved(bytecode)) {// std::cout << "@@@@yym%%%%field is_resolved" << info.name()->as_C_string() << ":result:" << "true" << std::endl;return;}// compute auxiliary field attributesTosState state  = as_TosState(info.field_type());// Resolution of put instructions on final fields is delayed. That is required so that// exceptions are thrown at the correct place (when the instruction is actually invoked).// If we do not resolve an instruction in the current pass, leaving the put_code// set to zero will cause the next put instruction to the same field to reresolve.// Resolution of put instructions to final instance fields with invalid updates (i.e.,// to final instance fields with updates originating from a method different than <init>)// is inhibited. A putfield instruction targeting an instance final field must throw// an IllegalAccessError if the instruction is not in an instance// initializer method <init>. If resolution were not inhibited, a putfield// in an initializer method could be resolved in the initializer. Subsequent// putfield instructions to the same field would then use cached information.// As a result, those instructions would not pass through the VM. That is,// checks in resolve_field_access() would not be executed for those instructions// and the required IllegalAccessError would not be thrown.//// Also, we need to delay resolving getstatic and putstatic instructions until the// class is initialized.  This is required so that access to the static// field will call the initialization function every time until the class// is completely initialized ala. in 2.17.5 in JVM Specification.InstanceKlass* klass = info.field_holder();bool uninitialized_static = is_static && !klass->is_initialized();bool has_initialized_final_update = info.field_holder()->major_version() >= 53 &&info.has_initialized_final_update();assert(!(has_initialized_final_update && !info.access_flags().is_final()), "Fields with initialized final updates must be final");Bytecodes::Code get_code = (Bytecodes::Code)0;Bytecodes::Code put_code = (Bytecodes::Code)0;if (!uninitialized_static) {get_code = ((is_static) ? Bytecodes::_getstatic : Bytecodes::_getfield);if ((is_put && !has_initialized_final_update) || !info.access_flags().is_final()) {put_code = ((is_static) ? Bytecodes::_putstatic : Bytecodes::_putfield);}}// std::cout << "@@@@yym%%%%field" << info.name()->as_C_string() << ":offset:" << info.offset() << std::endl;// std::string str1 = "o";// const char* cStr = info.name()->as_klass_external_name();  // std::string str2(cStr); // 使用构造函数进行转换// if (str1.compare(str2) == 0) {//     std::cout << "field name The strings are equal." << std::endl;//     std::cout << "@@@@yym%%%%field" << info.name()->as_C_string() << ":offset:" << info.offset() << std::endl;// }// std::string str3 = "CONSTANT_O";// const char* cStr1 = info.name()->as_klass_external_name();  // std::string str4(cStr1); // 使用构造函数进行转换// if (str3.compare(str4) == 0) {//     std::cout << "CONSTANT_O name The strings are equal." << std::endl;//     std::cout << "@@@@yym%%%%field" << info.name()->as_C_string() << ":offset:" << info.offset() << std::endl;// }cp_cache_entry->set_field(get_code,put_code,info.field_holder(),info.index(),info.offset(),state,info.access_flags().is_final(),info.access_flags().is_volatile());
}

相关文章:

openjdk17 C++源码是怎么给java字段赋值的

##java源码 public class OtherClass {public static int CONSTANT_O9876;public int o1234;public void dddd(){String dddd "dddd";//System.out.println(dddd);System.out.println(ddddCONSTANT_O);}} public int o1234; 在openjdk17中 C源码怎么执行这段代码…...

C++初阶(八)--内存管理

目录 引入&#xff1a; 一、C中的内存布局 1.内存区域 2.示例变量存储位置说明 二、C语言中动态内存管理 三、C内存管理方式 1.new/delete操作内置类型 2.new和delete操作自定义类型 四、operator new与operator delete函数&#xff08;重要点进行讲解&#xff09; …...

C# 企业微信机器人推送消息 windows服务应用程序的使用

C# 企业微信机器人推送消息 先添加一个机器人! 然后查看机器人就可以得到一个 webhook 特别特别要注意&#xff1a;一定要保护好机器人的webhook地址&#xff0c;避免泄漏&#xff01; 然后开始写代码 &#xff0c;只需要httpPost 调用一下这个地址就可以发送消息了。 首先我…...

社区交流系统设计与实现

社区交流系统设计与实现 1. 系统概述 社区交流系统是一个基于PHP和SQL的Web应用程序&#xff0c;旨在为用户提供一个互动交流的平台。该系统允许用户注册、发布帖子、回复帖子、查看其他用户的帖子和回复&#xff0c;以及管理个人资料&#xff0c;提高用户之间的互动和信息共享…...

【模型学习之路】手写+分析bert

手写分析bert 目录 前言 架构 embeddings Bertmodel 预训练任务 MLM NSP Bert 后话 netron可视化 code2flow可视化 fine tuning 前言 Attention is all you need! 读本文前&#xff0c;建议至少看懂【模型学习之路】手写分析Transformer-CSDN博客。 毕竟Bert是tr…...

Redis学习文档(常见面试题)

目录 Redis回收使用的是什么算法&#xff1f; Redis如何做大量数据插入&#xff1f; 为什么要做Redis分区&#xff1f; 你知道有哪些Redis分区实现方案&#xff1f; Redis分区有什么缺点&#xff1f; Redis持久化数据和缓存怎么做扩容&#xff1f; 分布式Redis是前期做还…...

【C++刷题】力扣-#594-最长和谐子序列

题目描述 和谐数组是指一个数组里元素的最大值和最小值之间的差别 正好是 1 。 给你一个整数数组 nums &#xff0c;请你在所有可能的子序列中找到最长的和谐子序列的长度。 数组的 子序列是一个由数组派生出来的序列&#xff0c;它可以通过删除一些元素或不删除元素、且不改变…...

MoveIt 控制自己的真实机械臂【2】——编写 action server 端代码

完成了 MoveIt 这边 action client 的基本配置&#xff0c;MoveIt 理论上可以将规划好的 trajectory 以 action 的形式发布出来了&#xff0c;浅浅尝试一下&#xff0c;在 terminal 中运行 roslaunch xmate7_moveit_config_new demo.launch 报错提示他在等待 xmate_arm_control…...

C#制作学生管理系统

定义学生类 定义一个简单的类来表示学生&#xff0c;包括学号、姓名、性别、年龄、电话、地址。再给其添加一个方法利于后续添加方法查看学生信息。 //定义学生类 public class student {public int ID { get; set; }//开放读写权限public string Name { get; set; }public i…...

python Pandas合并(单元格、sheet、excel )

安装 Pandas 和 openpyxl 首先&#xff0c;确保已经安装了 Pandas 和 openpyxl。可以通过 pip 安装&#xff1a; pip install pandas openpyxl 创建 DataFrame import pandas as pd # 创建 DataFrame df1 pd.DataFrame({ 姓名: [张三, 李四, 王五], 年龄: [25, 30, 35]…...

OJ在线编程常见输入输出练习【JavaScript】

&#xff08;注&#xff1a;本文是对【JavaScript Node 】 ACM模式&#xff0c;常见输入输出练习相关内容的介绍&#xff01;&#xff01;&#xff01;&#xff09; 牛客竞赛_ACM/NOI/CSP/CCPC/ICPC算法编程高难度练习赛_牛客竞赛OJ 一、ACM模式下的编辑页面 二、ACM模式下&a…...

新能源汽车空调系统:绿色出行的舒适保障

在新能源汽车迅速发展的今天&#xff0c;空调系统作为提升驾乘舒适度的重要组成部分&#xff0c;发挥着不可或缺的作用。新能源汽车空调系统主要由压缩机、冷凝器、节流装置和蒸发器四大件组成&#xff0c;它们协同工作&#xff0c;为车内提供适宜的温度和湿度环境。 一、压缩…...

Date工具类详细汇总-Date日期相关方法

# 1024程序员节 | 征文 # 目录 简介 Date工具类单元测试 Date工具类 简介 本文章是个人总结实际工作中常用到的Date工具类&#xff0c;主要包含Java-jdk8以下版本的Date相关使用方法&#xff0c;可以方便的在工作中灵活的应用&#xff0c;在个人工作期间频繁使用这些时间的格…...

TMUX1308PWR规格书 数据手册 具有注入电流控制功能的 5V 双向 8:1单通道和 4:1 双通道多路复用器芯片

TMUX1308 和 TMUX1309 为通用互补金属氧化物半导体 (CMOS) 多路复用器 (MUX)。TMUX1308 是 8:1单通道&#xff08;单端&#xff09;多路复用器&#xff0c;而 TMUX1309 是 4:1 双通道&#xff08;差分&#xff09;多路复用器。这些器件可在源极 (Sx) 和漏极 (Dx) 引脚上支持从 …...

证件照怎么换底色?简单又快速!不看后悔

一、引言 证件照在我们的生活中有着广泛的应用&#xff0c;无论是求职、考试还是办理各种证件&#xff0c;都需要用到不同底色的证件照。传统的换底色方法往往比较复杂&#xff0c;需要一定的专业技能和软件操作经验。但是现在&#xff0c;有了更简单快捷的方法&#xff0c;让你…...

Rust 基础语法与常用特性

Rust 跨界&#xff1a;全面掌握跨平台应用开发 第一章&#xff1a;快速上手 Rust 1.2 基础语法与常用特性 1.2.1 数据类型与控制流 数据类型 Rust 提供了丰富的内置数据类型&#xff0c;主要分为标量类型和复合类型。 标量类型 标量类型表示单一的值&#xff0c;Rust 中…...

一、开发环境的搭建

环境搭建步骤&#xff1a; 下载软件安装软件运行软件 其他&#xff1a; Visual studio 安装包文件&#xff1a;https://www.alipan.com/s/nd5RgzD4e3b 下载软件 在浏览器中搜索Visual studio&#xff0c;选择如图的选项 点击该区域&#xff0c;进入该页面&#xff0c;【或…...

Docker:存储原理

Docker&#xff1a;存储原理 镜像联合文件系统overlay镜像存储结构容器存储结构 存储卷绑定挂载存储卷结构 镜像 联合文件系统 联合文件系统Union File System是一种分层&#xff0c;轻量且高效的文件系统。其将整个文件系统分为多个层&#xff0c;层与层之间进行覆盖&#x…...

ts:数组的常用方法(push、pop、shift、unshift、splice、slice)

前端css中filter的使用 一、主要内容说明二、例子&#xff08;一&#xff09;、push方法&#xff08;尾添加&#xff09;1.源码1 &#xff08;push方法&#xff09;2.源码1运行效果 &#xff08;二&#xff09;、pop方法&#xff08;尾删除&#xff09;1.源码2&#xff08;pop方…...

物联网网关确保设备安全

物联网&#xff08;IoT&#xff09;网关在确保设备安全方面扮演着至关重要的角色。 作为连接物联网设备和云端或企业系统的中介&#xff0c;物联网网关可以实施多种安全措施来保护设备和数据。 是物联网网关确保设备安全的关键方法&#xff1a; 1. 设备认证和授权 认证&…...

3分钟掌握PCB交互式BOM:告别传统表格的终极可视化方案

3分钟掌握PCB交互式BOM&#xff1a;告别传统表格的终极可视化方案 【免费下载链接】InteractiveHtmlBom Interactive HTML BOM generation plugin for KiCad, EasyEDA, Eagle, Fusion360 and Allegro PCB designer 项目地址: https://gitcode.com/gh_mirrors/in/InteractiveH…...

强化学习实战指南:从原理到工业落地的完整路径

1. 这不是科幻&#xff0c;是正在发生的现实&#xff1a;当机器在围棋、电竞、物流调度甚至蛋白质折叠中全面超越人类你有没有过这种感觉&#xff1a;刷到一条新闻说“AI又赢了人类冠军”&#xff0c;第一反应不是惊讶&#xff0c;而是点开前先猜——这次输的是围棋手、星际争霸…...

uTinyRipper零基础实战:Unity游戏资产提取与反序列化指南

1. 这不是“破解工具”&#xff0c;而是一把Unity游戏资产的“数字考古铲” 你刚下载完一款国产独立游戏&#xff0c;想看看它的UI贴图是怎么做的&#xff1b;或者在学习Unity Shader时&#xff0c;想拆解某款商业Demo里那个流光溢散的粒子特效&#xff1b;又或者&#xff0c;你…...

Lovable主题定制深度教程:不改一行PHP代码,实现品牌专属UI/UX升级(仅限当前版本v4.8.3私有补丁包)

更多请点击&#xff1a; https://codechina.net 第一章&#xff1a;Lovable主题定制深度教程&#xff1a;不改一行PHP代码&#xff0c;实现品牌专属UI/UX升级&#xff08;仅限当前版本v4.8.3私有补丁包&#xff09; Lovable v4.8.3 通过其增强型 CSS 变量体系与声明式主题注入…...

Unity接入海康UMP流全流程:签名认证、HTTP长连接与自定义渲染

1. 这不是简单的“拉流”&#xff0c;而是一场跨协议、跨权限、跨引擎的精准对接你有没有试过在Unity里直接填一个RTSP地址&#xff0c;比如rtsp://admin:123456192.168.1.64:554/Streaming/Channels/101&#xff0c;然后点播放——结果黑屏、报错、卡死&#xff0c;或者更糟&a…...

Unity版本降级实战指南:从2021.1回退到2019.4的四步硬核操作

1. 为什么Unity版本降级不是“回退安装”那么简单 在Unity项目开发中&#xff0c;很多人把“降级”理解成卸载新版本、重装旧版本、再拖进工程——就像换手机系统时刷回上个固件。但Unity的版本管理机制远比这复杂得多。我第一次遇到从2021.1.7f1c1往回降到2019.4.17f1c1的问题…...

【ElevenLabs云南话语音落地实战】:20年语音AI专家亲授3步适配方言模型,避开92%开发者踩过的声学对齐陷阱

更多请点击&#xff1a; https://intelliparadigm.com 第一章&#xff1a;ElevenLabs云南话语音落地实战导论 云南话作为西南官话的重要分支&#xff0c;具有声调丰富、语流连贯、地域变体多样等特点&#xff0c;为语音合成技术带来独特挑战。ElevenLabs 提供的多语言、高保真…...

上班族开例会懒得记要点?2026年这3款AI总结工具,会后自动整理纪要

做互联网运营四年&#xff0c;开会已经成了每天的常态。部门周例会、项目复盘会、线上培训课、远程沟通会&#xff0c;大大小小的视频会议一场接一场。以前最让我头疼的不是参会&#xff0c;而是会后整理纪要。开会时既要认真听讨论、跟进工作进度&#xff0c;又要低头飞速记笔…...

React 从入门到生产(五):状态管理选型

创作者&#xff1a; Yardon | GitHub&#xff1a; github.com/YardonYan | 版本&#xff1a; v1.0 什么时候需要状态管理 先泼一盆冷水&#xff1a;大多数 React 应用不需要 Redux。 这句话不是我说的&#xff0c;是 Redux 的作者 Dan Abramov 本人说的。他在 2020 年就公…...

DeepSeek高并发场景下的云原生弹性架构设计(千万QPS容灾实测数据首次公开)

更多请点击&#xff1a; https://codechina.net 第一章&#xff1a;DeepSeek高并发场景下的云原生弹性架构设计&#xff08;千万QPS容灾实测数据首次公开&#xff09; 在支撑DeepSeek大模型推理服务的生产环境中&#xff0c;我们构建了一套面向千万级QPS的云原生弹性架构。该架…...