Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9a76135e authored by Bob Badour's avatar Bob Badour Committed by Gerrit Code Review
Browse files

Merge "Policy change: GPL+CE is permissive."

parents ae0ba167 10f5c48b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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
+6 −12
Original line number Diff line number Diff line
@@ -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-
@@ -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 (
@@ -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,
@@ -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:
@@ -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))
}
+7 −7
Original line number Diff line number Diff line
@@ -21,22 +21,22 @@ 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))
	}
}

@@ -44,7 +44,7 @@ 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)
		}
	}
}
@@ -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)
	}
}
+19 −31
Original line number Diff line number Diff line
@@ -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"},
@@ -116,7 +115,6 @@ func TestConditionSet(t *testing.T) {
				"notice",
				"reciprocal",
				"restricted",
				"restricted_with_classpath_exception",
				"restricted_allows_dynamic_linking",
				"proprietary",
				"by_exception_only",
@@ -131,7 +129,6 @@ func TestConditionSet(t *testing.T) {
				"notice",
				"reciprocal",
				"restricted",
				"restricted_with_classpath_exception",
				"restricted_allows_dynamic_linking",
				"proprietary",
				"by_exception_only",
@@ -151,7 +148,6 @@ func TestConditionSet(t *testing.T) {
				"notice",
				"reciprocal",
				"restricted",
				"restricted_with_classpath_exception",
				"restricted_allows_dynamic_linking",
				"proprietary",
				"by_exception_only",
@@ -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"},
@@ -195,7 +190,6 @@ func TestConditionSet(t *testing.T) {
				"notice",
				"reciprocal",
				"restricted",
				"restricted_with_classpath_exception",
				"restricted_allows_dynamic_linking",
				"proprietary",
				"by_exception_only",
@@ -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"},
@@ -221,7 +214,6 @@ func TestConditionSet(t *testing.T) {
				"notice",
				"reciprocal",
				"restricted",
				"restricted_with_classpath_exception",
				"proprietary",
				"by_exception_only",
				"not_allowed",
@@ -235,7 +227,6 @@ func TestConditionSet(t *testing.T) {
				"notice",
				"reciprocal",
				"restricted",
				"restricted_with_classpath_exception",
				"restricted_allows_dynamic_linking",
				"proprietary",
				"by_exception_only",
@@ -247,7 +238,6 @@ func TestConditionSet(t *testing.T) {
				"notice",
				"reciprocal",
				"restricted",
				"restricted_with_classpath_exception",
				"restricted_allows_dynamic_linking",
				"proprietary",
				"by_exception_only",
@@ -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{},
@@ -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 {
@@ -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) {
@@ -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) {
@@ -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
			}

@@ -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...)...) {
@@ -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
			}

@@ -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) {
@@ -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
		}
+6 −27
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@ package compliance

import (
	"regexp"
	"strings"
)

var (
@@ -62,14 +61,13 @@ var (

	// ImpliesNotice lists the condition names implying a notice or attribution policy.
	ImpliesNotice = LicenseConditionSet(UnencumberedCondition | PermissiveCondition | NoticeCondition | ReciprocalCondition |
		RestrictedCondition | RestrictedClasspathExceptionCondition | WeaklyRestrictedCondition |
		ProprietaryCondition | ByExceptionOnlyCondition)
		RestrictedCondition | WeaklyRestrictedCondition | ProprietaryCondition | ByExceptionOnlyCondition)

	// ImpliesReciprocal lists the condition names implying a local source-sharing policy.
	ImpliesReciprocal = LicenseConditionSet(ReciprocalCondition)

	// Restricted lists the condition names implying an infectious source-sharing policy.
	ImpliesRestricted = LicenseConditionSet(RestrictedCondition | RestrictedClasspathExceptionCondition | WeaklyRestrictedCondition)
	ImpliesRestricted = LicenseConditionSet(RestrictedCondition | WeaklyRestrictedCondition)

	// ImpliesProprietary lists the condition names implying a confidentiality policy.
	ImpliesProprietary = LicenseConditionSet(ProprietaryCondition)
@@ -81,7 +79,7 @@ var (
	ImpliesPrivate = LicenseConditionSet(ProprietaryCondition)

	// ImpliesShared lists the condition names implying a source-code sharing policy.
	ImpliesShared = LicenseConditionSet(ReciprocalCondition | RestrictedCondition | RestrictedClasspathExceptionCondition | WeaklyRestrictedCondition)
	ImpliesShared = LicenseConditionSet(ReciprocalCondition | RestrictedCondition | WeaklyRestrictedCondition)
)

var (
@@ -112,13 +110,9 @@ func LicenseConditionSetFromNames(tn *TargetNode, names ...string) LicenseCondit
				continue
			}
			hasLgpl := false
			hasClasspath := false
			hasGeneric := false
			for _, kind := range tn.LicenseKinds() {
				if strings.HasSuffix(kind, "-with-classpath-exception") {
					cs = cs.Plus(RestrictedClasspathExceptionCondition)
					hasClasspath = true
				} else if anyLgpl.MatchString(kind) {
				if anyLgpl.MatchString(kind) {
					cs = cs.Plus(WeaklyRestrictedCondition)
					hasLgpl = true
				} else if versionedGpl.MatchString(kind) {
@@ -131,7 +125,7 @@ func LicenseConditionSetFromNames(tn *TargetNode, names ...string) LicenseCondit
					cs = cs.Plus(RestrictedCondition)
				}
			}
			if hasGeneric && !hasLgpl && !hasClasspath {
			if hasGeneric && !hasLgpl {
				cs = cs.Plus(RestrictedCondition)
			}
			continue
@@ -202,9 +196,6 @@ func depConditionsPropagatingToTarget(lg *LicenseGraph, e *TargetEdge, depCondit
	}

	result |= depConditions & LicenseConditionSet(RestrictedCondition)
	if 0 != (depConditions&LicenseConditionSet(RestrictedClasspathExceptionCondition)) && !edgeNodesAreIndependentModules(e) {
		result |= LicenseConditionSet(RestrictedClasspathExceptionCondition)
	}
	return result
}

@@ -241,9 +232,6 @@ func targetConditionsPropagatingToDep(lg *LicenseGraph, e *TargetEdge, targetCon
		return result
	}
	result = result.Minus(WeaklyRestrictedCondition)
	if edgeNodesAreIndependentModules(e) {
		result = result.Minus(RestrictedClasspathExceptionCondition)
	}
	return result
}

@@ -261,10 +249,7 @@ func conditionsAttachingAcrossEdge(lg *LicenseGraph, e *TargetEdge, universe Lic
		return NewLicenseConditionSet()
	}

	result &= LicenseConditionSet(RestrictedCondition | RestrictedClasspathExceptionCondition)
	if 0 != (result&LicenseConditionSet(RestrictedClasspathExceptionCondition)) && edgeNodesAreIndependentModules(e) {
	result &= LicenseConditionSet(RestrictedCondition)
	}
	return result
}

@@ -281,9 +266,3 @@ func edgeIsDerivation(e *TargetEdge) bool {
	isToolchain := e.annotations.HasAnnotation("toolchain")
	return !isDynamic && !isToolchain
}

// edgeNodesAreIndependentModules returns true for edges where the target and
// dependency are independent modules.
func edgeNodesAreIndependentModules(e *TargetEdge) bool {
	return e.target.PackageName() != e.dependency.PackageName()
}
Loading