This is an automated email from the ASF dual-hosted git repository.

cdutz pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/tsfile.git


The following commit(s) were added to refs/heads/develop by this push:
     new a4b0538c fix: Made the code build with all JDK version (by manually 
defining constants for the individual type sizes)
a4b0538c is described below

commit a4b0538c7e1eb7deb561f472b6983e1d7a38fcba
Author: Christofer Dutz <[email protected]>
AuthorDate: Thu Jan 4 16:58:33 2024 +0100

    fix: Made the code build with all JDK version (by manually defining 
constants for the individual type sizes)
---
 common-api/pom.xml                                 | 12 -------
 .../iotdb/tsfile/utils/RamUsageEstimator.java      | 41 ++++++++++++----------
 pom.xml                                            | 39 +++++++++++++++++++-
 tsfile/pom.xml                                     |  8 -----
 4 files changed, 60 insertions(+), 40 deletions(-)

diff --git a/common-api/pom.xml b/common-api/pom.xml
index db29c076..45d6e1b0 100644
--- a/common-api/pom.xml
+++ b/common-api/pom.xml
@@ -28,18 +28,6 @@
     </parent>
     <artifactId>common-api</artifactId>
     <name>TsFile: Common API</name>
-    <build>
-        <plugins>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-compiler-plugin</artifactId>
-                <configuration>
-                    <source>8</source>
-                    <target>8</target>
-                </configuration>
-            </plugin>
-        </plugins>
-    </build>
     <profiles>
         <profile>
             <id>get-jar-with-dependencies</id>
diff --git 
a/common-api/src/main/java/org/apache/iotdb/tsfile/utils/RamUsageEstimator.java 
b/common-api/src/main/java/org/apache/iotdb/tsfile/utils/RamUsageEstimator.java
index 94841e1b..3aff9494 100644
--- 
a/common-api/src/main/java/org/apache/iotdb/tsfile/utils/RamUsageEstimator.java
+++ 
b/common-api/src/main/java/org/apache/iotdb/tsfile/utils/RamUsageEstimator.java
@@ -33,25 +33,6 @@ import java.util.IdentityHashMap;
 import java.util.Locale;
 import java.util.Map;
 
-import static sun.misc.Unsafe.ARRAY_BOOLEAN_BASE_OFFSET;
-import static sun.misc.Unsafe.ARRAY_BOOLEAN_INDEX_SCALE;
-import static sun.misc.Unsafe.ARRAY_BYTE_BASE_OFFSET;
-import static sun.misc.Unsafe.ARRAY_BYTE_INDEX_SCALE;
-import static sun.misc.Unsafe.ARRAY_CHAR_BASE_OFFSET;
-import static sun.misc.Unsafe.ARRAY_CHAR_INDEX_SCALE;
-import static sun.misc.Unsafe.ARRAY_DOUBLE_BASE_OFFSET;
-import static sun.misc.Unsafe.ARRAY_DOUBLE_INDEX_SCALE;
-import static sun.misc.Unsafe.ARRAY_FLOAT_BASE_OFFSET;
-import static sun.misc.Unsafe.ARRAY_FLOAT_INDEX_SCALE;
-import static sun.misc.Unsafe.ARRAY_INT_BASE_OFFSET;
-import static sun.misc.Unsafe.ARRAY_INT_INDEX_SCALE;
-import static sun.misc.Unsafe.ARRAY_LONG_BASE_OFFSET;
-import static sun.misc.Unsafe.ARRAY_LONG_INDEX_SCALE;
-import static sun.misc.Unsafe.ARRAY_OBJECT_BASE_OFFSET;
-import static sun.misc.Unsafe.ARRAY_OBJECT_INDEX_SCALE;
-import static sun.misc.Unsafe.ARRAY_SHORT_BASE_OFFSET;
-import static sun.misc.Unsafe.ARRAY_SHORT_INDEX_SCALE;
-
 /**
  * This class is copied from apache lucene, version 8.4.0. Estimates the 
size(memory representation)
  * of Java objects. <a
@@ -550,6 +531,28 @@ public final class RamUsageEstimator {
     }
   }
 
+  // These constant values are derived from sun.misc.Unsafe, as referencing 
this class was causing
+  // compilation issues.
+  // TODO: Verify that these values don't actually change from one version of 
the SDK to the other.
+  public static final int ARRAY_OBJECT_BASE_OFFSET = 16;
+  public static final int ARRAY_OBJECT_INDEX_SCALE = 4;
+  public static final int ARRAY_BOOLEAN_BASE_OFFSET = 16;
+  public static final int ARRAY_BOOLEAN_INDEX_SCALE = 1;
+  public static final int ARRAY_BYTE_BASE_OFFSET = 16;
+  public static final int ARRAY_BYTE_INDEX_SCALE = 1;
+  public static final int ARRAY_SHORT_BASE_OFFSET = 16;
+  public static final int ARRAY_SHORT_INDEX_SCALE = 2;
+  public static final int ARRAY_INT_BASE_OFFSET = 16;
+  public static final int ARRAY_INT_INDEX_SCALE = 4;
+  public static final int ARRAY_LONG_BASE_OFFSET = 16;
+  public static final int ARRAY_LONG_INDEX_SCALE = 8;
+  public static final int ARRAY_FLOAT_BASE_OFFSET = 16;
+  public static final int ARRAY_FLOAT_INDEX_SCALE = 4;
+  public static final int ARRAY_DOUBLE_BASE_OFFSET = 16;
+  public static final int ARRAY_DOUBLE_INDEX_SCALE = 8;
+  public static final int ARRAY_CHAR_BASE_OFFSET = 16;
+  public static final int ARRAY_CHAR_INDEX_SCALE = 2;
+
   public static long sizeOfBooleanArray(int length) {
     return ARRAY_BOOLEAN_BASE_OFFSET + (((long) ARRAY_BOOLEAN_INDEX_SCALE) * 
length);
   }
diff --git a/pom.xml b/pom.xml
index 20d340ee..aee23cfd 100644
--- a/pom.xml
+++ b/pom.xml
@@ -36,6 +36,8 @@
         <module>tsfile</module>
     </modules>
     <properties>
+        <maven.compiler.source>1.8</maven.compiler.source>
+        <maven.compiler.target>1.8</maven.compiler.target>
         <argLine/>
     </properties>
     <dependencyManagement>
@@ -129,7 +131,7 @@
                 </plugin>
                 <!--
                     We need to increase the memory available to tests as we 
were
-                    getting out-of-memory errors when building on windows 
machines.
+                    getting out-of-memory errors when building on Windows 
machines.
                 -->
                 <plugin>
                     <groupId>org.apache.maven.plugins</groupId>
@@ -251,6 +253,11 @@
                     <artifactId>antlr4-maven-plugin</artifactId>
                     <version>4.9.3</version>
                 </plugin>
+                <plugin>
+                    <groupId>org.codehaus.mojo</groupId>
+                    <artifactId>build-helper-maven-plugin</artifactId>
+                    <version>3.5.0</version>
+                </plugin>
             </plugins>
         </pluginManagement>
         <plugins>
@@ -656,6 +663,7 @@
                 <jdk>[9,)</jdk>
             </activation>
             <properties>
+                <!-- TODO: This seems to break the build on everything above 
Java 8 -->
                 <maven.compiler.release>8</maven.compiler.release>
             </properties>
         </profile>
@@ -813,5 +821,34 @@
                 <enforcer.skip>false</enforcer.skip>
             </properties>
         </profile>
+        <!--
+            This profile is intended to help when having problems with Maven.
+            When enabled, it automatically generates an "effective.pom" in the 
target directory.
+            This version is the fully expanded version where all inherited 
configuration is in
+            place and all variables are resolved and profile configuration is 
included.
+        -->
+        <profile>
+            <id>debug-pom</id>
+            <build>
+                <plugins>
+                    <plugin>
+                        <groupId>org.apache.maven.plugins</groupId>
+                        <artifactId>maven-help-plugin</artifactId>
+                        <executions>
+                            <execution>
+                                <id>generate-effective-pom</id>
+                                <phase>validate</phase>
+                                <goals>
+                                    <goal>effective-pom</goal>
+                                </goals>
+                                <configuration>
+                                    
<output>${project.build.directory}/effective.pom</output>
+                                </configuration>
+                            </execution>
+                        </executions>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
     </profiles>
 </project>
diff --git a/tsfile/pom.xml b/tsfile/pom.xml
index cf137beb..274b5e80 100644
--- a/tsfile/pom.xml
+++ b/tsfile/pom.xml
@@ -218,14 +218,6 @@
                     </execution>
                 </executions>
             </plugin>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-compiler-plugin</artifactId>
-                <configuration>
-                    <source>8</source>
-                    <target>8</target>
-                </configuration>
-            </plugin>
         </plugins>
     </build>
     <profiles>

Reply via email to