System and method for supporting compatibility checking for lambda expression
Saved in:
| Title: | System and method for supporting compatibility checking for lambda expression |
|---|---|
| Patent Number: | 9,557,974 |
| Publication Date: | January 31, 2017 |
| Appl. No: | 13/779536 |
| Application Filed: | February 27, 2013 |
| Abstract: | A system and method can support compatibility checking in a programming language environment. The programming language environment can check whether a target type associated with an expression in the programming language environment is functional, wherein the target type is functional when it has exactly one method meeting one or more criteria that define that method as relevant in a counting system. Then, the programming language environment can derive a function descriptor from the target type, which is context-dependent. Furthermore, the programming language environment can type-check the expression with the function descriptor associated with the target type. |
| Inventors: | Oracle International Corporation (Redwood Shores, CA, US) |
| Assignees: | ORACLE INTERNATIONAL CORPORATION (Redwood Shores, CA, US) |
| Claim: | 1. A computer-implemented method for supporting compatibility checking in a programming language environment (PLE), the computer-implemented method comprising: receiving a language expression in the PLE; determining a context of the language expression in the PLE; analyzing the context of the language expression in the PLE to determine a target type of the language expression in the PLE; determining, via a compiler in the PLE, that the target type of the language expression implements a functional interface that includes a single abstract method; deriving, using the compiler, a function descriptor from the target type; and comparing a return type and an exception type resulting from an execution of the language expression against the function descriptor. |
| Claim: | 2. The computer-implemented method according to claim 1 , further comprising: the language expression is a lambda expression that provides a list of parameters and a body. |
| Claim: | 3. The computer-implemented method according to claim 2 , further comprising: inferring types of one or more parameters of the lambda expression. |
| Claim: | 4. The computer-implemented method according to claim 2 , further comprising: comparing types of one or more parameters against the function descriptor. |
| Claim: | 5. The computer-implemented method according to claim 2 , wherein the lambda expression appears in one of an assignment context, an invocation context, and a casting context. |
| Claim: | 6. The computer-implemented method according to claim 2 , further comprising: inferring a natural parameterized type from a wildcard-parameterized functional interface type and the lambda expression. |
| Claim: | 7. The method of claim 1 , wherein the PLE is a Java programming language environment, and wherein the language expression is a lambda expression expressed in the Java programming language. |
| Claim: | 8. A system for supporting compatibility checking in a programming language environment (PLE), the system comprising: one or more microprocessors; and a compiler, running on the one or more microprocessors, wherein the compiler is configured to receive a language expression in the PLE, determine a context of the language expression in the PLE; analyze the context of the language expression in the PLE to determine a target type of the language expression in the PLE, determine that the target type of the language expression implements a functional interface that includes a single abstract method, derive a function descriptor from the target type, and compare a return type and an exception type resulting from an execution of the language expression against the function descriptor. |
| Claim: | 9. The system according to claim 8 , wherein the language expression is a lambda expression that provides a list of parameters and a body. |
| Claim: | 10. The system according to claim 9 , wherein types of one or more parameters of the lambda expression are inferred. |
| Claim: | 11. The system according to claim 9 , wherein types of one or more parameters are compared against the function descriptor. |
| Claim: | 12. The system according to claim 9 , wherein the lambda expression appears in one of an assignment context, an invocation context, and a casting context. |
| Claim: | 13. The system according to claim 9 , wherein a natural parameterized type is inferred from a wildcard-parameterized functional interface type and the lambda expression. |
| Claim: | 14. The system of claim 8 , wherein the PLE is a Java programming language environment, and wherein the language expression is a lambda expression expressed in the Java programming language. |
| Claim: | 15. A non-transitory machine readable storage medium having instructions stored thereon for supporting compatibility checking in a programming language environment (PLE), which instructions, when executed cause a system to perform steps comprising: receiving a language expression in the PLE; determining a context of the language expression in the PLE; analyzing the context of the language expression in the PLE to determine a target type of the language expression in the PLE; determining, via a compiler in the PLE, that the target type of the language expression implements a functional interface that includes a single abstract method; deriving, using the compiler, a function descriptor from the target type; and comparing a return type and an exception type resulting from an execution of the language expression against the function descriptor. |
| Claim: | 16. The non-transitory machine readable storage medium according to claim 15 , wherein the language expression is a lambda expression that provides a list of parameters and a body. |
| Claim: | 17. The non-transitory machine readable storage medium according to claim 16 , wherein types of one or more parameters of the lambda expression are inferred. |
| Claim: | 18. The non-transitory machine readable storage medium according to claim 16 , wherein types of one or more parameters are compared against the function descriptor. |
| Claim: | 19. The non-transitory machine readable storage medium according to claim 16 , wherein the lambda expression appears in one of an assignment context, an invocation context, and a casting context. |
| Claim: | 20. The non-transitory machine readable storage medium according to claim 16 , wherein a natural parameterized type is inferred from a wildcard-parameterized functional interface type and the lambda expression. |
| Patent References Cited: | 5748966 May 1998 Sato 7873592 January 2011 Meijer 2005/0229048 October 2005 Da Palma 2006/0070028 March 2006 Belov et al. 2006/0130015 June 2006 Griffin 2006/0206876 September 2006 Barton 2006/0212847 September 2006 Tarditi, Jr. 2007/0044083 February 2007 Meijer et al. 2008/0178140 July 2008 Lin 2008/0228761 September 2008 Kei Leung et al. 2008/0320440 December 2008 Meijer et al. 2009/0144714 June 2009 Fan et al. 2009/0328013 December 2009 Aharoni 2009/0328016 December 2009 Ng 2010/0088679 April 2010 Langworthy et al. 2010/0088686 April 2010 Langworthy 2011/0202906 August 2011 Asao 2012/0079464 March 2012 De Smet 2013/0125101 May 2013 Pamer 2013/0132070 May 2013 Dayan 2013/0159981 June 2013 Klemenz 2014/0019948 January 2014 Goetz et al. |
| Other References: | OpenJDK, State of the Lambda, 2011, pp. 1-9. cited by examiner Mads Torgersen, Adding Wildcards to the Java Programming Language, 2004, pp. 98-112. cited by examiner Goldman Sachs, GS Collections, Copyright 2011 Goldman Sachs, Version 1.2.0 (Mar. 14, 2012), pp. 1-24. cited by examiner Brian Goetz, Java theory and practice: Going wild with generics, Part 1, Understanding wildcard capture, 2008, pp. 1-8. cited by examiner Mohamed Sanaulla, Lambda Expressions in Java 8, May 2012, pp. 1-6. cited by examiner Martin Heitmanek, From developers to developers—K#, 2011, pp. 1-11. cited by examiner Frank Hinkel, Software Engineering, Architecture, 2012, pp. 1-8. cited by examiner Don Box, LINQ: .Net Language-Integrated Query, 2007, pp. 1-32. cited by examiner Goetz, Brian, Interface evolution via “public defender” methods, Third draft, Aug. 2010, 10 pages, retrieved Apr. 2, 2015 from: <http://cr.openjdk.java.net/˜briangoetz/lambda/>. cited by applicant Goetz, Brian, Interface evolution via virtual extension methods, Fourth draft, Jun. 2011, 12 pages, retrieved Apr. 2, 2015 from: <http://cr.openjdk.java.net/˜briangoetz/lambda/>. cited by applicant Goetz, Brian et al., Featherweight Defenders: A formal model for virtual extension methods in Java, Oracle Corporation, Mar. 27, 2012, 9 pages, retrieved Apr. 2, 2015 from: <http://cr.openjdk.java.net/˜briangoetz/lambda/>. cited by applicant Goetz, Brian, Featherweight Defenders, Jan. 19, 2011, 6 pages, retrieved Apr. 2, 2015 from: <http://cr.openjdk.java.net/˜briangoetz/lambda/>. cited by applicant Goetz, Brian, Featherweight Defenders, Jan. 31, 2011, 6 pages, retrieved Apr. 2, 2015 from: <http://cr.openjdk.java.net/˜briangoetz/lambda/>. cited by applicant Goetz, Brian et al., Featherweight Defenders: A formal model for virtual extension methods in Java, Oracle Corporation Dec. 2, 2011, 9 pages, retrieved Apr. 2, 2015 from: <http://cr.openjdk.java.net/˜briangoetz/lambda/>. cited by applicant Reinhold, Mark, Project Lambda: Straw-Man Proposal, licensed under a Creative Commons Attribution-Share Alike 3.0 U.S. License, Dec. 2009, 7 pages, retrieved Apr. 2, 2015 from: <http://cr.openjdk.java.net/˜mr/lambda/>. cited by applicant Goetz, Brian, State of the Lambda, Version 2, Jul. 6, 2010, 7 pages, retrieved Apr. 2, 2015 from: <http://cr.openjdk.java.net/˜briangoetz/lambda/>. cited by applicant Goetz, Brian, State of the Lambda, Oct. 10, 2010, 7 pages, retrieved Apr. 2, 2015 from: <http://cr.openjdk.java.net/˜briangoetz/lambda/>. cited by applicant Goetz, Brian, State of the Lambda, Dec. 2011, 4th edition, 10 pages, retrieved Apr. 2, 2015 from: <http://cr.openjdk.java.net/˜briangoetz/lambda/>. cited by applicant Goetz, Brian, Translation of Lambda Expressions, Apr. 2012, 10 pages, retrieved Apr. 2, 2015 from: <http://cr.openjdk.java.net/˜briangoetz/lambda/>. cited by applicant European Patent Office, International Searching Authority, International Search Report and Written Opinion dated Jan. 12, 2016 for International Application No. PCT/US2015/052060, 14 pages. cited by applicant Jameela Al-Jaroodi et al., “Middleware Infrastructure for Parallel and Distributed Programming Models in Heterogeneous Systems”, IEEE Transactions on Parallel and Distributed Systems, vol. 14, No. 11, Nov. 2003, 13 pages. cited by applicant Laurent Baduel et al., “Programming, Composing, Deploying for the Grid” in Grid Computing: Software Environments and Tools, Springer, 2006, 30 pages. cited by applicant |
| Assistant Examiner: | Nguyen, Mongbao |
| Primary Examiner: | Dao, Thuy |
| Attorney, Agent or Firm: | Tucker Ellis LLP |
| Accession Number: | edspgr.09557974 |
| Database: | USPTO Patent Grants |
| Abstract: | A system and method can support compatibility checking in a programming language environment. The programming language environment can check whether a target type associated with an expression in the programming language environment is functional, wherein the target type is functional when it has exactly one method meeting one or more criteria that define that method as relevant in a counting system. Then, the programming language environment can derive a function descriptor from the target type, which is context-dependent. Furthermore, the programming language environment can type-check the expression with the function descriptor associated with the target type. |
|---|