From 56d186f03199c0ebfaee9e7ea519a951772d421e Mon Sep 17 00:00:00 2001 From: Ali Dehghani Date: Tue, 9 Jun 2020 02:23:08 +0430 Subject: [PATCH] Added the Boolean Object Size Samples --- core-java-modules/core-java-jvm/pom.xml | 8 +++++- .../boolsize/BooleanSizeUnitTest.java | 25 +++++++++++++++++++ .../com/baeldung/boolsize/BooleanWrapper.java | 5 ++++ 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 core-java-modules/core-java-jvm/src/test/java/com/baeldung/boolsize/BooleanSizeUnitTest.java create mode 100644 core-java-modules/core-java-jvm/src/test/java/com/baeldung/boolsize/BooleanWrapper.java diff --git a/core-java-modules/core-java-jvm/pom.xml b/core-java-modules/core-java-jvm/pom.xml index 5e731363ae..08e536998c 100644 --- a/core-java-modules/core-java-jvm/pom.xml +++ b/core-java-modules/core-java-jvm/pom.xml @@ -65,7 +65,12 @@ org.apache.bcel bcel ${bcel.version} - + + + org.openjdk.jol + jol-core + ${jol-core.version} + @@ -74,6 +79,7 @@ 3.27.0-GA 2.1.0.1 1.8.0 + 0.10 8.0.1 6.5.0 diff --git a/core-java-modules/core-java-jvm/src/test/java/com/baeldung/boolsize/BooleanSizeUnitTest.java b/core-java-modules/core-java-jvm/src/test/java/com/baeldung/boolsize/BooleanSizeUnitTest.java new file mode 100644 index 0000000000..19c7055438 --- /dev/null +++ b/core-java-modules/core-java-jvm/src/test/java/com/baeldung/boolsize/BooleanSizeUnitTest.java @@ -0,0 +1,25 @@ +package com.baeldung.boolsize; + +import org.junit.Test; +import org.openjdk.jol.info.ClassLayout; +import org.openjdk.jol.vm.VM; + +public class BooleanSizeUnitTest { + + @Test + public void printingTheVMDetails() { + System.out.println(VM.current().details()); + } + + @Test + public void printingTheBoolWrapper() { + System.out.println(ClassLayout.parseClass(BooleanWrapper.class).toPrintable()); + } + + @Test + public void printingTheBoolArray() { + boolean[] value = new boolean[3]; + + System.out.println(ClassLayout.parseInstance(value).toPrintable()); + } +} diff --git a/core-java-modules/core-java-jvm/src/test/java/com/baeldung/boolsize/BooleanWrapper.java b/core-java-modules/core-java-jvm/src/test/java/com/baeldung/boolsize/BooleanWrapper.java new file mode 100644 index 0000000000..1ad164adbc --- /dev/null +++ b/core-java-modules/core-java-jvm/src/test/java/com/baeldung/boolsize/BooleanWrapper.java @@ -0,0 +1,5 @@ +package com.baeldung.boolsize; + +class BooleanWrapper { + private boolean value; +}