Skip to content

Instantly share code, notes, and snippets.

@marschall
marschall / oracle_calendar.sql
Created Aug 2, 2019
Shows the Oracle calendar is not proleptic
View oracle_calendar.sql
WITH calendar(date_value) AS (
SELECT TIMESTAMP '1582-09-30 00:00:00'
FROM dual
UNION ALL
SELECT date_value + 1
FROM calendar
WHERE date_value <= TIMESTAMP '1582-10-16 00:00:00'
)
SELECT date_value
FROM calendar;
View PortableDecimalFormatTest.java
class PortableDecimalFormatTest {
@Test
void decimalFormat() {
Locale switzerland = new Locale("de", "CH");
DecimalFormat format = (DecimalFormat) NumberFormat.getInstance(switzerland);
format.applyPattern("#,##0.00");
DecimalFormatSymbols decimalFormatSymbols = format.getDecimalFormatSymbols();
decimalFormatSymbols.setGroupingSeparator('\'');
// important because #getDecimalFormatSymbols() returns a clone
@marschall
marschall / SwissDecimalFormatTest.java
Created Mar 5, 2019
Decimal Formatting Changes in Java 11
View SwissDecimalFormatTest.java
class SwissDecimalFormatTest {
@Test
void decimalFormat() {
Locale switzerland = new Locale("de", "CH");
DecimalFormat format = (DecimalFormat) NumberFormat.getInstance(switzerland);
format.applyPattern("#,##0.00");
String formatted = format.format(new BigDecimal("1234567.8"));
assertEquals("1'234'567.80", formatted);
@marschall
marschall / val.jsh
Created Mar 30, 2018
val is not a keyword
View val.jsh
class val {}
val val = new val()
View jmc-jpms-warning.txt
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.eclipse.emf.ecore.xmi.impl.XMLHandler (file:/Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/Home/lib/missioncontrol/plugins/org.eclipse.emf.ecore.xmi_2.12.0.v20160420-0247.jar) to method com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser$LocatorProxy.getEncoding()
WARNING: Please consider reporting this to the maintainers of org.eclipse.emf.ecore.xmi.impl.XMLHandler
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
@marschall
marschall / Graal
Created Aug 20, 2017
UUID parsing performance
View Graal
$java -version
openjdk version "1.8.0_121"
OpenJDK Runtime Environment (build 1.8.0_121-b13)
OpenJDK 64-Bit Graal VM (build 25.71-b01-internal-jvmci-0.30, mixed mode)
Result "com.github.marschall.charsequences.ParseUuidBenchmark.parseJdk":
2.411 ±(99.9%) 0.014 ops/us [Average]
(min, avg, max) = (2.124, 2.411, 2.462), stdev = 0.043
CI (99.9%): [2.396, 2.425] (assumes normal distribution)
@marschall
marschall / glassfish-all-jdeprscan.txt
Created Oct 13, 2016
jdeprscan on application servers
View glassfish-all-jdeprscan.txt
class com/sun/ejb/containers/EJBContextImpl uses type java/security/Identity deprecated FOR REMOVAL
class com/sun/ejb/containers/EJBContextImpl uses method in type java/security/Identity deprecated FOR REMOVAL
class com/sun/ejb/containers/EJBContextImpl method getCallerIdentity has return type Ljava/security/Identity; deprecated FOR REMOVAL
class com/sun/ejb/containers/EJBContextImpl method isCallerInRole has parameter type Ljava/security/Identity; deprecated FOR REMOVAL
class com/sun/enterprise/security/PolicyLoader uses type javax/security/auth/Policy deprecated FOR REMOVAL
class com/sun/enterprise/security/PolicyLoader uses method in type javax/security/auth/Policy deprecated FOR REMOVAL
class com/sun/enterprise/security/PolicyLoader uses method in type javax/security/auth/Policy deprecated FOR REMOVAL
class com/sun/enterprise/security/ssl/GlassfishSSLSupport uses type [Ljavax/security/cert/X509Certificate; deprecated FOR REMOVAL
class com/sun/enterprise/security/ssl/GlassfishSSLSupport uses type javax/sec
View gist:3f97e487c24e545b4a17689b0c236f24
$JAVA_HOME/bin/jdeprscan --for-removal --release 9 oracle-javaee-api-7.0.jar
interface javax/ejb/EJBContext method getCallerIdentity has return type Ljava/security/Identity; deprecated FOR REMOVAL
interface javax/ejb/EJBContext method isCallerInRole has parameter type Ljava/security/Identity; deprecated FOR REMOVAL
View FasterGame.java
class Vector
{
public float x, y, z;
public Vector(float x, float y, float z)
{
this.x = x;
this.y = y;
this.z = z;
}
View SequenceableCollection.java
public class SequenceableCollection {
public static <T> List<T> streamContents(Supplier<List<T>> constructor, Consumer<Consumer<T>> block) {
List<T> result = constructor.get();
block.accept(each -> result.add(each));
return result;
}
public static List<String> example(ResultSet rs) {
return streamContents(ArrayList::new, (accumulator) -> {