1
0
mirror of https://github.com/Snailclimb/JavaGuide synced 2025-08-10 00:41:37 +08:00

Compare commits

...

6 Commits

Author SHA1 Message Date
Guide
d9dcedbd64
Merge pull request #2100 from JacketFu/main
Update unsafe.md
2023-07-31 22:39:17 +08:00
Guide
c8e459c808
Merge pull request #2099 from Teamop/patch-1
Fix format
2023-07-31 22:38:42 +08:00
Guide
62721ec58a
Merge pull request #2101 from Conquers/main
Update proxy.md
2023-07-31 22:38:06 +08:00
wtt
84737ecc55 Update proxy.md 2023-07-31 22:10:22 +08:00
fu
9d802717c2
Update unsafe.md 2023-07-31 17:17:03 +08:00
Terry
158fcc10e6
fix format 2023-07-31 15:32:43 +08:00
3 changed files with 6 additions and 4 deletions

View File

@ -229,7 +229,7 @@ public class DebugInvocationHandler implements InvocationHandler {
public class JdkProxyFactory {
public static Object getProxy(Object target) {
return Proxy.newProxyInstance(
target.getClass().getClassLoader(), // 目标类的类加载
target.getClass().getClassLoader(), // 目标类的类加载
target.getClass().getInterfaces(), // 代理需要实现的接口,可指定多个
new DebugInvocationHandler(target) // 代理对象对应的自定义 InvocationHandler
);

View File

@ -654,7 +654,8 @@ private void staticTest() throws Exception {
运行结果:
```
falseHydra
false
Hydra
```
`Unsafe` 的对象操作中,我们学习了通过`objectFieldOffset`方法获取对象属性偏移量并基于它对变量的值进行存取,但是它不适用于类中的静态属性,这时候就需要使用`staticFieldOffset`方法。在上面的代码中,只有在获取`Field`对象的过程中依赖到了`Class`,而获取静态变量的属性时不再依赖于`Class`
@ -662,7 +663,8 @@ falseHydra
在上面的代码中首先创建一个`User`对象,这是因为如果一个类没有被初始化,那么它的静态属性也不会被初始化,最后获取的字段属性将是`null`。所以在获取静态属性前,需要调用`shouldBeInitialized`方法,判断在获取前是否需要初始化这个类。如果删除创建 User 对象的语句,运行结果会变为:
```
truenull
true
null
```
**使用`defineClass`方法允许程序在运行时动态地创建一个类**

View File

@ -74,7 +74,7 @@ public class OrdersService {
>
> 翻译过来的意思是:原子性,隔离性和持久性是数据库的属性,而一致性(在 ACID 意义上)是应用程序的属性。应用可能依赖数据库的原子性和隔离属性来实现一致性,但这并不仅取决于数据库。因此,字母 C 不属于 ACID 。
《Designing Data-Intensive Application数据密集型应用系统设计》这本书强推一波值得读很多遍豆瓣有接近 90% 的人看了这本书之后给了五星好评。另外,中文翻译版本已经在 GitHub 开源,地址:[https://github.com/Vonng/ddiaopen in new window](https://github.com/Vonng/ddia) 。
《Designing Data-Intensive Application数据密集型应用系统设计》这本书强推一波值得读很多遍豆瓣有接近 90% 的人看了这本书之后给了五星好评。另外,中文翻译版本已经在 GitHub 开源,地址:[https://github.com/Vonng/ddia](https://github.com/Vonng/ddia) 。
## 详谈 Spring 对事务的支持