Giter VIP home page Giter VIP logo

evergreen-java's Introduction

Evergreen Java

Memory Layout of Objects in Java

Compressed OOPs in the JVM

https://www.baeldung.com/jvm-compressed-oops

How To Install

brew tap AdoptOpenJDK/openjdk
brew cask install <version>

java15

ZGC

https://www.baeldung.com/jvm-zgc-garbage-collector

java13

study

Switch Expression

Reference

java11

study

Time

ZoneDateTime

LocalDateTime + Time-Zone

Instant

에포크 타임(EPOCH TIME, 1970-01-01 00:00:00 UTC)부터 경과된 시간을 나노초 단위로 표현한다

OffSet

UTC로 부터 얼마만큼 떨어져 있는지

String

strip

  • 공백 제거 메서드, 유니코드도 제거해준다.

isBlank

  • 공백 체크 메서드, 유니코드도 체크해준다.

lines

  • \n 라인 별로 잘라준다.

repeat

  • 문자열을 반복한다.

HttpClient

자바11에 추가된 Client 라이브러리

block

  @Test
  public void httpClient_block() throws IOException, InterruptedException {
    final HttpClient httpClient = HttpClient.newHttpClient();
    final HttpRequest httpRequest = HttpRequest.newBuilder().uri(URI.create(JAVA11_URL)).GET().build();
    final HttpResponse<String> httpResponse = httpClient.send(httpRequest, HttpResponse.BodyHandlers.ofString());
    assertEquals(httpResponse.body(), "hello");
  }

async

 @Test
  public void httpClient_async() throws IOException, InterruptedException {
    final HttpClient httpClient = HttpClient.newHttpClient();
    final HttpRequest httpRequest = HttpRequest.newBuilder().uri(URI.create(JAVA11_URL)).GET().build();
    CompletableFuture<HttpResponse<String>> future = httpClient.sendAsync(httpRequest, BodyHandlers.ofString());
    future.thenApply(HttpResponse::body)
      .thenAccept(log::info);

    log.info("async");
    Thread.sleep(1000); // shutdown
  }

: 그냥 WebClient 쓰자.

Compact String

  • vm option (default)
-XX:+UseCompressedStrings
  • char[] 가 아닌 byte[]
public final class String
    implements java.io.Serializable, Comparable<String>, CharSequence {

    @Stable
    private final byte[] value;
}
  • How It Works
 private final byte coder;

: LATIN1 / UTF16을 구별하는 필드

public int indexOf(String str) {
        if (coder() == str.coder()) {
            return isLatin1() ? StringLatin1.indexOf(value, str.value)
                              : StringUTF16.indexOf(value, str.value);
        }
        if (coder() == LATIN1) {  // str.coder == UTF16
            return -1;
        }
        return StringUTF16.indexOfLatin1(value, str.value);
    }

: isLatin1() 체크를 통해 StringLantin1 / StringUTF16 으로 나누어 처리한다.

  • Performance Test

: CompactPerformanceTest.class

baeldung-java-tutorial

https://www.baeldung.com/java-tutorial

Native

https://www.baeldung.com/java-native

Beyond Java

https://blog.naver.com/gngh0101/222396980468

evergreen-java's People

Contributors

hotire avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.