Skip to content

Commit e672fdb

Browse files
committed
Merge branch 'master' of https://github.com/GGGGGHT/java8
# Conflicts: # java8/pom.xml
2 parents 5d09cba + c3ee72b commit e672fdb

6 files changed

Lines changed: 741 additions & 27 deletions

File tree

LICENSE

Lines changed: 674 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333
- [ ] skywalking
3434
- [x] eclipse collection
3535
- [ ] jetbrains annotation
36-
- [ ] idea Profiler
36+
- [x] idea Profiler
37+
- [ ] JProfiler
3738

3839
[^2]: https://github.com/spring-projects/spring-boot/pull/31701
3940
## 方法引用
@@ -134,7 +135,7 @@ LL(1)分析法中第一个L表示从左到右处理输入的Token对象;第二
134135

135136

136137
---
137-
# jfr StartFlightRecording配置参数
138+
# jfr [StartFlightRecording配置参数](https://docs.oracle.com/javase/7/docs/technotes/tools/windows/java.html#:~:text=%2DXX%3AStartFlightRecording%3Dparameter%3Dvalue)
138139
|配置key | 默认值 | 说明|
139140
|---|---|---|
140141
|delay | 0 | 延迟多久后启动 JFR 记录,支持带单位配置, 例如 delay=60s(秒), delay=20m(分钟), delay=1h(小时), delay=1d(天),不带单位就是秒, 0就是没有延迟直接开始记录。一般为了避免框架初始化等影响,我们会延迟 1 分钟开始记录(例如Spring cloud应用,可以看下日志中应用启动耗时,来决定下这个时间)|
@@ -146,6 +147,7 @@ LL(1)分析法中第一个L表示从左到右处理输入的Token对象;第二
146147
|maxage | 0 | 这个参数只有在 disk 为 true 的情况下才有效。最大文件记录保存时间,就是 global buffer 满了需要刷入本地临时目录下保存,这些文件最多保留多久的。也可以通过单位配置,没有单位就是秒,默认是0,就是不限制
147148
|maxsize | 250MB | 这个参数只有在 disk 为 true 的情况下才有效。最大文件大小,支持单位配置, 不带单位是字节,m或者M代表MB,g或者G代表GB。设置为0代表不限制大小**。虽然官网说默认就是0,但是实际用的时候,不设置会有提示**: No limit specified, using maxsize=250MB as default. 注意,这个配置不能小于后面将会提到的 maxchunksize 这个参数。
148149
|path-to-gc-roots| false | 是否记录GC根节点到活动对象的路径,一般不打开这个,首先这个在我个人定位问题的时候,很难用到,只要你的编程习惯好。还有就是打开这个,性能损耗比较大,会导致FullGC一般是在怀疑有内存泄漏的时候热启动这种采集,并且通过产生对象堆栈无法定位的时候,动态打开即可。一般通过产生这个对象的堆栈就能定位,如果定位不到,怀疑有其他引用,例如 ThreadLocal 没有释放这样的,可以在 dump 的时候采集 gc roots
150+
|compress|false |指定是否使用 gzip 文件压缩实用程序压缩磁盘上的 JFR 记录日志文件(JFR 类型)。 此参数仅在指定文件名参数时有效。 默认情况下,它设置为 false(记录未压缩)。|
149151

150152
JDK Flight Recorder (JFR) 是一个基于事件的工具,用于监视和分析内置在JDK中的工具。 使用默认设置,JFR 的开销非常低, 基本上<1%,因此可以在生产中使用。
151153
通常从 JFR 中提取信息需要执行转储; 但是,在 JDK 14 中添加的包 jdk.jfr.consumer 提供了用于使用 JFR 事件的 API,而无需执行 JFR 转储。
@@ -155,3 +157,10 @@ java -XX:StartFlightRecording=disk=true,dumponexit=true,filename=recording.jfr,m
155157
```
156158

157159

160+
## Question
161+
- [x] Spring-batch 设置taskExecutor后jackson解析json失败 [See Also](https://stackoverflow.com/questions/73915795/is-there-a-thread-safe-jacksonjsonobjectreader-class-in-spring-batch) 原因是多线程读取json不安全导致
162+
- [x] SpringBoot Web项目没有 main线程 [See Also](https://stackoverflow.com/questions/73896394/there-is-no-main-thread-in-the-springboot-web-project) 原因是main线程的工作已经结束 但是由于进程中有其他非守护线程还在继续工作 所以进程不会退出
163+
- [x] 解决btrace的bug [See Also](https://github.com/btraceio/btrace/pull/584)
164+
- [x] Java8之前打印SafePoint的日志 [See Also](https://stackoverflow.com/questions/62819904/how-can-i-output-the-safepoint-log-in-a-specified-file) 使用`-XX:+LogVMOutput` `-XX:LogFile=logs/hotspot_pid%p.log`这两个参数
165+
- [x] Java 反射 [See Also](https://github.com/openjdk/jdk/blob/master/src/java.base/share/classes/jdk/internal/reflect/NativeMethodAccessorImpl.java#L55) 经过15次调用之后会生成直接调用的方法
166+
- [ ] 测试环境服务经常下线的问题

java8/pom.xml

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
<properties>
1919
<java.version>17</java.version>
20-
<fastjson.version>2.0.12.graal</fastjson.version>
20+
<fastjson.version>2.0.15.graal</fastjson.version>
2121
<commons-lang3.version>3.12.0</commons-lang3.version>
2222
<jmh-version>1.21</jmh-version>
2323
<kotlin.version>1.7.20</kotlin.version>
@@ -122,12 +122,12 @@
122122
<dependency>
123123
<groupId>io.netty</groupId>
124124
<artifactId>netty-all</artifactId>
125-
<version>4.1.81.Final</version>
125+
<version>4.1.84.Final</version>
126126
</dependency>
127127
<dependency>
128128
<groupId>com.google.protobuf</groupId>
129129
<artifactId>protobuf-java</artifactId>
130-
<version>3.21.5</version>
130+
<version>3.21.7</version>
131131
</dependency>
132132
<dependency>
133133
<groupId>dom4j</groupId>
@@ -148,7 +148,7 @@
148148
<dependency>
149149
<groupId>org.springframework.data</groupId>
150150
<artifactId>spring-data-redis</artifactId>
151-
<version>2.7.2</version>
151+
<version>2.7.4</version>
152152
<exclusions>
153153
<exclusion>
154154
<artifactId>spring-data-commons</artifactId>
@@ -159,7 +159,7 @@
159159
<dependency>
160160
<groupId>org.springframework.data</groupId>
161161
<artifactId>spring-data-commons</artifactId>
162-
<version>2.7.2</version>
162+
<version>2.7.4</version>
163163
</dependency>
164164
<dependency>
165165
<groupId>org.springframework.boot</groupId>
@@ -197,31 +197,19 @@
197197
<artifactId>junit-jupiter-api</artifactId>
198198
<version>5.9.0</version>
199199
</dependency>
200-
<!-- <dependency>-->
201-
<!-- <groupId>org.apache.shardingsphere.elasticjob</groupId>-->
202-
<!-- <artifactId>elasticjob-lite-core</artifactId>-->
203-
<!-- <version>3.0.0</version>-->
204-
<!-- </dependency>-->
205-
<!-- <dependency>-->
206-
<!-- <groupId>org.apache.shardingsphere.elasticjob</groupId>-->
207-
<!-- <artifactId>elasticjob-cloud-spring-boot-starter</artifactId>-->
208-
<!-- <version>3.0.1</version>-->
209-
<!-- </dependency>-->
210200
<dependency>
211-
<groupId>org.apache.shardingsphere.elasticjob</groupId>
212-
<artifactId>elasticjob-cloud</artifactId>
213-
<version>3.0.0</version>
201+
<groupId>org.springframework</groupId>
202+
<artifactId>spring-aop</artifactId>
203+
<version>5.3.23</version>
214204
</dependency>
215205
<dependency>
216-
<groupId>org.jetbrains.kotlin</groupId>
217-
<artifactId>kotlin-stdlib-jdk8</artifactId>
218-
<version>${kotlin.version}</version>
206+
<groupId>org.springframework</groupId>
207+
<artifactId>spring-aspects</artifactId>
219208
</dependency>
220209
<dependency>
221-
<groupId>org.jetbrains.kotlin</groupId>
222-
<artifactId>kotlin-test</artifactId>
223-
<version>${kotlin.version}</version>
224-
<scope>test</scope>
210+
<groupId>org.aspectj</groupId>
211+
<artifactId>aspectjrt</artifactId>
212+
<version>1.9.9.1</version>
225213
</dependency>
226214
</dependencies>
227215

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.ggggght.learningjava8.aop;
2+
3+
import org.aspectj.lang.annotation.Aspect;
4+
import org.aspectj.lang.annotation.Before;
5+
import org.aspectj.lang.annotation.Pointcut;
6+
7+
@Aspect
8+
public class AspectConfiguration {
9+
@Pointcut("execution(public * * (..))")
10+
private void anyPublicMethod() {
11+
}
12+
13+
@Before("anyPublicMethod()")
14+
public void beforeAnyPublicMethod() {
15+
System.out.println("@pointcut any public method.");
16+
}
17+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package com.ggggght.learningjava8.aop;
2+
3+
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
4+
import org.springframework.context.annotation.Configuration;
5+
import org.springframework.context.annotation.EnableAspectJAutoProxy;
6+
7+
@Configuration
8+
@EnableAspectJAutoProxy
9+
public class AspectJAnnotatedPointcutDemo {
10+
public static void main(String[] args) {
11+
var context = new AnnotationConfigApplicationContext();
12+
context.register(AspectJAnnotatedPointcutDemo.class, AspectConfiguration.class);
13+
context.refresh();
14+
15+
var demoBean = context.getBean(AspectJAnnotatedPointcutDemo.class);
16+
demoBean.execute();
17+
context.close();
18+
}
19+
20+
public void execute() {
21+
System.out.println("AspectJAnnotatedPointcutDemo#execute");
22+
}
23+
}

java8/src/main/java/com/ggggght/learningjava8/aop/TargetFilterDemo.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
import java.lang.reflect.Method;
44
import org.springframework.util.ReflectionUtils;
55

6+
/**
7+
* use <b>-Dsun.misc.ProxyGenerator.saveGeneratedFiles=true</b> to generate class file
8+
*/
69
public class TargetFilterDemo {
710
public static void main(String[] args) throws ClassNotFoundException {
811
String targetClassName = "com.ggggght.learningjava8.Learningjava8Application";

0 commit comments

Comments
 (0)