Hello community,

here is the log from the commit of package java-9-openjdk for openSUSE:Factory 
checked in at 2017-12-10 18:13:12
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/java-9-openjdk (Old)
 and      /work/SRC/openSUSE:Factory/.java-9-openjdk.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "java-9-openjdk"

Sun Dec 10 18:13:12 2017 rev:17 rq:554962 version:9.0.1.0

Changes:
--------
--- /work/SRC/openSUSE:Factory/java-9-openjdk/java-9-openjdk.changes    
2017-11-11 14:18:30.689607021 +0100
+++ /work/SRC/openSUSE:Factory/.java-9-openjdk.new/java-9-openjdk.changes       
2017-12-10 18:13:13.955233049 +0100
@@ -1,0 +2,22 @@
+Thu Dec  7 10:05:19 UTC 2017 - [email protected]
+
+- The macro bits was not defined for aarch64 and some other
+  architectures (bsc#1071624)
+
+-------------------------------------------------------------------
+Fri Dec  1 09:46:16 UTC 2017 - [email protected]
+
+- Run TestCryptoLevel and TestECDSA as a part of build to assure
+  that the crypto works as expected
+
+-------------------------------------------------------------------
+Fri Dec  1 08:04:07 UTC 2017 - [email protected]
+
+- Added patch:
+  * java9-improved-fonts.patch
+    + Imports IMPROVED_FONT_RENDERING from OpenJDK 1.8.0 to use
+      system fontconfig settings instead of hardcoded flags
+    + Adds fontconfig dependency
+- Enabled IMPROVED_FONT_RENDERING
+
+-------------------------------------------------------------------

New:
----
  TestCryptoLevel.java
  TestECDSA.java
  java9-improved-fonts.patch

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ java-9-openjdk.spec ++++++
--- /var/tmp/diff_new_pack.z7BS2M/_old  2017-12-10 18:13:16.315120646 +0100
+++ /var/tmp/diff_new_pack.z7BS2M/_new  2017-12-10 18:13:16.315120646 +0100
@@ -87,6 +87,9 @@
 %ifarch x86_64 ia64 s390x
 %global bits 64
 %endif
+%if 0%{?__isa_bits}
+%global bits %{__isa_bits}
+%endif
 # Turn on/off some features depending on openSUSE version
 %if 0%{?suse_version} > 1320
 %global with_system_pcsc 1
@@ -149,6 +152,10 @@
 Source12:       policytool.desktop.in
 # nss configuration file
 Source13:       nss.cfg
+# Ensure we aren't using the limited crypto policy
+Source14:       TestCryptoLevel.java
+# Ensure ECDSA is working
+Source15:       TestECDSA.java
 # New versions of config files with aarch64 support. This is not upstream yet.
 Source100:      config.guess
 Source101:      config.sub
@@ -190,6 +197,7 @@
 #
 Patch400:       jaw-misc.patch
 Patch401:       jaw-jdk9.patch
+Patch800:       java9-improved-fonts.patch
 BuildRequires:  alsa-lib-devel
 BuildRequires:  autoconf
 BuildRequires:  automake
@@ -489,6 +497,8 @@
 %patch302 -p1
 %patch303 -p1
 
+%patch800 -p1
+
 %patch400
 %patch401
 
@@ -537,11 +547,11 @@
 export CFLAGS="$CFLAGS -mieee"
 %endif
 
-EXTRA_CFLAGS="-Wno-error"
-EXTRA_CPP_FLAGS="-Wno-error"
+EXTRA_CFLAGS="-Wno-error -DIMPROVED_FONT_RENDERING"
+EXTRA_CPP_FLAGS="-Wno-error -DIMPROVED_FONT_RENDERING"
 
 %ifarch ppc64 ppc64le ppc
-EXTRA_CFLAGS="$EXTRA_CFLAGS -fno-tree-vectorize -fno-strict-aliasing"
+EXTRA_CFLAGS="$EXTRA_CFLAGS -fno-strict-aliasing"
 %endif
 
 %if 0%{?suse_version} >= 1330
@@ -677,6 +687,15 @@
   nm -aCl "$ZERO_JVM" | grep javaCalls.cpp
 fi
 
+# Check unlimited policy has been used
+$JAVA_HOME/bin/javac -d . %{SOURCE14}
+$JAVA_HOME/bin/java --add-opens java.base/javax.crypto=ALL-UNNAMED 
TestCryptoLevel
+
+# Check ECC is working
+$JAVA_HOME/bin/javac -d . %{SOURCE15}
+#FIXME make it run after system NSS support?
+$JAVA_HOME/bin/java $(echo $(basename %{SOURCE15})|sed "s|\.java||") || true
+
 %install
 export LANG=en_US.UTF-8
 #bnc#530046

++++++ TestCryptoLevel.java ++++++
/* TestCryptoLevel -- Ensure unlimited crypto policy is in use.
   Copyright (C) 2012 Red Hat, Inc.

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.InvocationTargetException;

import java.security.Permission;
import java.security.PermissionCollection;

public class TestCryptoLevel
{
  public static void main(String[] args)
    throws NoSuchFieldException, ClassNotFoundException,
           IllegalAccessException, InvocationTargetException
  {
    Class<?> cls = null;
    Method def = null, exempt = null;

    try
      {
        cls = Class.forName("javax.crypto.JceSecurity");
      }
    catch (ClassNotFoundException ex)
      {
        System.err.println("Running a non-Sun JDK.");
        System.exit(0);
      }
    try
      {
        def = cls.getDeclaredMethod("getDefaultPolicy");
        exempt = cls.getDeclaredMethod("getExemptPolicy");
      }
    catch (NoSuchMethodException ex)
      {
        System.err.println("Running IcedTea with the original crypto patch.");
        System.exit(0);
      }
    def.setAccessible(true);
    exempt.setAccessible(true);
    PermissionCollection defPerms = (PermissionCollection) def.invoke(null);
    PermissionCollection exemptPerms = (PermissionCollection) 
exempt.invoke(null);
    Class<?> apCls = Class.forName("javax.crypto.CryptoAllPermission");
    Field apField = apCls.getDeclaredField("INSTANCE");
    apField.setAccessible(true);
    Permission allPerms = (Permission) apField.get(null);
    if (defPerms.implies(allPerms) && (exemptPerms == null || 
exemptPerms.implies(allPerms)))
      {
        System.err.println("Running with the unlimited policy.");
        System.exit(0);
      }
    else
      {
        System.err.println("WARNING: Running with a restricted crypto policy.");
        System.exit(-1);
      }
  }
}
++++++ TestECDSA.java ++++++
/* TestECDSA -- Ensure ECDSA signatures are working.
   Copyright (C) 2016 Red Hat, Inc.

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

import java.math.BigInteger;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.Signature;

/**
 * @test
 */
public class TestECDSA {

    public static void main(String[] args) throws Exception {
        KeyPairGenerator keyGen = KeyPairGenerator.getInstance("EC");
        KeyPair key = keyGen.generateKeyPair();
        
        byte[] data = "This is a string to sign".getBytes("UTF-8");
        
        Signature dsa = Signature.getInstance("NONEwithECDSA");
        dsa.initSign(key.getPrivate());
        dsa.update(data);
        byte[] sig = dsa.sign();
        System.out.println("Signature: " + new BigInteger(1, sig).toString(16));
        
        Signature dsaCheck = Signature.getInstance("NONEwithECDSA");
        dsaCheck.initVerify(key.getPublic());
        dsaCheck.update(data);
        boolean success = dsaCheck.verify(sig);
        if (!success) {
            throw new RuntimeException("Test failed. Signature verification 
error");
        }
        System.out.println("Test passed.");
    }
}
++++++ java9-improved-fonts.patch ++++++
--- jdk9/jdk/make/lib/Awt2dLibraries.gmk.org    2017-07-27 21:04:48.000000000 
+0300
+++ jdk9/jdk/make/lib/Awt2dLibraries.gmk        2017-10-06 20:11:05.824660829 
+0300
@@ -689,7 +689,7 @@
     LDFLAGS_macosx := -undefined dynamic_lookup, \
     LIBS := $(BUILD_LIBFONTMANAGER_FONTLIB), \
     LIBS_unix := -lawt -ljava -ljvm $(LIBM) $(LIBCXX), \
-    LIBS_linux := -lc, \
+    LIBS_linux := -lc -lfontconfig, \
     LIBS_solaris := -lawt_headless -lc, \
     LIBS_aix := -lawt_headless,\
     LIBS_windows := $(WIN_JAVA_LIB) advapi32.lib user32.lib gdi32.lib \
--- jdk9/jdk/src/java.desktop/share/native/libfontmanager/freetypeScaler.c.org  
2017-07-27 21:04:48.000000000 +0300
+++ jdk9/jdk/src/java.desktop/share/native/libfontmanager/freetypeScaler.c      
2017-10-06 20:00:58.000000000 +0300
@@ -38,6 +38,10 @@
 #include FT_SIZES_H
 #include FT_OUTLINE_H
 #include FT_SYNTHESIS_H
+#ifdef IMPROVED_FONT_RENDERING
+#include FT_LCD_FILTER_H
+#include <fontconfig/fontconfig.h>
+#endif
 
 #include "fontscaler.h"
 
@@ -652,6 +656,162 @@
     }
 }
 
+#ifdef IMPROVED_FONT_RENDERING
+typedef struct {
+    FT_Render_Mode ftRenderMode;
+    int ftLoadFlags;
+    FT_LcdFilter ftLcdFilter;
+} RenderingProperties;
+
+static FcPattern* matchedPattern(const FcChar8* family, double ptSize) {
+    /*
+      we will create pattern to find our family and size in
+      fontconfig configuration, and then will return it's
+      properties:
+    */
+    FcPattern* fcPattern = 0;
+    fcPattern = FcPatternCreate();
+    FcValue fcValue;
+    fcValue.type = FcTypeString;
+    fcValue.u.s = family;
+    FcPatternAdd(fcPattern, FC_FAMILY, fcValue, FcTrue);
+    FcPatternAddBool(fcPattern, FC_SCALABLE, FcTrue);
+    FcPatternAddDouble(fcPattern, FC_SIZE, ptSize);
+    // TODO FcPatternAddInteger(pattern, FC_WEIGHT, weight_value);
+    // TODO FcPatternAddInteger(pattern, FC_SLANT, slant_value);
+    // TODO FcPatternAddDouble(pattern, FC_PIXEL_SIZE, size_value);
+    // TODO FcPatternAddInteger(pattern, FC_WIDTH, stretch); 100 in most cases
+    FcConfigSubstitute(0, fcPattern, FcMatchPattern);
+    FcConfigSubstitute(0, fcPattern, FcMatchFont);
+    FcDefaultSubstitute(fcPattern);
+    FcResult res;
+
+    FcPattern *pattern = 0;
+    pattern = FcFontMatch(0, fcPattern, &res);
+    FcPatternDestroy(fcPattern);
+    return pattern;
+}
+
+static void readFontconfig(const FcChar8* family, FTScalerContext *context, 
RenderingProperties* rp) {
+
+    FcPattern *pattern = matchedPattern(family, context->ptsz);
+
+    int ftLoadFalgs = FT_LOAD_DEFAULT;
+    FT_Render_Mode ftRenderMode;
+    FT_LcdFilter ftLcdFilter;
+    char horizontal = 1;
+    FcBool fcAntialias = false, fcBool;
+
+    // If the user has no antialias information set in their fontconfig 
directory
+    // and the font itself does not provide any hints either (which is common),
+    // Fontconfig may not return any antialias hint about the selected font 
since
+    // it does not set any default for this key internally.
+    // Use the antialias hint when it is available but only if antialiasing was
+    // actually requested by the caller.
+    // If antialiasing was requested but Fontconfig states to use no 
antialiasing,
+    // that takes precedence and also modifies the supplied context to account 
for
+    // the change (sets context->aaType to TEXT_AA_OFF as a side-effect in the 
render
+    // mode conditional block down below).
+    if (context->aaType != TEXT_AA_OFF) {
+        if (FcPatternGetBool(pattern, FC_ANTIALIAS, 0, &fcAntialias) != 
FcResultMatch)
+            fcAntialias = true;
+    }
+
+    // render mode:
+    if (fcAntialias) {
+        if (context->aaType == TEXT_AA_ON)
+            ftRenderMode = FT_RENDER_MODE_NORMAL;
+        else {
+            // subpixel order:
+            int subpixel = FC_RGBA_UNKNOWN;
+            FcPatternGetInteger(pattern, FC_RGBA, 0, &subpixel);
+            if (subpixel == FC_RGBA_UNKNOWN)
+                subpixel = FC_RGBA_NONE;
+            switch (subpixel) {
+            case FC_RGBA_NONE:
+                ftRenderMode = FT_RENDER_MODE_NORMAL;
+                break;
+            case FC_RGBA_RGB:
+            case FC_RGBA_BGR:
+                ftRenderMode = FT_RENDER_MODE_LCD;
+                horizontal = 1;
+                break;
+            case FC_RGBA_VRGB:
+            case FC_RGBA_VBGR:
+                ftRenderMode = FT_RENDER_MODE_LCD_V;
+                horizontal = 0;
+                break;
+            default:
+                break;
+            }
+        }
+    } else {
+        ftRenderMode = FT_RENDER_MODE_MONO;
+        context->aaType = TEXT_AA_OFF; // if this was forced through Fontconfig
+   }
+
+    // loading mode:
+    if (!fcAntialias)
+        ftLoadFalgs |= FT_LOAD_TARGET_MONO;
+    else {
+        int hint_style = FC_HINT_NONE;
+        FcPatternGetInteger(pattern, FC_HINT_STYLE, 0, &hint_style);
+        switch (hint_style) {
+        case FC_HINT_NONE:
+            ftLoadFalgs |= FT_LOAD_NO_HINTING;
+            break;
+        case FC_HINT_SLIGHT:
+            ftLoadFalgs |= FT_LOAD_TARGET_LIGHT;
+            break;
+        case FC_HINT_MEDIUM:
+            ftLoadFalgs |= FT_LOAD_TARGET_NORMAL;
+            break;
+        case FC_HINT_FULL:
+            if (fcAntialias)
+                ftLoadFalgs |= FT_LOAD_TARGET_NORMAL;
+            else
+                ftLoadFalgs |= horizontal ? FT_LOAD_TARGET_LCD : 
FT_LOAD_TARGET_LCD_V;
+            break;
+        default:
+            // what else to use as default?
+            ftLoadFalgs |= FT_LOAD_TARGET_NORMAL;
+            break;
+        }
+    }
+
+    // autohinting:
+    if (FcPatternGetBool(pattern, FC_AUTOHINT, 0, &fcBool) == FcResultMatch && 
fcBool)
+        ftLoadFalgs |= FT_LOAD_FORCE_AUTOHINT;
+
+    // LCD filter:
+    int filter = FC_LCD_DEFAULT;
+    FcPatternGetInteger(pattern, FC_LCD_FILTER, 0, &filter);
+    switch (filter) {
+    case FC_LCD_NONE:
+        ftLcdFilter = FT_LCD_FILTER_NONE;
+        break;
+    case FC_LCD_DEFAULT:
+        ftLcdFilter = FT_LCD_FILTER_DEFAULT;
+        break;
+    case FC_LCD_LIGHT:
+        ftLcdFilter = FT_LCD_FILTER_LIGHT;
+        break;
+    case FC_LCD_LEGACY:
+        ftLcdFilter = FT_LCD_FILTER_LEGACY;
+        break;
+    default:
+        // new unknown lcd filter type?! will use default one:
+        ftLcdFilter = FT_LCD_FILTER_DEFAULT;
+        break;
+    }
+
+    FcPatternDestroy(pattern);
+
+    rp->ftRenderMode = ftRenderMode;
+    rp->ftLoadFlags = ftLoadFalgs;
+    rp->ftLcdFilter = ftLcdFilter;
+}
+#endif
 
 /*
  * Class:     sun_font_FreetypeFontScaler
@@ -667,7 +827,9 @@
     UInt16 width, height;
     GlyphInfo *glyphInfo;
     int glyph_index;
+#ifndef IMPROVED_FONT_RENDERING
     int renderFlags = FT_LOAD_RENDER, target;
+#endif
     FT_GlyphSlot ftglyph;
 
     FTScalerContext* context =
@@ -685,6 +847,11 @@
         return ptr_to_jlong(getNullGlyphImage());
     }
 
+#ifdef IMPROVED_FONT_RENDERING
+    RenderingProperties renderingProperties;
+    readFontconfig((const FcChar8 *) scalerInfo->face->family_name,
+                   context, &renderingProperties);
+#else
     /* if algorithmic styling is required then we do not request bitmap */
     if (context->doBold || context->doItalize) {
         renderFlags =  FT_LOAD_DEFAULT;
@@ -707,10 +874,17 @@
         target = FT_LOAD_TARGET_LCD_V;
     }
     renderFlags |= target;
+#endif
 
     glyph_index = FT_Get_Char_Index(scalerInfo->face, glyphCode);
 
+#ifdef IMPROVED_FONT_RENDERING
+    FT_Library_SetLcdFilter(scalerInfo->library, 
renderingProperties.ftLcdFilter);
+    error = FT_Load_Glyph(scalerInfo->face, glyphCode, 
renderingProperties.ftLoadFlags);
+#else
     error = FT_Load_Glyph(scalerInfo->face, glyphCode, renderFlags);
+#endif
+
     if (error) {
         //do not destroy scaler yet.
         //this can be problem of particular context (e.g. with bad transform)
@@ -729,9 +903,13 @@
 
     /* generate bitmap if it is not done yet
      e.g. if algorithmic styling is performed and style was added to outline */
+#ifdef IMPROVED_FONT_RENDERING
+    FT_Render_Glyph(ftglyph, renderingProperties.ftRenderMode);
+#else
     if (ftglyph->format == FT_GLYPH_FORMAT_OUTLINE) {
         FT_Render_Glyph(ftglyph, FT_LOAD_TARGET_MODE(target));
     }
+#endif
 
     width  = (UInt16) ftglyph->bitmap.width;
     height = (UInt16) ftglyph->bitmap.rows;
@@ -945,7 +1123,9 @@
 static FT_Outline* getFTOutline(JNIEnv* env, jobject font2D,
         FTScalerContext *context, FTScalerInfo* scalerInfo,
         jint glyphCode, jfloat xpos, jfloat ypos) {
+#ifndef IMPROVED_FONT_RENDERING
     int renderFlags;
+#endif
     int glyph_index;
     FT_Error error;
     FT_GlyphSlot ftglyph;
@@ -960,11 +1140,22 @@
         return NULL;
     }
 
+#ifdef IMPROVED_FONT_RENDERING
+    RenderingProperties renderingProperties;
+    readFontconfig((const FcChar8 *) scalerInfo->face->family_name,
+                   context, &renderingProperties);
+#else
     renderFlags = FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP;
+#endif
 
     glyph_index = FT_Get_Char_Index(scalerInfo->face, glyphCode);
 
+#ifdef IMPROVED_FONT_RENDERING
+    error = FT_Load_Glyph(scalerInfo->face, glyphCode, 
renderingProperties.ftLoadFlags);
+#else
     error = FT_Load_Glyph(scalerInfo->face, glyphCode, renderFlags);
+#endif
+
     if (error) {
         return NULL;
     }

Reply via email to