Skip to content

Commit

Permalink
Merge "Policy change: GPL+CE is permissive."
Browse files Browse the repository at this point in the history
  • Loading branch information
bbadour authored and Gerrit Code Review committed Sep 21, 2022
2 parents ae0ba16 + 10f5c48 commit 9a76135
Show file tree
Hide file tree
Showing 11 changed files with 101 additions and 218 deletions.
2 changes: 1 addition & 1 deletion core/tasks/tools/compatibility.mk
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ $(test_suite_jdk): $(shell find $(test_suite_jdk_dir) -type f | sort)
$(test_suite_jdk): $(SOONG_ZIP)
$(SOONG_ZIP) -o $@ -P $(PRIVATE_SUBDIR)/jdk -C $(PRIVATE_JDK_DIR) -D $(PRIVATE_JDK_DIR)

$(call declare-license-metadata,$(test_suite_jdk),SPDX-license-identifier-GPL-2.0-with-classpath-exception,restricted,\
$(call declare-license-metadata,$(test_suite_jdk),SPDX-license-identifier-GPL-2.0-with-classpath-exception,permissive,\
$(test_suite_jdk_dir)/legal/java.base/LICENSE,JDK,prebuilts/jdk/$(notdir $(patsubst %/,%,$(dir $(test_suite_jdk_dir)))))

# Copy license metadata
Expand Down
18 changes: 6 additions & 12 deletions tools/compliance/condition.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
type LicenseCondition uint16

// LicenseConditionMask is a bitmask for the recognized license conditions.
const LicenseConditionMask = LicenseCondition(0x3ff)
const LicenseConditionMask = LicenseCondition(0x1ff)

const (
// UnencumberedCondition identifies public domain or public domain-
Expand All @@ -41,21 +41,18 @@ const (
// RestrictedCondition identifies a license with requirement to share
// all source code linked to the module's source.
RestrictedCondition = LicenseCondition(0x0010)
// RestrictedClasspathExceptionCondition identifies RestrictedCondition
// waived for dynamic linking from independent modules.
RestrictedClasspathExceptionCondition = LicenseCondition(0x0020)
// WeaklyRestrictedCondition identifies a RestrictedCondition waived
// for dynamic linking.
WeaklyRestrictedCondition = LicenseCondition(0x0040)
WeaklyRestrictedCondition = LicenseCondition(0x0020)
// ProprietaryCondition identifies a license with source privacy
// requirements.
ProprietaryCondition = LicenseCondition(0x0080)
ProprietaryCondition = LicenseCondition(0x0040)
// ByExceptionOnly identifies a license where policy requires product
// counsel review prior to use.
ByExceptionOnlyCondition = LicenseCondition(0x0100)
ByExceptionOnlyCondition = LicenseCondition(0x0080)
// NotAllowedCondition identifies a license with onerous conditions
// where policy prohibits use.
NotAllowedCondition = LicenseCondition(0x0200)
NotAllowedCondition = LicenseCondition(0x0100)
)

var (
Expand All @@ -66,7 +63,6 @@ var (
"notice": NoticeCondition,
"reciprocal": ReciprocalCondition,
"restricted": RestrictedCondition,
"restricted_with_classpath_exception": RestrictedClasspathExceptionCondition,
"restricted_allows_dynamic_linking": WeaklyRestrictedCondition,
"proprietary": ProprietaryCondition,
"by_exception_only": ByExceptionOnlyCondition,
Expand All @@ -87,8 +83,6 @@ func (lc LicenseCondition) Name() string {
return "reciprocal"
case RestrictedCondition:
return "restricted"
case RestrictedClasspathExceptionCondition:
return "restricted_with_classpath_exception"
case WeaklyRestrictedCondition:
return "restricted_allows_dynamic_linking"
case ProprietaryCondition:
Expand All @@ -98,5 +92,5 @@ func (lc LicenseCondition) Name() string {
case NotAllowedCondition:
return "not_allowed"
}
panic(fmt.Errorf("unrecognized license condition: %04x", lc))
panic(fmt.Errorf("unrecognized license condition: %#v", lc))
}
14 changes: 7 additions & 7 deletions tools/compliance/condition_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,30 +21,30 @@ import (
func TestConditionSetHas(t *testing.T) {
impliesShare := ImpliesShared

t.Logf("testing with imliesShare=%04x", impliesShare)
t.Logf("testing with imliesShare=%#v", impliesShare)

if impliesShare.HasAny(NoticeCondition) {
t.Errorf("impliesShare.HasAny(\"notice\"=%04x) got true, want false", NoticeCondition)
t.Errorf("impliesShare.HasAny(\"notice\"=%#v) got true, want false", NoticeCondition)
}

if !impliesShare.HasAny(RestrictedCondition) {
t.Errorf("impliesShare.HasAny(\"restricted\"=%04x) got false, want true", RestrictedCondition)
t.Errorf("impliesShare.HasAny(\"restricted\"=%#v) got false, want true", RestrictedCondition)
}

if !impliesShare.HasAny(ReciprocalCondition) {
t.Errorf("impliesShare.HasAny(\"reciprocal\"=%04x) got false, want true", ReciprocalCondition)
t.Errorf("impliesShare.HasAny(\"reciprocal\"=%#v) got false, want true", ReciprocalCondition)
}

if impliesShare.HasAny(LicenseCondition(0x0000)) {
t.Errorf("impliesShare.HasAny(nil=%04x) got true, want false", LicenseCondition(0x0000))
t.Errorf("impliesShare.HasAny(nil=%#v) got true, want false", LicenseCondition(0x0000))
}
}

func TestConditionName(t *testing.T) {
for expected, condition := range RecognizedConditionNames {
actual := condition.Name()
if expected != actual {
t.Errorf("unexpected name for condition %04x: got %s, want %s", condition, actual, expected)
t.Errorf("unexpected name for condition %#v: got %s, want %s", condition, actual, expected)
}
}
}
Expand All @@ -62,6 +62,6 @@ func TestConditionName_InvalidCondition(t *testing.T) {
t.Errorf("invalid condition unexpected name: got %s, wanted panic", name)
}()
if !panicked {
t.Errorf("no expected panic for %04x.Name(): got no panic, wanted panic", lc)
t.Errorf("no expected panic for %#v.Name(): got no panic, wanted panic", lc)
}
}
50 changes: 19 additions & 31 deletions tools/compliance/conditionset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,13 @@ func TestConditionSet(t *testing.T) {
{
name: "everything",
conditions: []string{"unencumbered", "permissive", "notice", "reciprocal", "restricted", "proprietary"},
plus: &[]string{"restricted_with_classpath_exception", "restricted_allows_dynamic_linking", "by_exception_only", "not_allowed"},
plus: &[]string{"restricted_allows_dynamic_linking", "by_exception_only", "not_allowed"},
matchingAny: map[string][]string{
"unencumbered": []string{"unencumbered"},
"permissive": []string{"permissive"},
"notice": []string{"notice"},
"reciprocal": []string{"reciprocal"},
"restricted": []string{"restricted"},
"restricted_with_classpath_exception": []string{"restricted_with_classpath_exception"},
"restricted_allows_dynamic_linking": []string{"restricted_allows_dynamic_linking"},
"proprietary": []string{"proprietary"},
"by_exception_only": []string{"by_exception_only"},
Expand All @@ -116,7 +115,6 @@ func TestConditionSet(t *testing.T) {
"notice",
"reciprocal",
"restricted",
"restricted_with_classpath_exception",
"restricted_allows_dynamic_linking",
"proprietary",
"by_exception_only",
Expand All @@ -131,7 +129,6 @@ func TestConditionSet(t *testing.T) {
"notice",
"reciprocal",
"restricted",
"restricted_with_classpath_exception",
"restricted_allows_dynamic_linking",
"proprietary",
"by_exception_only",
Expand All @@ -151,7 +148,6 @@ func TestConditionSet(t *testing.T) {
"notice",
"reciprocal",
"restricted",
"restricted_with_classpath_exception",
"restricted_allows_dynamic_linking",
"proprietary",
"by_exception_only",
Expand All @@ -168,7 +164,6 @@ func TestConditionSet(t *testing.T) {
"notice": []string{"notice"},
"reciprocal": []string{"reciprocal"},
"restricted": []string{"restricted"},
"restricted_with_classpath_exception": []string{},
"restricted_allows_dynamic_linking": []string{"restricted_allows_dynamic_linking"},
"proprietary": []string{"proprietary"},
"by_exception_only": []string{"by_exception_only"},
Expand All @@ -195,7 +190,6 @@ func TestConditionSet(t *testing.T) {
"notice",
"reciprocal",
"restricted",
"restricted_with_classpath_exception",
"restricted_allows_dynamic_linking",
"proprietary",
"by_exception_only",
Expand All @@ -208,7 +202,6 @@ func TestConditionSet(t *testing.T) {
"notice": []string{"notice"},
"reciprocal": []string{"reciprocal"},
"restricted": []string{"restricted"},
"restricted_with_classpath_exception": []string{"restricted_with_classpath_exception"},
"restricted_allows_dynamic_linking": []string{},
"proprietary": []string{"proprietary"},
"by_exception_only": []string{"by_exception_only"},
Expand All @@ -221,7 +214,6 @@ func TestConditionSet(t *testing.T) {
"notice",
"reciprocal",
"restricted",
"restricted_with_classpath_exception",
"proprietary",
"by_exception_only",
"not_allowed",
Expand All @@ -235,7 +227,6 @@ func TestConditionSet(t *testing.T) {
"notice",
"reciprocal",
"restricted",
"restricted_with_classpath_exception",
"restricted_allows_dynamic_linking",
"proprietary",
"by_exception_only",
Expand All @@ -247,7 +238,6 @@ func TestConditionSet(t *testing.T) {
"notice",
"reciprocal",
"restricted",
"restricted_with_classpath_exception",
"restricted_allows_dynamic_linking",
"proprietary",
"by_exception_only",
Expand All @@ -259,7 +249,6 @@ func TestConditionSet(t *testing.T) {
"notice": []string{},
"reciprocal": []string{},
"restricted": []string{},
"restricted_with_classpath_exception": []string{},
"restricted_allows_dynamic_linking": []string{},
"proprietary": []string{},
"by_exception_only": []string{},
Expand All @@ -270,21 +259,20 @@ func TestConditionSet(t *testing.T) {
},
{
name: "restrictedplus",
conditions: []string{"restricted", "restricted_with_classpath_exception", "restricted_allows_dynamic_linking"},
conditions: []string{"restricted", "restricted_allows_dynamic_linking"},
plus: &[]string{"permissive", "notice", "restricted", "proprietary"},
matchingAny: map[string][]string{
"unencumbered": []string{},
"permissive": []string{"permissive"},
"notice": []string{"notice"},
"restricted": []string{"restricted"},
"restricted_with_classpath_exception": []string{"restricted_with_classpath_exception"},
"restricted_allows_dynamic_linking": []string{"restricted_allows_dynamic_linking"},
"proprietary": []string{"proprietary"},
"restricted|proprietary": []string{"restricted", "proprietary"},
"by_exception_only": []string{},
"proprietary|by_exception_only": []string{"proprietary"},
},
expected: []string{"permissive", "notice", "restricted", "restricted_with_classpath_exception", "restricted_allows_dynamic_linking", "proprietary"},
expected: []string{"permissive", "notice", "restricted", "restricted_allows_dynamic_linking", "proprietary"},
},
}
for _, tt := range tests {
Expand Down Expand Up @@ -342,11 +330,11 @@ func TestConditionSet(t *testing.T) {
actual := cs.MatchingAny(toConditions(strings.Split(data, "|"))...)
actualNames := actual.Names()

t.Logf("MatchingAny(%s): actual set %04x %s", data, actual, actual.String())
t.Logf("MatchingAny(%s): expected set %04x %s", data, expected, expected.String())
t.Logf("MatchingAny(%s): actual set %#v %s", data, actual, actual.String())
t.Logf("MatchingAny(%s): expected set %#v %s", data, expected, expected.String())

if actual != expected {
t.Errorf("MatchingAny(%s): got %04x, want %04x", data, actual, expected)
t.Errorf("MatchingAny(%s): got %#v, want %#v", data, actual, expected)
continue
}
if len(actualNames) != len(expectedNames) {
Expand Down Expand Up @@ -382,11 +370,11 @@ func TestConditionSet(t *testing.T) {
actual := cs.MatchingAnySet(NewLicenseConditionSet(toConditions(strings.Split(data, "|"))...))
actualNames := actual.Names()

t.Logf("MatchingAnySet(%s): actual set %04x %s", data, actual, actual.String())
t.Logf("MatchingAnySet(%s): expected set %04x %s", data, expected, expected.String())
t.Logf("MatchingAnySet(%s): actual set %#v %s", data, actual, actual.String())
t.Logf("MatchingAnySet(%s): expected set %#v %s", data, expected, expected.String())

if actual != expected {
t.Errorf("MatchingAnySet(%s): got %04x, want %04x", data, actual, expected)
t.Errorf("MatchingAnySet(%s): got %#v, want %#v", data, actual, expected)
continue
}
if len(actualNames) != len(expectedNames) {
Expand Down Expand Up @@ -426,11 +414,11 @@ func TestConditionSet(t *testing.T) {

actualNames := actual.Names()

t.Logf("actual license condition set: %04x %s", actual, actual.String())
t.Logf("expected license condition set: %04x %s", expected, expected.String())
t.Logf("actual license condition set: %#v %s", actual, actual.String())
t.Logf("expected license condition set: %#v %s", expected, expected.String())

if actual != expected {
t.Errorf("checkExpected: got %04x, want %04x", actual, expected)
t.Errorf("checkExpected: got %#v, want %#v", actual, expected)
return false
}

Expand Down Expand Up @@ -487,7 +475,7 @@ func TestConditionSet(t *testing.T) {

notExpected := (AllLicenseConditions &^ expected)
notExpectedList := notExpected.AsList()
t.Logf("not expected license condition set: %04x %s", notExpected, notExpected.String())
t.Logf("not expected license condition set: %#v %s", notExpected, notExpected.String())

if len(tt.expected) == 0 {
if actual.HasAny(append(expectedConditions, notExpectedList...)...) {
Expand Down Expand Up @@ -526,11 +514,11 @@ func TestConditionSet(t *testing.T) {

actualNames := actual.Names()

t.Logf("actual license condition set: %04x %s", actual, actual.String())
t.Logf("expected license condition set: %04x %s", expected, expected.String())
t.Logf("actual license condition set: %#v %s", actual, actual.String())
t.Logf("expected license condition set: %#v %s", expected, expected.String())

if actual != expected {
t.Errorf("checkExpectedSet: got %04x, want %04x", actual, expected)
t.Errorf("checkExpectedSet: got %#v, want %#v", actual, expected)
return false
}

Expand Down Expand Up @@ -581,7 +569,7 @@ func TestConditionSet(t *testing.T) {
}

notExpected := (AllLicenseConditions &^ expected)
t.Logf("not expected license condition set: %04x %s", notExpected, notExpected.String())
t.Logf("not expected license condition set: %#v %s", notExpected, notExpected.String())

if len(tt.expected) == 0 {
if actual.MatchesAnySet(expected, notExpected) {
Expand All @@ -606,10 +594,10 @@ func TestConditionSet(t *testing.T) {
t.Errorf("actual.Difference({expected}).IsEmpty(): want true, got false")
}
if expected != actual.Intersection(expected) {
t.Errorf("expected == actual.Intersection({expected}): want true, got false (%04x != %04x)", expected, actual.Intersection(expected))
t.Errorf("expected == actual.Intersection({expected}): want true, got false (%#v != %#v)", expected, actual.Intersection(expected))
}
if actual != actual.Intersection(expected) {
t.Errorf("actual == actual.Intersection({expected}): want true, got false (%04x != %04x)", actual, actual.Intersection(expected))
t.Errorf("actual == actual.Intersection({expected}): want true, got false (%#v != %#v)", actual, actual.Intersection(expected))
}
return true
}
Expand Down
Loading

0 comments on commit 9a76135

Please sign in to comment.