Lines 1867-1914
Link Here
|
1867 |
int contractsCount = 0; |
1867 |
int contractsCount = 0; |
1868 |
int contractsLength = 0; |
1868 |
int contractsLength = 0; |
1869 |
|
1869 |
|
1870 |
// -- the following are used for early termination. |
|
|
1871 |
MethodBinding aContract = null; |
1872 |
int contractParameterLength = 0; |
1873 |
char [] contractSelector = null; |
1874 |
// --- |
1875 |
|
1876 |
ReferenceBinding [] superInterfaces = superInterfaces(); |
1870 |
ReferenceBinding [] superInterfaces = superInterfaces(); |
1877 |
for (int i = 0, length = superInterfaces.length; i < length; i++) { |
1871 |
for (int i = 0, length = superInterfaces.length; i < length; i++) { |
1878 |
MethodBinding [] superInterfaceContracts = superInterfaces[i].getInterfaceAbstractContracts(scope); |
1872 |
MethodBinding [] superInterfaceContracts = superInterfaces[i].getInterfaceAbstractContracts(scope); |
1879 |
final int superInterfaceContractsLength = superInterfaceContracts == null ? 0 : superInterfaceContracts.length; |
1873 |
final int superInterfaceContractsLength = superInterfaceContracts == null ? 0 : superInterfaceContracts.length; |
1880 |
|
|
|
1881 |
if (superInterfaceContractsLength == 0) continue; |
1874 |
if (superInterfaceContractsLength == 0) continue; |
1882 |
if (aContract == null) { |
1875 |
if (contractsLength < contractsCount + superInterfaceContractsLength) { |
1883 |
aContract = superInterfaceContracts[0]; |
1876 |
System.arraycopy(contracts, 0, contracts = new MethodBinding[contractsLength = contractsCount + superInterfaceContractsLength], 0, contractsCount); |
1884 |
contractParameterLength = aContract.parameters.length; |
|
|
1885 |
contractSelector = aContract.selector; |
1886 |
contracts = superInterfaceContracts; |
1887 |
contractsCount = contractsLength = superInterfaceContractsLength; |
1888 |
} else { |
1889 |
if (superInterfaceContracts[0].parameters.length != contractParameterLength || !CharOperation.equals(contractSelector, superInterfaceContracts[0].selector)) { |
1890 |
throw new InvalidInputException("Not a functional interface"); //$NON-NLS-1$ |
1891 |
} |
1892 |
if (contractsLength < contractsCount + superInterfaceContractsLength) { |
1893 |
System.arraycopy(contracts, 0, contracts = new MethodBinding[contractsLength = contractsCount + superInterfaceContractsLength], 0, contractsCount); |
1894 |
} |
1895 |
System.arraycopy(superInterfaceContracts, 0, contracts, contractsCount, superInterfaceContractsLength); |
1896 |
contractsCount += superInterfaceContractsLength; |
1897 |
} |
1877 |
} |
|
|
1878 |
System.arraycopy(superInterfaceContracts, 0, contracts, contractsCount, superInterfaceContractsLength); |
1879 |
contractsCount += superInterfaceContractsLength; |
1898 |
} |
1880 |
} |
|
|
1881 |
|
1899 |
for (int i = 0, length = methods == null ? 0 : methods.length; i < length; i++) { |
1882 |
for (int i = 0, length = methods == null ? 0 : methods.length; i < length; i++) { |
1900 |
final MethodBinding method = methods[i]; |
1883 |
final MethodBinding method = methods[i]; |
1901 |
if (method.isStatic() || method.redeclaresPublicObjectMethod(scope)) continue; |
1884 |
if (method == null || method.isStatic() || method.redeclaresPublicObjectMethod(scope)) |
|
|
1885 |
continue; |
1886 |
if (!method.isValidBinding()) |
1887 |
throw new InvalidInputException("Not a functional interface"); //$NON-NLS-1$ |
1902 |
if (method.isDefaultMethod()) { |
1888 |
if (method.isDefaultMethod()) { |
1903 |
for (int j = 0; j < contractsCount; j++) { |
1889 |
for (int j = 0; j < contractsCount; j++) { |
1904 |
if (contracts[j] == null) |
1890 |
if (contracts[j] == null) |
1905 |
continue; |
1891 |
continue; |
1906 |
if (MethodVerifier.doesMethodOverride(method, contracts[j], scope.environment())) { |
1892 |
if (MethodVerifier.doesMethodOverride(method, contracts[j], scope.environment())) { |
1907 |
if (aContract == contracts[j]) { |
|
|
1908 |
aContract = null; |
1909 |
contractParameterLength = 0; |
1910 |
contractSelector = null; |
1911 |
} |
1912 |
contractsCount--; |
1893 |
contractsCount--; |
1913 |
// abstract method from super type rendered default by present interface ==> contracts[j] = null; |
1894 |
// abstract method from super type rendered default by present interface ==> contracts[j] = null; |
1914 |
if (j < contractsCount) |
1895 |
if (j < contractsCount) |
Lines 1916-1931
Link Here
|
1916 |
} |
1897 |
} |
1917 |
} |
1898 |
} |
1918 |
continue; // skip default method itself |
1899 |
continue; // skip default method itself |
1919 |
} |
|
|
1920 |
final boolean validBinding = method.isValidBinding(); |
1921 |
if (aContract == null && validBinding) { |
1922 |
aContract = method; |
1923 |
contractParameterLength = aContract.parameters.length; |
1924 |
contractSelector = aContract.selector; |
1925 |
} else { |
1926 |
if (!validBinding || method.parameters.length != contractParameterLength || !CharOperation.equals(contractSelector, method.selector)) { |
1927 |
throw new InvalidInputException("Not a functional interface"); //$NON-NLS-1$ |
1928 |
} |
1929 |
} |
1900 |
} |
1930 |
if (contractsCount == contractsLength) { |
1901 |
if (contractsCount == contractsLength) { |
1931 |
System.arraycopy(contracts, 0, contracts = new MethodBinding[contractsLength += 16], 0, contractsCount); |
1902 |
System.arraycopy(contracts, 0, contracts = new MethodBinding[contractsLength += 16], 0, contractsCount); |
Lines 1952-1966
Link Here
|
1952 |
MethodBinding[] methods = null; |
1923 |
MethodBinding[] methods = null; |
1953 |
try { |
1924 |
try { |
1954 |
methods = getInterfaceAbstractContracts(scope); |
1925 |
methods = getInterfaceAbstractContracts(scope); |
|
|
1926 |
if (methods == null || methods.length == 0) |
1927 |
return this.singleAbstractMethod[index] = samProblemBinding; |
1928 |
int contractParameterLength = 0; |
1929 |
char [] contractSelector = null; |
1930 |
for (int i = 0, length = methods.length; i < length; i++) { |
1931 |
MethodBinding method = methods[i]; |
1932 |
if (method == null) continue; |
1933 |
if (contractSelector == null) { |
1934 |
contractSelector = method.selector; |
1935 |
contractParameterLength = method.parameters == null ? 0 : method.parameters.length; |
1936 |
} else { |
1937 |
int methodParameterLength = method.parameters == null ? 0 : method.parameters.length; |
1938 |
if (methodParameterLength != contractParameterLength || !CharOperation.equals(method.selector, contractSelector)) |
1939 |
return this.singleAbstractMethod[index] = samProblemBinding; |
1940 |
} |
1941 |
} |
1955 |
} catch (InvalidInputException e) { |
1942 |
} catch (InvalidInputException e) { |
1956 |
return this.singleAbstractMethod[index] = samProblemBinding; |
1943 |
return this.singleAbstractMethod[index] = samProblemBinding; |
1957 |
} |
1944 |
} |
1958 |
if (methods != null && methods.length == 1) |
1945 |
if (methods.length == 1) |
1959 |
return this.singleAbstractMethod[index] = methods[0]; |
1946 |
return this.singleAbstractMethod[index] = methods[0]; |
1960 |
|
1947 |
|
1961 |
final LookupEnvironment environment = scope.environment(); |
1948 |
final LookupEnvironment environment = scope.environment(); |
1962 |
boolean genericMethodSeen = false; |
1949 |
boolean genericMethodSeen = false; |
1963 |
int length = methods.length; |
1950 |
int length = methods.length; |
|
|
1951 |
|
1964 |
next:for (int i = length - 1; i >= 0; --i) { |
1952 |
next:for (int i = length - 1; i >= 0; --i) { |
1965 |
MethodBinding method = methods[i], otherMethod = null; |
1953 |
MethodBinding method = methods[i], otherMethod = null; |
1966 |
if (method.typeVariables != Binding.NO_TYPE_VARIABLES) |
1954 |
if (method.typeVariables != Binding.NO_TYPE_VARIABLES) |