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: | 10528,330 |
| Publication Date: | January 07, 2020 |
| Appl. No: | 16/234533 |
| Application Filed: | December 27, 2018 |
| 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 method, comprising: identifying a first instruction, in a set of code, that includes a particular expression and associates the particular expression with a first target type in a first context; wherein the particular expression includes (a) a list of one or more parameters and (b) a body including a single expression or a statement block; performing, during a compilation of the set of code, a first compatibility check on the particular expression and the first target type, wherein performing the first compatibility check on the particular expression and the first target type comprises: determining that the first target type is a functional interface, wherein only a single method of a set of one or more methods contained in the functional interface is not inherited from a particular class; determining a function descriptor associated with the first target type based on at least one of: a method type of the single method, a parameter type of the single method, a return type of the single method, and an exception type of the single method; type-checking the particular expression with the function descriptor associated with the first target type to determine compatibility between the particular expression and the first target type; determining, during the compilation of the set of code, that the particular expression is compatible with the first target type; identifying a second instruction, in the set of code, that includes the particular expression and associates the particular expression with a second target type in a second context; wherein the first target type and the second target type are different; performing, during the compilation of the set of code, a second compatibility check on the particular expression and the second target type; determining, during the compilation of the set of code, that the particular expression is compatible with the second target type; wherein the method is performed by at least one device including a hardware processor. |
| Claim: | 2. A system, comprising: at least one device including a hardware processor; and the system being configured to perform operations comprising: identifying a first instruction, in a set of code, that includes a particular expression and associates the particular expression with a first target type in a first context; wherein the particular expression includes (a) a list of one or more parameters and (b) a body including a single expression or a statement block; performing, during a compilation of the set of code, a first compatibility check on the particular expression and the first target type, wherein performing the first compatibility check on the particular expression and the first target type comprises: determining that the first target type is a functional interface, wherein only a single method of a set of one or more methods contained in the functional interface is not inherited from a particular class; determining a function descriptor associated with the first target type based on at least one of: a method type of the single method, a parameter type of the single method, a return type of the single method, and an exception type of the single method; type-checking the particular expression with the function descriptor associated with the first target type to determine compatibility between the particular expression and the first target type; determining, during the compilation of the set of code, that the particular expression is compatible with the first target type; identifying a second instruction, in the set of code, that includes the particular expression and associates the particular expression with a second target type in a second context; wherein the first target type and the second target type are different; performing, during the compilation of the set of code, a second compatibility check on the particular expression and the second target type; determining, during the compilation of the set of code, that the particular expression is compatible with the second target type. |
| Claim: | 3. The system of claim 2 , wherein: type-checking the particular expression with the function descriptor associated with the first target type to determine compatibility between the particular expression and the first target type comprises: type-checking a parameter, of the list of parameters, indicated by the particular expression with the parameter type of the single method associated with the first target type. |
| Claim: | 4. The system of claim 2 , wherein: type-checking the particular expression with the function descriptor associated with the first target type to determine compatibility between the particular expression and the first target type comprises: type-checking a particular return type associated with the body indicated by the particular expression with the return type of the single method associated with the first target type. |
| Claim: | 5. The system of claim 2 , wherein: type-checking the particular expression with the function descriptor associated with the first target type to determine compatibility between the particular expression and the first target type comprises: type-checking a particular exception type associated with the body indicated by the particular expression with the exception type of the single method associated with the first target type. |
| Claim: | 6. The system of claim 2 , wherein: the first instruction assigns the particular expression to an object of the first target type. |
| Claim: | 7. The system of claim 2 , wherein: the first instruction specifies the particular expression as a value for a parameter inputted to a particular method; and a parameter type of the parameter inputted to the particular method is the first target type. |
| Claim: | 8. The system of claim 2 , wherein: the first instruction casts the particular expression as the first target type. |
| Claim: | 9. The system of claim 2 , wherein: the first context comprises an assignment context; and the second context comprises at least one of: an invocation context and a casting context. |
| Claim: | 10. The system of claim 2 , wherein: type-checking the particular expression with the function descriptor associated with the first target type to determine compatibility between the particular expression and the first target type comprises: determining whether a particular type of a parameter, of the list of parameters, indicated by the particular expression is same as or assignment-compatible with the parameter type of the single method associated with the first target type. |
| Claim: | 11. One or more non-transitory machine-readable media storing instructions which, when executed by one or more processors, cause: identifying a first instruction, in a set of code, that includes a particular expression and associates the particular expression with a first target type in a first context; wherein the particular expression includes (a) a list of one or more parameters and (b) a body including a single expression or a statement block; performing, during a compilation of the set of code, a first compatibility check on the particular expression and the first target type, wherein performing the first compatibility check on the particular expression and the first target type comprises: determining that the first target type is a functional interface, wherein only a single method of a set of one or more methods contained in the functional interface is not inherited from a particular class; determining a function descriptor associated with the first target type based on at least one of: a method type of the single method, a parameter type of the single method, a return type of the single method, and an exception type of the single method; type-checking the particular expression with the function descriptor associated with the first target type to determine compatibility between the particular expression and the first target type; determining, during the compilation of the set of code, that the particular expression is compatible with the first target type; identifying a second instruction, in the set of code, that includes the particular expression and associates the particular expression with a second target type in a second context; wherein the first target type and the second target type are different; performing, during the compilation of the set of code, a second compatibility check on the particular expression and the second target type; determining, during the compilation of the set of code, that the particular expression is compatible with the second target type. |
| Claim: | 12. The one or more non-transitory machine-readable media of claim 1 , wherein: type-checking the particular expression with the function descriptor associated with the first target type to determine compatibility between the particular expression and the first target type comprises: type-checking a parameter, of the list of parameters, indicated by the particular expression with the parameter type of the single method associated with the first target type. |
| Claim: | 13. The one or more non-transitory machine-readable media of claim 11 , wherein: type-checking the particular expression with the function descriptor associated with the first target type to determine compatibility between the particular expression and the first target type comprises: type-checking a particular return type associated with the body indicated by the particular expression with the return type of the single method associated with the first target type. |
| Claim: | 14. The one or more non-transitory machine-readable media of claim 11 , wherein: type-checking the particular expression with the function descriptor associated with the first target type to determine compatibility between the particular expression and the first target type comprises: type-checking a particular exception type associated with the body indicated by the particular expression with the exception type of the single method associated with the first target type. |
| Claim: | 15. The one or more non-transitory machine-readable media of claim 11 , wherein: the first instruction assigns the particular expression to an object of the first target type. |
| Claim: | 16. The one or more non-transitory machine-readable media of claim 11 , wherein: the first instruction specifies the particular expression as a value for a parameter inputted to a particular method; and a parameter type of the parameter inputted to the particular method is the first target type. |
| Claim: | 17. The one or more non-transitory machine-readable media of claim 11 , wherein: the first instruction casts the particular expression as the first target type. |
| Claim: | 18. The one or more non-transitory machine-readable media of claim 11 , wherein: the first context comprises an assignment context; and the second context comprises at least one of: an invocation context and a casting context. |
| Claim: | 19. The one or more non-transitory machine-readable media of claim 11 , wherein performing the first compatibility check on the particular expression and the first target type further comprises: inferring a natural parameterized type from a wildcard-parameterized functional interface type associated with the first target type; and type-checking the particular expression with the natural parameterized type. |
| Claim: | 20. The one or more non-transitory machine-readable media of claim 11 , wherein: type-checking the particular expression with the function descriptor associated with the first target type to determine compatibility between the particular expression and the first target type comprises: determining whether a particular type of a parameter, of the list of parameters, indicated by the particular expression is same as or assignment-compatible with the parameter type of the single method associated with the first target type. |
| Patent References Cited: | 5748966 May 1998 Sato 6149318 November 2000 Chase et al. 6973646 December 2005 Bordawekar et al. 7055132 May 2006 Bogdan et al. 7350193 March 2008 Belov et al. 7620944 November 2009 Beccario et al. 7716644 May 2010 Horton et al. 7761856 July 2010 Griffin 7873592 January 2011 Meijer et al. 7913239 March 2011 Barton et al. 7934207 April 2011 Gustafsson et al. 8060868 November 2011 Meijer et al. 8266145 September 2012 Leung et al. 8397227 March 2013 Fan et al. 8516458 August 2013 Stewart et al. 8555264 October 2013 Ohrstrom 8656379 February 2014 Meirowitz 8739137 May 2014 Siskind 8762942 June 2014 Langworthy et al. 8813049 August 2014 Goetz et al. 8990010 March 2015 Pfeifle et al. 8997070 March 2015 Klemenz et al. 9170787 October 2015 Aharoni et al. 9177017 November 2015 De et al. 9195442 November 2015 Goetz et al. 9336018 May 2016 Zhou et al. 9542168 January 2017 Pamer 2003/0033596 February 2003 Souloglou et al. 2004/0083465 April 2004 Zhang 2004/0216094 October 2004 Bosworth et al. 2005/0066319 March 2005 Deline et al. 2005/0081192 April 2005 Deline et al. 2005/0229048 October 2005 Da et al. 2006/0070028 March 2006 Belov et al. 2006/0130015 June 2006 Griffin 2006/0190935 August 2006 Kielstra 2006/0206876 September 2006 Barton et al. 2006/0212847 September 2006 Tarditi et al. 2007/0028223 February 2007 Meijer 2007/0044083 February 2007 Meijer et al. 2008/0178140 July 2008 Lin et al. 2008/0228761 September 2008 Kei et al. 2008/0262992 October 2008 Meijer et al. 2008/0320440 December 2008 Meijer et al. 2009/0144714 June 2009 Fan et al. 2009/0222799 September 2009 Stewart et al. 2009/0319991 December 2009 Shneerson et al. 2009/0328013 December 2009 Aharoni et al. 2009/0328016 December 2009 Ng et al. 2010/0066879 March 2010 Tanaka 2010/0088679 April 2010 Langworthy et al. 2010/0088686 April 2010 Langworthy et al. 2010/0180264 July 2010 Aharoni et al. 2010/0191930 July 2010 Groff 2010/0192129 July 2010 Langworthy et al. 2010/0299658 November 2010 Ng 2011/0167404 July 2011 Liu et al. 2011/0202906 August 2011 Asao 2011/0258593 October 2011 Ng et al. 2011/0314459 December 2011 Husbands 2012/0005660 January 2012 Goetz et al. 2012/0079464 March 2012 De et al. 2012/0079465 March 2012 Harvey 2012/0137277 May 2012 Varadarajan et al. 2013/0125101 May 2013 Pamer 2013/0132070 May 2013 Dayan et al. 2013/0159981 June 2013 Klemenz et al. 2014/0019948 January 2014 Goetz et al. 2014/0068557 March 2014 Vanags et al. |
| Other References: | Yau Chi Hang, A Novel Just-In-Time Compiler on an Embedded Object-Oriented Processor, 2005, pages https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=1562749 (Year: 2005). cited by examiner Mark Michaelis, Delegates and Lambda Expressions in C# 3.0, 2008, pp. 1-15. http://www.informit.com/articles/article.aspx?p=1245158&seqNum=4 (Year: 2008). cited by examiner Franck Binard, An Abstraction-Based Genetic Programming System, 2007, pp. 2415-2422. https://dl.acm.org/citation.cfm?id=1274004 (Year: 2007). cited by examiner Zeeshan Jafar Hirani, Exploring Lambda Expression in C#, 2008, pp. 1-6. https://www.codeproject.com/Articles/24255/Exploring-Lambda-Expression-in-C (Year: 2008). cited by applicant Ying Hu, C/C++ Conditional Compilation Analysis Using Symbolic Execution, 2000, pp. 196-206. https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=883045 (Year: 2000). cited by applicant Willem Van Ketwich, Using LINQ with generics and lambda expression to add wildcard searches to a query, 2010, pp. 1-4. cited by applicant Saurabh Srivastava, Modular Information Hiding and Type-Safe Linking for C, 2008, pp. 357-375 https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=4497211 (Year: 2008). cited by applicant Sanaulla, Mohamed, “Lambda Expressions in Java 8”, May 21, 2012, Copyright by JavaBeat, 9 pages. 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/.about.mr/lambda>. cited by applicant Peter M. Kelly, Lambda Calculus as a Workflow Model, 2008, pp. 15-22. https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=4539319 (Year: 2008). cited by applicant Martin Heitmanek, From developers to developers—K#, 2011, pp. 1-11. cited by applicant Mads Torgersen, Erik Ernst, Christian Plesner Hansen, Peter Von Der Ahe, Filad Bracha, Neal Gafter: “Adding Wildcards to the Java Programming Language” Journal of Object Technology, vol. 3, No. 11, Dec. 2004, Special issue: OOPS track at SAC 2004, Nicosia/Cyprus, pp. 97-116. <http://www.jol.fm/issues/issue_2004_12/article5/>. cited by applicant Mads Torgersen, Adding Wildcards to the Java Programming Language, 2004, pp. 1-8. http://www.bracha.org/wildcards.pdf. 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 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 Hinkel, Frank, Software Engineering, Architecture, “Java 8—Closures, Lambda Expressions Demystified”, Nov. 28, 2012, 8 pages, retrieved from: <http://frankhinkel.blogspol.de/2012/11/java-8-closures-lambda-expressions.html>. cited by applicant Goldman Sachs, GS Collections, Copyright 2011 Goldman Sachs, Version 1.2.0 (Mar. 14, 2012), pp. 1-24. cited by applicant Goetz, Brian, Translation of Lambda Expressions, Apr. 2012, 10 pages, retrieved Apr. 2, 2015 from: <http://cr.openjdk.java.net/.about.briangoetz/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/.about.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/.about.briangoetz/lambda/>. cited by applicant Goetz, Brian, State of the Lambda, Dec. 2011, 4th edition, 10 pages, retrieved Apr. 2, 2015 from: <http://cr.openjdkjava.net/.about.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/.about.briangoetz/lambda/>. cited by applicant Goetz, Brian, Interface evolution via “public defender” methods, Third draft, Aug. 2010, 10 pages, retrieved Apr. 2, 2015 from: <http://cr.openjdk.java.net/.about.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/.about.briangoetz/lambda/>. cited by applicant Georgios Korfiatis, A Type and Effect System for Implementing Functional Arrays with Destructive Updates, 2011, pp. 879-885. https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=6078196 (Year: 2011). cited by applicant Francisco Ortin, Design Patterns for Teaching Type Checking in a Compiler Construction Course, 2007, pp. 1-11. https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=4287122 (Year: 2007). cited by applicant Don Box, LINQ: .NET Language-Integrated Query, 2007, pp. 1-32. cited by applicant D.A. Lampasi, The Generalized Lambda Distribution for the Expression of Measurement Uncertainty, 2005, pp. 2118-2123. https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=1604548 (Year: 2005). cited by applicant Brian Goetz, Java theory and practice: Going wild with generics, Part 1, Understanding wildcard capture, 2008, pp. 1-8. cited by applicant |
| Primary Examiner: | Nguyen, Mongbao |
| Attorney, Agent or Firm: | Invoke |
| Accession Number: | edspgr.10528330 |
| 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. |
|---|