<commit_before>package io.sniffy.nio;

import sun.misc.Unsafe;

import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.lang.reflect.Field;
import java.security.Permissions;
import java.security.ProtectionDomain;

public class SniffySelectorProviderBootstrap {

    private static boolean publicSelChImplLoadedInBootstrapClassLoader = false;

    private static int getVersion() {
        String version = System.getProperty("java.version");
        if(version.startsWith("1.")) {
            version = version.substring(2, 3);
        } else {
            int dot = version.indexOf(".");
            if(dot != -1) { version = version.substring(0, dot); }
        } return Integer.parseInt(version);
    }

    public static void loadPublicSelChImplInBootstrapClassLoader() throws Exception {

        if (publicSelChImplLoadedInBootstrapClassLoader) return;

        publicSelChImplLoadedInBootstrapClassLoader = true;

        if (getVersion() >= 9) return;

        InputStream is = SniffySelectorProviderBootstrap.class.getClassLoader().getResourceAsStream("sun/nio/ch/PublicSelChImpl.clazz");
        ByteArrayOutputStream baos = new ByteArrayOutputStream();

        int i = 0;
        while ((i = is.read()) != -1) {
            baos.write(i);
        }

        is.close();

        Field f = Unsafe.class.getDeclaredField("theUnsafe");
        f.setAccessible(true);
        Unsafe unsafe = (Unsafe) f.get(null);

        unsafe.defineClass(
                "sun.nio.ch.PublicSelChImpl",
                baos.toByteArray(),
                0,
                baos.size(),
                null,
                new ProtectionDomain(null, new Permissions())
        );

    }

    public static void initialize() {

        try {
            loadPublicSelChImplInBootstrapClassLoader();
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

}
<commit_msg>Fix SniffySocketChannel in Java 6&7<commit_after>package io.sniffy.nio;

import sun.misc.Unsafe;

import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.lang.reflect.Field;
import java.security.CodeSource;
import java.security.Permissions;
import java.security.ProtectionDomain;
import java.security.cert.Certificate;

public class SniffySelectorProviderBootstrap {

    private static boolean publicSelChImplLoadedInBootstrapClassLoader = false;

    private static int getVersion() {
        String version = System.getProperty("java.version");
        if(version.startsWith("1.")) {
            version = version.substring(2, 3);
        } else {
            int dot = version.indexOf(".");
            if(dot != -1) { version = version.substring(0, dot); }
        } return Integer.parseInt(version);
    }

    public static void loadPublicSelChImplInBootstrapClassLoader() throws Exception {

        if (publicSelChImplLoadedInBootstrapClassLoader) return;

        publicSelChImplLoadedInBootstrapClassLoader = true;

        if (getVersion() >= 9) return;

        InputStream is = SniffySelectorProviderBootstrap.class.getClassLoader().getResourceAsStream("sun/nio/ch/PublicSelChImpl.clazz");
        ByteArrayOutputStream baos = new ByteArrayOutputStream();

        int i = 0;
        while ((i = is.read()) != -1) {
            baos.write(i);
        }

        is.close();

        Field f = Unsafe.class.getDeclaredField("theUnsafe");
        f.setAccessible(true);
        Unsafe unsafe = (Unsafe) f.get(null);

        unsafe.defineClass(
                "sun.nio.ch.PublicSelChImpl",
                baos.toByteArray(),
                0,
                baos.size(),
                Class.forName("sun.nio.ch.SelChImpl").getClassLoader(),
                new ProtectionDomain(
                        new CodeSource(
                                SniffySelectorProviderBootstrap.class.getClassLoader().getResource("sun/nio/ch/PublicSelChImpl.clazz"),
                                new Certificate[] {}
                        ), new Permissions())
        );

    }

    public static void initialize() {

        try {
            loadPublicSelChImplInBootstrapClassLoader();
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

}

{'fraction_non_alphanumeric': 0.10542525467898602, 'fraction_numerical': 0.004738213693437574, 'mean_word_length': 2.290724863600935, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3318718', 'n_tokens_mistral': 1187, 'n_tokens_neox': 1126, 'n_words': 219}