Program: 68787
Project: 68787
Buggy source:
/** 
 * INTERNAL: Get default package name from a namespace URI.<br> This function follows the JSR-222 JAXB 2.0 algorithm from https://jaxb.dev.java.net/spec-download.html.<br>
 * @param uriString - a namespace URL or URN
 * @return Java package name String
 * @exclude
 */
public static String getPackageNameFromURI(String uriString){
  String strToken;
  String prefix;
  int position=0;
  StringBuffer pkgName=new StringBuffer();
  if (null == uriString || uriString.equals(SDOConstants.EMPTY_STRING)) {
    AbstractSessionLog.getLog().log(AbstractSessionLog.FINEST,INVALID_URI_WARNING,new Object[]{uriString,SDOConstants.JAVA_TYPEGENERATION_DEFAULT_PACKAGE_NAME},false);
    return SDOConstants.JAVA_TYPEGENERATION_DEFAULT_PACKAGE_NAME;
  }
  URI uri;
  String originalUriString=uriString;
  String schemePrefix;
  boolean invalidOriginalFormat=false;
  boolean isValidScheme=false;
  try {
    uri=new URI(uriString);
    schemePrefix=uri.getScheme();
    if (null != schemePrefix && (schemePrefix.equalsIgnoreCase("String_Node_Str") || schemePrefix.equalsIgnoreCase("String_Node_Str"))) {
      uriString=uri.getSchemeSpecificPart();
      isValidScheme=true;
    }
  }
 catch (  NullPointerException npe) {
    AbstractSessionLog.getLog().log(AbstractSessionLog.FINEST,INVALID_URI_WARNING,new Object[]{"String_Node_Str",SDOConstants.JAVA_TYPEGENERATION_DEFAULT_PACKAGE_NAME},false);
    return SDOConstants.JAVA_TYPEGENERATION_DEFAULT_PACKAGE_NAME;
  }
catch (  URISyntaxException use) {
    invalidOriginalFormat=true;
    if (uriString.length() > 4) {
      prefix=uriString.substring(0,4);
      if (prefix.equalsIgnoreCase("String_Node_Str")) {
        uriString=uriString.substring(4);
        isValidScheme=true;
      }
 else {
        prefix=uriString.substring(0,5);
        if (prefix.equalsIgnoreCase("String_Node_Str")) {
          uriString=uriString.substring(5);
          isValidScheme=true;
        }
      }
    }
  }
 finally {
    int potentialPathSepIndex=uriString.lastIndexOf('/');
    int potentialHostSepIndex=uriString.indexOf('/');
    int potentialFileExtIndex=uriString.lastIndexOf('.');
    if ((!isValidScheme && potentialFileExtIndex != -1) || ((potentialFileExtIndex != -1 && potentialPathSepIndex != -1 && potentialHostSepIndex != -1 && (potentialPathSepIndex - potentialHostSepIndex) > 1))) {
      String extension=uriString.substring(potentialFileExtIndex);
      if (extension.length() == 3 || extension.length() == 4 || extension.equalsIgnoreCase("String_Node_Str")) {
        uriString=uriString.substring(0,potentialFileExtIndex);
      }
    }
    StringTokenizer aTokenizer=new StringTokenizer(uriString,"String_Node_Str");
    int length=aTokenizer.countTokens();
    if (length == 0) {
      return SDOConstants.JAVA_TYPEGENERATION_DEFAULT_PACKAGE_NAME;
    }
    ArrayList<String> strings=new ArrayList<String>(length);
    while (aTokenizer.hasMoreTokens()) {
      strToken=aTokenizer.nextToken();
      strings.add(decodeUriHexadecimalEscapeSequence(strToken));
    }
    strToken=strings.remove(0).toLowerCase();
    aTokenizer=new StringTokenizer(strToken,"String_Node_Str");
    if (aTokenizer.countTokens() < 1) {
      AbstractSessionLog.getLog().log(AbstractSessionLog.FINEST,INVALID_URI_WARNING,new Object[]{uriString,SDOConstants.JAVA_TYPEGENERATION_DEFAULT_PACKAGE_NAME},false);
      return SDOConstants.JAVA_TYPEGENERATION_DEFAULT_PACKAGE_NAME;
    }
 else {
      while (aTokenizer.hasMoreTokens()) {
        strToken=aTokenizer.nextToken();
        if (!strToken.equals("String_Node_Str")) {
          strings.add(0,strToken);
        }
      }
    }
    position=0;
    for (    String aString : strings) {
      strings.set(position++,aString.toLowerCase());
    }
    position=0;
    for (    String aString : strings) {
      StringBuffer buffer=new StringBuffer();
      for (int j=0; j < aString.length(); j++) {
        char charToken=aString.charAt(j);
        if (Character.isJavaIdentifierPart(charToken)) {
          buffer.append(charToken);
        }
 else {
          buffer.append('_');
        }
      }
      if (!Character.isJavaIdentifierStart(buffer.charAt(0))) {
        buffer.insert(0,'_');
      }
      if (position++ != 0) {
        buffer.insert(0,'.');
      }
      pkgName.append(buffer.toString());
    }
    if (invalidOriginalFormat) {
      AbstractSessionLog.getLog().log(AbstractSessionLog.FINEST,INVALID_URI_WARNING,new Object[]{originalUriString,pkgName},false);
    }
  }
  return pkgName.toString();
}

Fixed version (ground truth):
/** 
 * INTERNAL: Get default package name from a namespace URI.<br> This function follows the JSR-222 JAXB 2.0 algorithm from https://jaxb.dev.java.net/spec-download.html.<br>
 * @param uriString - a namespace URL or URN
 * @return Java package name String
 * @exclude
 */
public static String getPackageNameFromURI(String uriString){
  String strToken;
  String prefix;
  int position=0;
  StringBuffer pkgName=new StringBuffer();
  if (null == uriString || uriString.equals(SDOConstants.EMPTY_STRING)) {
    AbstractSessionLog.getLog().log(AbstractSessionLog.FINEST,INVALID_URI_WARNING,new Object[]{uriString,SDOConstants.JAVA_TYPEGENERATION_DEFAULT_PACKAGE_NAME},false);
    return SDOConstants.JAVA_TYPEGENERATION_DEFAULT_PACKAGE_NAME;
  }
  URI uri;
  String originalUriString=uriString;
  String schemePrefix;
  boolean invalidOriginalFormat=false;
  boolean invalidScheme=false;
  try {
    uri=new URI(uriString);
    schemePrefix=uri.getScheme();
    if (null != schemePrefix) {
      if ((schemePrefix.equalsIgnoreCase("String_Node_Str") || schemePrefix.equalsIgnoreCase("String_Node_Str"))) {
        uriString=uri.getSchemeSpecificPart();
      }
 else {
        invalidScheme=true;
      }
    }
  }
 catch (  NullPointerException npe) {
    AbstractSessionLog.getLog().log(AbstractSessionLog.FINEST,INVALID_URI_WARNING,new Object[]{"String_Node_Str",SDOConstants.JAVA_TYPEGENERATION_DEFAULT_PACKAGE_NAME},false);
    return SDOConstants.JAVA_TYPEGENERATION_DEFAULT_PACKAGE_NAME;
  }
catch (  URISyntaxException use) {
    invalidOriginalFormat=true;
    if (uriString.length() > 4) {
      prefix=uriString.substring(0,4);
      if (prefix.equalsIgnoreCase("String_Node_Str")) {
        uriString=uriString.substring(4);
      }
 else {
        prefix=uriString.substring(0,5);
        if (prefix.equalsIgnoreCase("String_Node_Str")) {
          uriString=uriString.substring(5);
        }
      }
    }
  }
 finally {
    int potentialPathSepIndex=uriString.lastIndexOf('/');
    int potentialHostSepIndex=uriString.indexOf('/');
    int potentialFileExtIndex=uriString.lastIndexOf('.');
    if ((invalidScheme && potentialFileExtIndex != -1) || ((potentialFileExtIndex != -1 && potentialPathSepIndex != -1 && potentialHostSepIndex != -1 && (potentialPathSepIndex - potentialHostSepIndex) > 1))) {
      String extension=uriString.substring(potentialFileExtIndex);
      if (extension.length() == 3 || extension.length() == 4 || extension.equalsIgnoreCase("String_Node_Str")) {
        uriString=uriString.substring(0,potentialFileExtIndex);
      }
    }
    StringTokenizer aTokenizer=new StringTokenizer(uriString,"String_Node_Str");
    int length=aTokenizer.countTokens();
    if (length == 0) {
      return SDOConstants.JAVA_TYPEGENERATION_DEFAULT_PACKAGE_NAME;
    }
    ArrayList<String> strings=new ArrayList<String>(length);
    while (aTokenizer.hasMoreTokens()) {
      strToken=aTokenizer.nextToken();
      strings.add(decodeUriHexadecimalEscapeSequence(strToken));
    }
    strToken=strings.remove(0).toLowerCase();
    aTokenizer=new StringTokenizer(strToken,"String_Node_Str");
    if (aTokenizer.countTokens() < 1) {
      AbstractSessionLog.getLog().log(AbstractSessionLog.FINEST,INVALID_URI_WARNING,new Object[]{uriString,SDOConstants.JAVA_TYPEGENERATION_DEFAULT_PACKAGE_NAME},false);
      return SDOConstants.JAVA_TYPEGENERATION_DEFAULT_PACKAGE_NAME;
    }
 else {
      while (aTokenizer.hasMoreTokens()) {
        strToken=aTokenizer.nextToken();
        if (!strToken.equals("String_Node_Str")) {
          strings.add(0,strToken);
        }
      }
    }
    position=0;
    for (    String aString : strings) {
      strings.set(position++,aString.toLowerCase());
    }
    position=0;
    for (    String aString : strings) {
      StringBuffer buffer=new StringBuffer();
      for (int j=0; j < aString.length(); j++) {
        char charToken=aString.charAt(j);
        if (Character.isJavaIdentifierPart(charToken)) {
          buffer.append(charToken);
        }
 else {
          buffer.append('_');
        }
      }
      if (!Character.isJavaIdentifierStart(buffer.charAt(0))) {
        buffer.insert(0,'_');
      }
      if (position++ != 0) {
        buffer.insert(0,'.');
      }
      pkgName.append(buffer.toString());
    }
    if (invalidOriginalFormat) {
      AbstractSessionLog.getLog().log(AbstractSessionLog.FINEST,INVALID_URI_WARNING,new Object[]{originalUriString,pkgName},false);
    }
  }
  return pkgName.toString();
}