Skip to content

Commit

Permalink
GPLv2 + Classpath exception compliance: ship the source code of jform…
Browse files Browse the repository at this point in the history
…atstring

Technically, jformatstring has no problem because we were shiping the source
of in the jar file itself but that's easier to keep track of it if we actually
vendor the source and build from the source.

--
Change-Id: I80fc47ddeafc60263db47f33bfa9a2f2d7e2188d
Reviewed-on: https://bazel-review.googlesource.com/#/c/3914
MOS_MIGRATED_REVID=126174813
  • Loading branch information
damienmg committed Jun 29, 2016
1 parent 8f460f3 commit 068a661
Show file tree
Hide file tree
Showing 15 changed files with 1,637 additions and 9 deletions.
1 change: 1 addition & 0 deletions src/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ genrule(
srcs = [
":create_embedded_tools.sh",
"//tools:embedded_tools_srcs",
"//third_party:gpl-srcs",
"//third_party/iossim:srcs",
"//third_party/java/jarjar:srcs",
"//third_party/java/jdk/langtools:srcs",
Expand Down
22 changes: 13 additions & 9 deletions third_party/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ filegroup(
"//third_party/java/jdk/langtools:srcs",
"//third_party/java/jdk/javabuilder:srcs",
"//third_party/javascript/bootstrap:srcs",
"//third_party/jformatstring:srcs",
"//third_party/protobuf:srcs",
"//third_party/py/concurrent:srcs",
"//third_party/py/gflags:srcs",
Expand All @@ -25,6 +26,16 @@ filegroup(
],
)

# Filegroup to ship the sources to the Bazel embededded tools
# This filegroup should contains all GPL with classpath exception
# and LGPL code that we use in Bazel.
filegroup(
name = "gpl-srcs",
srcs = [
"//third_party/jformatstring:srcs",
],
)

filegroup(
name = "d3-js",
srcs = glob(["javascript/d3/**/*.js"]),
Expand Down Expand Up @@ -274,9 +285,9 @@ java_import(
":checker_framework_dataflow",
":guava",
":jcip_annotations",
":jformatstring",
":jsr305",
":pcollections",
"//third_party/jformatstring",
],
)

Expand All @@ -294,13 +305,6 @@ java_import(
],
)

java_import(
name = "jformatstring",
jars = [
"jformatstring/jFormatString-3.0.0.jar",
],
)

java_import(
name = "checker_framework_dataflow",
jars = [
Expand All @@ -318,9 +322,9 @@ filegroup(
"error_prone/error_prone_core-2.0.9-20160129.jar",
"guava/guava-19.0.jar",
"jcip_annotations/jcip-annotations-1.0-1.jar",
"jformatstring/jFormatString-3.0.0.jar",
"jsr305/jsr-305.jar",
"pcollections/pcollections-2.1.2.jar",
"//third_party/jformatstring:bootstrap",
],
)

Expand Down
20 changes: 20 additions & 0 deletions third_party/jformatstring/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package(default_visibility = ["//visibility:public"])

licenses(["restricted"]) # GNU GPL v2 with Classpath exception

filegroup(
name = "srcs",
srcs = glob(["**"]),
)

java_library(
name = "jformatstring",
srcs = glob(["java/**"]),
)

load("//tools/build_rules:java_rules_skylark.bzl", "bootstrap_java_library")

bootstrap_java_library(
name = "bootstrap",
srcs = glob(["java/**"]),
)
347 changes: 347 additions & 0 deletions third_party/jformatstring/LICENSE

Large diffs are not rendered by default.

Binary file removed third_party/jformatstring/jFormatString-3.0.0.jar
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
/*
* Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/* This file has been extensively modified from the original Sun implementation
* to provide for compile time checking of Format Strings.
*
* These modifications were performed by Bill Pugh, this code is free software.
*
*/
package edu.umd.cs.findbugs.formatStringChecker;

class Conversion {
// Byte, Short, Integer, Long, BigInteger
// (and associated primitives due to autoboxing)
static final char DECIMAL_INTEGER = 'd';
static final char OCTAL_INTEGER = 'o';
static final char HEXADECIMAL_INTEGER = 'x';
static final char HEXADECIMAL_INTEGER_UPPER = 'X';

// Float, Double, BigDecimal
// (and associated primitives due to autoboxing)
static final char SCIENTIFIC = 'e';
static final char SCIENTIFIC_UPPER = 'E';
static final char GENERAL = 'g';
static final char GENERAL_UPPER = 'G';
static final char DECIMAL_FLOAT = 'f';
static final char HEXADECIMAL_FLOAT = 'a';
static final char HEXADECIMAL_FLOAT_UPPER = 'A';

// Character, Byte, Short, Integer
// (and associated primitives due to autoboxing)
static final char CHARACTER = 'c';
static final char CHARACTER_UPPER = 'C';

// java.util.Date, java.util.Calendar, long
static final char DATE_TIME = 't';
static final char DATE_TIME_UPPER = 'T';

// if (arg.TYPE != boolean) return boolean
// if (arg != null) return true; else return false;
static final char BOOLEAN = 'b';
static final char BOOLEAN_UPPER = 'B';
// if (arg instanceof Formattable) arg.formatTo()
// else arg.toString();
static final char STRING = 's';
static final char STRING_UPPER = 'S';
// arg.hashCode()
static final char HASHCODE = 'h';
static final char HASHCODE_UPPER = 'H';

static final char LINE_SEPARATOR = 'n';
static final char PERCENT_SIGN = '%';

static boolean isValid(char c) {
return (isGeneral(c) || isInteger(c) || isFloat(c) || isText(c)
|| c == 't' || isCharacter(c));
}

// Returns true iff the Conversion is applicable to all objects.
static boolean isGeneral(char c) {
switch (c) {
case BOOLEAN:
case BOOLEAN_UPPER:
case STRING:
case STRING_UPPER:
case HASHCODE:
case HASHCODE_UPPER:
return true;
default:
return false;
}
}

// Returns true iff the Conversion is applicable to character.
static boolean isCharacter(char c) {
switch (c) {
case CHARACTER:
case CHARACTER_UPPER:
return true;
default:
return false;
}
}

// Returns true iff the Conversion is an integer type.
static boolean isInteger(char c) {
switch (c) {
case DECIMAL_INTEGER:
case OCTAL_INTEGER:
case HEXADECIMAL_INTEGER:
case HEXADECIMAL_INTEGER_UPPER:
return true;
default:
return false;
}
}

// Returns true iff the Conversion is a floating-point type.
static boolean isFloat(char c) {
switch (c) {
case SCIENTIFIC:
case SCIENTIFIC_UPPER:
case GENERAL:
case GENERAL_UPPER:
case DECIMAL_FLOAT:
case HEXADECIMAL_FLOAT:
case HEXADECIMAL_FLOAT_UPPER:
return true;
default:
return false;
}
}

// Returns true iff the Conversion does not require an argument
static boolean isText(char c) {
switch (c) {
case LINE_SEPARATOR:
case PERCENT_SIGN:
return true;
default:
return false;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
/*
* Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/* This file has been extensively modified from the original Sun implementation
* to provide for compile time checking of Format Strings.
*
* These modifications were performed by Bill Pugh, this code is free software.
*
*/
package edu.umd.cs.findbugs.formatStringChecker;

class DateTime {
static final char HOUR_OF_DAY_0 = 'H'; // (00 - 23)
static final char HOUR_0 = 'I'; // (01 - 12)
static final char HOUR_OF_DAY = 'k'; // (0 - 23) -- like H
static final char HOUR = 'l'; // (1 - 12) -- like I
static final char MINUTE = 'M'; // (00 - 59)
static final char NANOSECOND = 'N'; // (000000000 - 999999999)
static final char MILLISECOND = 'L'; // jdk, not in gnu (000 - 999)
static final char MILLISECOND_SINCE_EPOCH = 'Q'; // (0 - 99...?)
static final char AM_PM = 'p'; // (am or pm)
static final char SECONDS_SINCE_EPOCH = 's'; // (0 - 99...?)
static final char SECOND = 'S'; // (00 - 60 - leap second)
static final char TIME = 'T'; // (24 hour hh:mm:ss)
static final char ZONE_NUMERIC = 'z'; // (-1200 - +1200) - ls minus?
static final char ZONE = 'Z'; // (symbol)

// Date
static final char NAME_OF_DAY_ABBREV = 'a'; // 'a'
static final char NAME_OF_DAY = 'A'; // 'A'
static final char NAME_OF_MONTH_ABBREV = 'b'; // 'b'
static final char NAME_OF_MONTH = 'B'; // 'B'
static final char CENTURY = 'C'; // (00 - 99)
static final char DAY_OF_MONTH_0 = 'd'; // (01 - 31)
static final char DAY_OF_MONTH = 'e'; // (1 - 31) -- like d
// * static final char ISO_WEEK_OF_YEAR_2 = 'g'; // cross %y %V
// * static final char ISO_WEEK_OF_YEAR_4 = 'G'; // cross %Y %V
static final char NAME_OF_MONTH_ABBREV_X = 'h'; // -- same b
static final char DAY_OF_YEAR = 'j'; // (001 - 366)
static final char MONTH = 'm'; // (01 - 12)
// * static final char DAY_OF_WEEK_1 = 'u'; // (1 - 7) Monday
// * static final char WEEK_OF_YEAR_SUNDAY = 'U'; // (0 - 53) Sunday+
// * static final char WEEK_OF_YEAR_MONDAY_01 = 'V'; // (01 - 53) Monday+
// * static final char DAY_OF_WEEK_0 = 'w'; // (0 - 6) Sunday
// * static final char WEEK_OF_YEAR_MONDAY = 'W'; // (00 - 53) Monday
static final char YEAR_2 = 'y'; // (00 - 99)
static final char YEAR_4 = 'Y'; // (0000 - 9999)

// Composites
static final char TIME_12_HOUR = 'r'; // (hh:mm:ss [AP]M)
static final char TIME_24_HOUR = 'R'; // (hh:mm same as %H:%M)
// * static final char LOCALE_TIME = 'X'; // (%H:%M:%S) - parse format?
static final char DATE_TIME = 'c';
// (Sat Nov 04 12:02:33 EST 1999)
static final char DATE = 'D'; // (mm/dd/yy)
static final char ISO_STANDARD_DATE = 'F'; // (%Y-%m-%d)

// * static final char LOCALE_DATE = 'x'; // (mm/dd/yy)

static boolean isValid(char c) {
switch (c) {
case HOUR_OF_DAY_0:
case HOUR_0:
case HOUR_OF_DAY:
case HOUR:
case MINUTE:
case NANOSECOND:
case MILLISECOND:
case MILLISECOND_SINCE_EPOCH:
case AM_PM:
case SECONDS_SINCE_EPOCH:
case SECOND:
case TIME:
case ZONE_NUMERIC:
case ZONE:

// Date
case NAME_OF_DAY_ABBREV:
case NAME_OF_DAY:
case NAME_OF_MONTH_ABBREV:
case NAME_OF_MONTH:
case CENTURY:
case DAY_OF_MONTH_0:
case DAY_OF_MONTH:
// * case ISO_WEEK_OF_YEAR_2:
// * case ISO_WEEK_OF_YEAR_4:
case NAME_OF_MONTH_ABBREV_X:
case DAY_OF_YEAR:
case MONTH:
// * case DAY_OF_WEEK_1:
// * case WEEK_OF_YEAR_SUNDAY:
// * case WEEK_OF_YEAR_MONDAY_01:
// * case DAY_OF_WEEK_0:
// * case WEEK_OF_YEAR_MONDAY:
case YEAR_2:
case YEAR_4:

// Composites
case TIME_12_HOUR:
case TIME_24_HOUR:
// * case LOCALE_TIME:
case DATE_TIME:
case DATE:
case ISO_STANDARD_DATE:
// * case LOCALE_DATE:
return true;
default:
return false;
}
}
}
Loading

0 comments on commit 068a661

Please sign in to comment.