V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
V2EX  ›  JasonLaw  ›  全部回复第 32 页 / 共 38 页
回复总数  742
1 ... 24  25  26  27  28  29  30  31  32  33 ... 38  
❮ ❯
@ik2h #3 先抛开其他的,单纯讨论 3 楼所引用的内容。

“A reference to a static field (§8.3.1.1) causes initialization of only the class or interface that actually declares it”不一定正确。主题正文中的外链(因为提示回复不能包含外链,所以只能这么弄)说了“A use of a field that is both static and final, and initialized by a compile-time constant expression, is not an active use of the type that declares the field.”,其中的 Example3 也演示了(虽然 Example3 中引用了 Angry.greeting 和 Dog.greeting,但是 Angry 和 Dog 都没有被初始化)。

还是我哪里理解错了?
@ik2h #1 你说的都是关于 initialization 的,而我的问题是关于 loading 的。

顺便说一下,“javac 会为每个类自动生成一个类初始化方法”不是完全正确的。

关于什么情况会产生()方法,https://www.artima.com/insidejvm/ed2/lifetype4.html 中描述了很清楚,以下是一些片段:

Not all classes will necessarily have a () method in their class file. If a class declares no class variables or static initializers, it won't have a () method. If a class declares class variables, but doesn't explicitly initialize them with class variable initializers or static initializers, it won't have a () method. If a class contains only class variable initializers for static final variables, and those class variable initializers use compile-time constant expressions, that class won't have a () method. Only those classes that actually require Java code to be executed to initialize class variables to proper initial values will have a class initialization method.

Interfaces may also be awarded a () method in the class file. All fields declared in an interface are implicitly public, static, and final and must be initialized with a field initializer. If an interface has any field initializers that don't resolve at compile-time to a constant, that interface will have a () method.
2020 年 9 月 3 日
回复了 zyfsuzy 创建的主题 › macOS › 谁有 navicat15 mac 版激活码,请他喝咖啡
更可笑的是这么多人帮忙出谋划策😷
我明白了,我 javac Example3c.java 之后,`javap -c Example3c.class `的输出结果如下所示:

Compiled from "Example3c.java"
class Example3c {
Example3c();
Code:
0: aload_0
1: invokespecial #1 // Method java/lang/Object."<init>":()V
4: return

public static void addAndPrint();
Code:
0: iconst_1
1: ldc2_w #2 // double 88.88d
4: invokestatic #4 // Method addTwoTypes:(ID)D
7: dstore_0
8: getstatic #5 // Field java/lang/System.out:Ljava/io/PrintStream;
11: dload_0
12: invokevirtual #6 // Method java/io/PrintStream.println:(D)V
15: return

public static double addTwoTypes(int, double);
Code:
0: iload_0
1: i2d
2: dload_1
3: dadd
4: dreturn
}

注意“1: i2d”,https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-6.html 中的对 i2d 的描述是“Convert int to double”,这也就是为什么 operand stack 需要 four words 的原因。因为不是存储一个 int 和一个 double,是要存储两个 double 。
2020 年 9 月 1 日
回复了 JasonLaw 创建的主题 › Java › 关于 StackOverflowError 和 OutOfMemoryError 的疑惑
@251 #7 我没有说 CRVV 说的有问题,很多回复说的都是对的。但是对的不代表回答了我的问题,我没有说它们的内容是错的,我说的是很多回复都是答非所问,基本并没有正面回答我的两个疑问,而我的疑问更多的是关于书本所说内容的正确性。

如果你觉得“If there is no space for a new stack frame then, the StackOverflowError is thrown by the Java Virtual Machine (JVM).”跟“请求的栈深度大于虚拟机所允许的最大深度”相等的话,那我无话可说。
2020 年 9 月 1 日
回复了 JasonLaw 创建的主题 › Java › 关于 StackOverflowError 和 OutOfMemoryError 的疑惑
说句不好听的话,我感觉回复总是出现一些答非所问,还是希望大家认真阅读题目,然后再回答。如果是我自己没有描述清楚的话,可以直接在回复里面沟通。
2020 年 8 月 31 日
回复了 JasonLaw 创建的主题 › Java › 关于 StackOverflowError 和 OutOfMemoryError 的疑惑
vincenttone 所说的内容来源于 https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-2.html 中的 “2.5.2. Java Virtual Machine Stacks”
@Aresxue #35 我在主题正文就已经说了 COMPACT Row Format 。什么叫不要照本宣科?难道你所说的东西不用有官方文档的支撑吗?如果你的答案是不用的话,那没什么了。

还有,你在 27 楼说“对于 innodb 来说 varchar 会和其他列存在一起”,假定你使用的是 DYNAMIC Row Format,有什么材料可以证明你所说的吗?反正我在 https://dev.mysql.com/doc/refman/8.0/en/innodb-row-format.html#innodb-row-format-dynamic 看到的是“When a table is created with ROW_FORMAT=DYNAMIC, InnoDB can store long variable-length column values (for VARCHAR, VARBINARY, and BLOB and TEXT types) fully off-page, with the clustered index record containing only a 20-byte pointer to the overflow page.”。
@Aresxue #27

https://dev.mysql.com/doc/refman/8.0/en/innodb-row-format.html#innodb-row-format-compact - Tables that use the COMPACT row format store the first 768 bytes of variable-length column values (VARCHAR, VARBINARY, and BLOB and TEXT types) in the index record within the B-tree node, with the remainder stored on overflow pages.

https://dev.mysql.com/doc/refman/8.0/en/optimize-character.html - If a table contains string columns such as name and address, but many queries do not retrieve those columns, consider splitting the string columns into a separate table and using join queries with a foreign key when necessary. When MySQL retrieves any value from a row, it reads a data block containing all the columns of that row (and possibly other adjacent rows). Keeping each row small, with only the most frequently used columns, allows more rows to fit in each data block. Such compact tables reduce disk I/O and memory usage for common queries.
@Infernalzero #22 我在 6 楼已经说了我明白你所说的内容,可能我的题目取得有点不好,除了原文提到的问题,我遗漏了我最关心的问题,为什么使用 text 替换 varchar,后来我也加了附言。你知道为什么要使用 text 替换 varchar 吗?

还有,你说的“你缺乏了一些基础知识的理解”是什么?我想知道。
@crclz 你在说什么?能够详细解释一下吗?
@BQsummer #15

你说“用 text 一般是长度限制”,什么长度限制?我在 9 楼已经回复了关于 varchar 和 text 容量的问题,它们的最大容量是一样的。

关于“使用附加表存储 text”,如果不是顺序获取 clustered index 中的 index record 之类的话,其实根本没有什么影响,比如直接通过主键 id 获取唯一的一行数据的时候。
@cnoder 你说“ varchar 会算在行记录 65535 字节中,text 不占用”,text 不占用是什么?能具体解释一下吗?
@CRUD https://dev.mysql.com/doc/refman/8.0/en/string-type-syntax.html 关于 varchar:A variable-length string. M represents the maximum column length in characters. The range of M is 0 to 65,535. 关于 text:A TEXT column with a maximum length of 65,535 (216 − 1) characters.
@statement 其实我是没怎么看的,因为它只说了应该怎么做,但是没有解释为什么这么做好,为什么这么做不好。
@PopRain
@nekolr

我明白你们所说的,将不常用字段放在附加表可以让一页可以存储主表更多的纪录。可能我没有表达清楚我的问题,我最大的疑问是为什么要将 varchar 换为 text 呢?它们的表现基本是一样的。
2020 年 8 月 27 日
回复了 JasonLaw 创建的主题 › Docker › 由 Docker Redis 组成的 Redis cluster 在 macOS 上无法成功创建
@windghoul #2
@whileFalse #3

我想确认一下我理解的是不是正确的。--network=host 不行是因为 macOS 不支持,单纯使用-p ${i}:${i} -p $((${i} + 10000)):$((${i} + 10000))替换--network=host 不行是因为 redis-cli --cluster create 127.0.0.1:7000 127.0.0.1:7001 127.0.0.1:7002 中的 127.0.0.1 (因为它们这三个容器都有自己的“动态”IP 地址)。对吗?
@yanyueio #1
@skai0dev #2

通过 @palfortime 在“MySQL 时间“不正确”问题 - V2EX”的回答 - https://www.sunp.eu.org/t/700563#reply15,我明白了为什么“在 connection URL string 中设置时区”会将所设置时区的时间存储到 MySQL ?明白了到底是哪里进行这样的处理的?。

在 https://github.com/mysql/mysql-connector-j/blob/79a4336f140499bd22dd07f02b708e163844e3d5/src/main/protocol-impl/java/com/mysql/cj/protocol/a/NativeProtocol.java#L2228 中,会获取到 connection URL string 中所设置的 serverTimezone,最后会设置 serverSession 的 serverTimeZone 。
@skai0dev #2 我有点不太理解“Override detection/mapping of time zone. Used when time zone from server doesn't map to Java time zone”,可以具体解释一下吗?谢谢。
2020 年 8 月 23 日
回复了 JasonLaw 创建的主题 › 数据库 › MySQL 时间“不正确”问题
@palfortime 我不太明白你所说的“mysql 默认认为 CST 是美国那个时区”,我已经设置了时区为 Asia/Shanghai 了。
1 ... 24  25  26  27  28  29  30  31  32  33 ... 38  
❮ ❯
About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   6161 Online   Highest 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 26ms · UTC 03:01 · PVG 11:01 · LAX 20:01 · JFK 23:01
♥ Do have faith in what you're doing.