C'est un extrait de la classe String d'IBM/Websphere Java 1.8.64Comment définir la propriété système disableCopyInSubstring de la classe String en Java?
/**
* This is a System property to disable copying the String when offset is non-zero in {@link #substring(int)}} and {@link #substring(int, int)}}
*/
static boolean disableCopyInSubstring;
Je veux définir la propriété comme si.
System.setProperty("java.lang.String.disableCopyInSubstring", "true");
Mais, apparemment, ce n'est pas la bonne façon de le régler parce que je suis mise au point dans la classe String et cette variable montre encore false
.
Ajout d'un extrait plus grand de la classe String que j'utilise. C'est Websphere Java 1.8.64 d'IBM. Quand j'ai demandé que j'avais initialement pensé que j'utilisais Java d'Oracle. Voici l'extrait de cette variable et en haut.
package java.lang;
/*
* Licensed Materials - Property of IBM,
* Copyright IBM Corp. 1998, 2016 All Rights Reserved
*/
import java.io.Serializable;
import java.util.Locale;
import java.util.Comparator;
import java.io.UnsupportedEncodingException;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
import java.util.Formatter;
import java.util.StringJoiner;
import java.util.Iterator;
import java.nio.charset.Charset;
/**
* Strings are objects which represent immutable arrays of
* characters.
*
* @author OTI
* @version initial
*
* @see StringBuffer
*/
public final class String implements Serializable, Comparable<String>, CharSequence {
// DO NOT CHANGE OR MOVE THIS LINE
// IT MUST BE THE FIRST THING IN THE INITIALIZATION
private static final boolean STRING_OPT_IN_HW = StrCheckHWAvailable();
private static final long serialVersionUID = -6849794470754667710L;
/**
* CaseInsensitiveComparator compares Strings ignoring the case of the
* characters.
*/
private static final class CaseInsensitiveComparator implements Comparator<String>, Serializable {
static final long serialVersionUID = 8575799808933029326L;
/**
* Compare the two objects to determine
* the relative ordering.
*
* @param o1 an Object to compare
* @param o2 an Object to compare
* @return an int < 0 if object1 is less than object2,
* 0 if they are equal, and > 0 if object1 is greater
*
* @exception ClassCastException when objects are not the correct type
*/
public int compare(String o1, String o2) {
return o1.compareToIgnoreCase(o2);
}
};
/**
* A Comparator which compares Strings ignoring the case of the
* characters.
*/
public static final Comparator<String> CASE_INSENSITIVE_ORDER = new CaseInsensitiveComparator();
private static final char[] ascii;
private static String[] stringArray;
private static final int stringArraySize = 10;
private static class UnsafeHelpers {
public final static long valueFieldOffset = getValueFieldOffset();
static long getValueFieldOffset() {
try { return sun.misc.Unsafe.getUnsafe().objectFieldOffset(String.class.getDeclaredField("value")); }
catch (NoSuchFieldException e) { throw new RuntimeException(e); }
}
}
/**
* This is a System property to enable copy in {@link #String(String)}}
*/
static boolean enableCopy;
/**
* This is a System property to disable copying the String when offset is non-zero in {@link #substring(int)}} and {@link #substring(int, int)}}
*/
static boolean disableCopyInSubstring;
Etes-vous sûr que cet extrait provient de java.lang.String? Je ne trouve cet attribut nulle part. – ggradnig
Utilisez-vous OpenJDK ou un autre fournisseur? – talex
Je ne le trouve pas en 1.8.77. Mais puisque vous avez trouvé la variable dans le code source, recherchez dans le code source où il est modifié. –