mirror of
https://github.com/Snailclimb/JavaGuide
synced 2025-08-10 00:41:37 +08:00
Compare commits
6 Commits
ef45856b5e
...
d9dcedbd64
Author | SHA1 | Date | |
---|---|---|---|
|
d9dcedbd64 | ||
|
c8e459c808 | ||
|
62721ec58a | ||
|
84737ecc55 | ||
|
9d802717c2 | ||
|
158fcc10e6 |
@ -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
|
||||
);
|
||||
|
@ -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`方法允许程序在运行时动态地创建一个类**
|
||||
|
@ -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 对事务的支持
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user