Unverified 提交 4fc4485a authored 作者: Noel Grandin's avatar Noel Grandin 提交者: GitHub

Merge pull request #783 from katzyn/Multi-Release

Add Bits implementation for Java 9 and later versions
/*
* Copyright 2004-2018 H2 Group. Multiple-Licensed under the MPL 2.0,
* and the EPL 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.util;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.VarHandle;
import java.nio.ByteOrder;
import java.util.UUID;
/**
* Manipulations with bytes and arrays. Specialized implementation for Java 9
* and later versions.
*/
public final class Bits {
/**
* VarHandle giving access to elements of a byte[] array viewed as if it were a
* int[] array on big-endian system.
*/
private static final VarHandle INT_VH = MethodHandles.byteArrayViewVarHandle(int[].class, ByteOrder.BIG_ENDIAN);
/**
* VarHandle giving access to elements of a byte[] array viewed as if it were a
* long[] array on big-endian system.
*/
private static final VarHandle LONG_VH = MethodHandles.byteArrayViewVarHandle(long[].class, ByteOrder.BIG_ENDIAN);
/**
* Reads a int value from the byte array at the given position in big-endian
* order.
*
* @param buff
* the byte array
* @param pos
* the position
* @return the value
*/
public static int readInt(byte[] buff, int pos) {
return (int) INT_VH.get(buff, pos);
}
/**
* Reads a long value from the byte array at the given position in big-endian
* order.
*
* @param buff
* the byte array
* @param pos
* the position
* @return the value
*/
public static long readLong(byte[] buff, int pos) {
return (long) LONG_VH.get(buff, pos);
}
/**
* Converts UUID value to byte array in big-endian order.
*
* @param msb
* most significant part of UUID
* @param lsb
* least significant part of UUID
* @return byte array representation
*/
public static byte[] uuidToBytes(long msb, long lsb) {
byte[] buff = new byte[16];
LONG_VH.set(buff, 0, msb);
LONG_VH.set(buff, 8, lsb);
return buff;
}
/**
* Converts UUID value to byte array in big-endian order.
*
* @param uuid
* UUID value
* @return byte array representation
*/
public static byte[] uuidToBytes(UUID uuid) {
return uuidToBytes(uuid.getMostSignificantBits(), uuid.getLeastSignificantBits());
}
/**
* Writes a int value to the byte array at the given position in big-endian
* order.
*
* @param buff
* the byte array
* @param pos
* the position
* @param x
* the value to write
*/
public static void writeInt(byte[] buff, int pos, int x) {
INT_VH.set(buff, pos, x);
}
/**
* Writes a long value to the byte array at the given position in big-endian
* order.
*
* @param buff
* the byte array
* @param pos
* the position
* @param x
* the value to write
*/
public static void writeLong(byte[] buff, int pos, long x) {
LONG_VH.set(buff, pos, x);
}
private Bits() {
}
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
Copyright 2004-2018 H2 Group. Multiple-Licensed under the MPL 2.0, Version 1.0,
and under the Eclipse Public License, Version 1.0
Initial Developer: H2 Group
-->
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head><meta http-equiv="Content-Type" content="text/html;charset=utf-8" /><title>
Javadoc package documentation
</title></head><body style="font: 9pt/130% Tahoma, Arial, Helvetica, sans-serif; font-weight: normal;"><p>
Internal utility classes reimplemented for Java 9 and later versions.
</p></body></html>
\ No newline at end of file
......@@ -13,6 +13,7 @@ Bundle-Vendor: H2 Group
Bundle-Version: ${version}
Bundle-License: http://www.h2database.com/html/license.html
Bundle-Category: jdbc
Multi-Release: true
Import-Package: javax.management,
javax.naming;resolution:=optional,
javax.naming.spi;resolution:=optional,
......
......@@ -14,6 +14,12 @@ import java.util.UUID;
*/
public final class Bits {
/*
* Signatures of methods should match with
* h2/src/java9/src/org/h2/util/Bits.java and precompiled
* h2/src/java9/precompiled/org/h2/util/Bits.class.
*/
/**
* Reads a int value from the byte array at the given position in big-endian
* order.
......
......@@ -446,8 +446,10 @@ public class Build extends BuildBase {
@Description(summary = "Create the regular h2.jar file.")
public void jar() {
compile();
FileList files = files("src/java9/precompiled");
copy("temp/META-INF/versions/9", files, "src/java9/precompiled");
manifest("H2 Database Engine", "org.h2.tools.Console");
FileList files = files("temp").
files = files("temp").
exclude("temp/android/*").
exclude("temp/org/h2/android/*").
exclude("temp/org/h2/build/*").
......
......@@ -30,7 +30,7 @@ public class CheckTextFiles {
"Driver", "Processor", "prefs" };
private static final String[] SUFFIX_IGNORE = { "gif", "png", "odg", "ico",
"sxd", "layout", "res", "win", "jar", "task", "svg", "MF", "mf",
"sh", "DS_Store", "prop" };
"sh", "DS_Store", "prop", "class" };
private static final String[] SUFFIX_CRLF = { "bat" };
private static final boolean ALLOW_TAB = false;
......
......@@ -31,7 +31,7 @@ public class SpellChecker {
"properties", "task", "MF", "mf", "sh", "" };
private static final String[] IGNORE = { "dev", "nsi", "gif", "png", "odg",
"ico", "sxd", "zip", "bz2", "rc", "layout", "res", "dll", "jar",
"svg", "prefs", "prop", "iml" };
"svg", "prefs", "prop", "iml", "class" };
private static final String DELIMITERS =
" \n.();-\"=,*/{}_<>+\r:'@[]&\\!#|?$^%~`\t";
private static final String PREFIX_IGNORE = "abc";
......
......@@ -757,4 +757,5 @@ chittanoor carrot
contextual unknowns enquote respectively sessionid reconnection selfreferential bbddbb instant subprotocol ddbbbb
zzbbzz cldr booleans maria enquotes mtc cbuf checksummed nreturn despite bbzz readlimit retries cceecc reconnects
unconditionally coco aren eecccc decimals charsets zzbb lsb msb usecount outdir endian
unconditionally coco aren eecccc decimals charsets zzbb lsb msb usecount outdir endian misleading precompiled
assorted reimplemented hangups confirmation predefined
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论