System and method for supporting compatibility checking for lambda expression

Saved in:
Bibliographic Details
Title: System and method for supporting compatibility checking for lambda expression
Patent Number: 10209,970
Publication Date: February 19, 2019
Appl. No: 15/402319
Application Filed: January 10, 2017
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 particular expression in a set of code during compilation of the set of code; determining a target type associated with the particular expression based on a context associated with the particular expression; checking that the target type associated with the particular expression is a functional interface including a single abstract method; determining a function descriptor associated with the target type based on at least one of: a method type of the single abstract method, a parameter type of the single abstract method, a return type of the single abstract method, and an exception type of the single abstract method; type-checking the particular expression with the function descriptor associated with the target type to determine compatibility between the particular expression and the target type; responsive to determining that the particular expression is not compatible with the target type: generating an error at compile time indicating that the particular expression is not compatible with the target type; identifying a second expression in the set of code during compilation of the set of code; determining a second target type associated with the second expression based on a second context associated with the second expression; checking that the second target type associated with the second expression is a second functional interface including a second single abstract method; determining a second function descriptor associated with the second target type based on at least one of: a second method type of the second single abstract method, a second parameter type of the second single abstract method, a second return type of the second single abstract method, and a second exception type of the second single abstract method; type-checking the second expression with the second function descriptor associated with the second target type to determine compatibility between the second expression and the second target type; responsive to determining that the second expression is compatible with the second target type: accepting the second expression in the set of code; wherein the method is performed by at least one device including a hardware processor.
Claim: 2. The method according to claim 1 , wherein the particular expression is a lambda expression that provides a list of one or more parameters and a body.
Claim: 3. The method according to claim 2 , further comprising: inferring one or more parameter types associated with the lambda expression.
Claim: 4. The method according to claim 2 further comprising: type-checking one or more parameter types associated with the lambda expression with the function descriptor.
Claim: 5. The method according to claim 2 , further comprising: type-checking a return type of the body of the lambda expression with the function descriptor.
Claim: 6. The method according to claim 2 , further comprising: type-checking one or more exception types that can result from an execution of the body of the lambda expression with the function descriptor.
Claim: 7. The method according to claim 2 , wherein the lambda expression appears in one of: an assignment context, an invocation context, and a casting context.
Claim: 8. The method according to claim 1 , wherein type-checking the particular expression with the function descriptor associated with the target type comprises: inferring a natural parameterized type from a wildcard-parameterized functional interface type associated with the target type; type-checking the particular expression with the natural parameterized type.
Claim: 9. The method of claim 1 , further comprising: determining the function descriptor associated with the target type based on the method type of the single abstract method.
Claim: 10. The method of claim 1 , further comprising: determining the function descriptor associated with the target type based on the parameter type of the single abstract method.
Claim: 11. The method of claim 1 , further comprising: determining the function descriptor associated with the target type based on the return type of the single abstract method.
Claim: 12. The method of claim 1 , further comprising: determining the function descriptor associated with the target type based on the exception type of the single abstract method.
Claim: 13. A system, comprising: one or more microprocessors; a compiler, running on the one or more microprocessors, that operates to perform the steps of: identifying a particular expression in a set of code; determining a target type associated with the particular expression based on a context associated with the particular expression; checking that the target type associated with the particular expression is a functional interface including a single abstract method; determining a function descriptor associated with the target type based on at least one of: a method type of the single abstract method, a parameter type of the single abstract method, a return type of the single abstract method, and an exception type of the single abstract method; type-checking the particular expression with the function descriptor associated with the target type to determine compatibility between the particular expression and the target type; responsive to determining that the particular expression is not compatible with the target type: generating an error at compile time indicating that the particular expression is not compatible with the target type; identifying a second expression in the set of code during compilation of the set of code; determining a second target type associated with the second expression based on a second context associated with the second expression; checking that the second target type associated with the second expression is a second functional interface including a second single abstract method; determining a second function descriptor associated with the second target type based on at least one of: a second method type of the second single abstract method, a second parameter type of the second single abstract method, a second return type of the second single abstract method, and a second exception type of the second single abstract method; type-checking the second expression with the second function descriptor associated with the second target type to determine compatibility between the second expression and the second target type; responsive to determining that the second expression is compatible with the second target type: accepting the second expression in the set of code.
Claim: 14. The system according to claim 13 , wherein: the particular expression is a lambda expression that provides a list of one or more parameters and a body.
Claim: 15. The system according to claim 14 , wherein: inferring one or more parameter types associated with the lambda expression.
Claim: 16. The system according to claim 14 wherein: type-checking one or more parameter types associated with the lambda expression with the function descriptor.
Claim: 17. The system according to claim 14 , wherein: type-checking a return type of the body of the lambda expression with the function descriptor.
Claim: 18. The system according to claim 14 , wherein: type-checking one or more exception types that can result from an execution of the body of the lambda expression with the function descriptor.
Claim: 19. The method according to claim 14 , wherein: the lambda expression appears in one of: an assignment context, an invocation context, and a casting context.
Claim: 20. The system according to claim 14 , wherein: inferring a natural parameterized type from a wildcard-parameterized functional interface type and the lambda expression.
Claim: 21. A non-transitory machine readable storage medium having instructions stored thereon that when executed cause a system to perform the steps comprising: identifying a particular expression in a set of code during compilation or execution of the set of code; determining a target type associated with the particular expression based on a context associated with the particular expression; checking that the target type associated with the particular expression is a functional interface including a single abstract method; determining a function descriptor associated with the target type based on at least one of: a method type of the single abstract method, a parameter type of the single abstract method, a return type of the single abstract method, and an exception type of the single abstract method; type-checking the particular expression with the function descriptor associated with the target type to determine compatibility between the particular expression and the target type; responsive to determining that the particular expression is not compatible with the target type: generating an error at compile time indicating that the particular expression is not compatible with the target type; identifying a second expression in the set of code during compilation of the set of code; determining a second target type associated with the second expression based on a second context associated with the second expression; checking that the second target type associated with the second expression is a second functional interface including a second single abstract method; determining a second function descriptor associated with the second target type based on at least one of: a second method type of the second single abstract method, a second parameter type of the second single abstract method, a second return type of the second single abstract method, and a second exception type of the second single abstract method; type-checking the second expression with the second function descriptor associated with the second target type to determine compatibility between the second expression and the second target type; responsive to determining that the second expression is compatible with the second target type: accepting the second expression in the set of code.
Patent References Cited: 5748966 May 1998 Sato
6149318 November 2000 Chase
6973646 December 2005 Bordawekar
7055132 May 2006 Bogdan
7350193 March 2008 Belov
7620944 November 2009 Beccario
7716644 May 2010 Horton
7761856 July 2010 Griffin
7873592 January 2011 Meijer
7913239 March 2011 Barton
7934207 April 2011 Gustafsson
8060868 November 2011 Meijer
8266145 September 2012 Leung
8397227 March 2013 Fan
8516458 August 2013 Stewart
8762942 June 2014 Langworthy
8813049 August 2014 Goetz
8990070 March 2015 Dayan
8997070 March 2015 Klemenz
9170787 October 2015 Aharoni
9177017 November 2015 De Smet
9195442 November 2015 Goetz
9336018 May 2016 Zhou
9542168 January 2017 Pamer
2003/0033596 February 2003 Souloglou
2004/0216094 October 2004 Bosworth
2005/0066319 March 2005 DeLine
2005/0081192 April 2005 DeLine
2005/0229048 October 2005 Da Palma
2006/0070028 March 2006 Belov et al.
2006/0130015 June 2006 Griffin
2006/0206876 September 2006 Barton et al.
2006/0212847 September 2006 Tarditi, Jr.
2007/0044083 February 2007 Meijer et al.
2008/0178140 July 2008 Lin
2008/0228761 September 2008 Kei et al.
2008/0262992 October 2008 Meijer
2008/0320440 December 2008 Meijer et al.
2009/0144714 June 2009 Fan et al.
2009/0222799 September 2009 Stewart
2009/0319991 December 2009 Shneerson
2009/0328013 December 2009 Aharoni
2009/0328016 December 2009 Maly
2010/0066879 March 2010 Tanaka
2010/0088679 April 2010 Langworthy
2010/0088686 April 2010 Langworthy
2010/0192129 July 2010 Langworthy
2011/0167404 July 2011 Liu
2011/0202906 August 2011 Asao
2011/0258593 October 2011 Ng
2012/0005660 January 2012 Goetz
2012/0079464 March 2012 De et al.
2012/0079465 March 2012 Harvey
2012/0137277 May 2012 Varadarajan
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





























Other References: Mads Torgersen, Adding Wildcards to the Java Programming Language, 2004, pp. 1-8. http://www.bracha.org/wildcards.pdf. cited by examiner
Willem Van Ketwich, Using LINQ with generics and lambda expression to add wildcard searches to a query, 2010, pp. 1-4. cited by examiner
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 examiner
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 examiner
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 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 examiner
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 examiner
Georgios Korfiatis, A Type and Effect System for Implementing Functional Arrays with Destructive Updates, 2011, pp. 1-8. https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=6078196 (Year: 2011). cited by examiner
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 examiner
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 examiner
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
Goetz, Brian, Interface evolution via Apublic 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
Goetz, Brian, Java theory and practice: Going wild with generics, Part 1 Understanding wildcard capture, May 6, 2008, 8 pages. cited by applicant
Heitmanek, Martin, “From developers to developers—K#”, Dec. 6, 2011, 11 pages. cited by applicant
Box, Don et al., “LINQ: .NET Language-Integrated Query”, Feb. 2007, 32 pages. cited by applicant
Hinkel, Frank, Software Engineering, Architecture, “Java 8—Closures, Lambda Expressions Demystified”, Nov. 28, 2012, 8 pages, retrieved from: <http://frankhinkel.blogspot.de/2012/11/java-8-closures-lambda-expressions.html>. cited by applicant
Goldman Sachs, GS Collections User Reference Guide, Version 1.2.0 (Mar. 14, 2012), Copyright © 2011 Goldman Sachs, 44 pages. cited by applicant
Sanaulla, Mohamed, “Lambda Expressions in Java 8”, May 21, 2012, Copyright © by JavaBeat, 9 pages. cited by applicant
Mads Torgersen, Erik Ernst, Christian Plesner Hansen, Peter Von Der Ahé, 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.jot.fm/issues/issue_2004_12/article5/>. cited by applicant
Primary Examiner: Nguyen, Mongbao
Attorney, Agent or Firm: Invoke
Accession Number: edspgr.10209970
Database: USPTO Patent Grants
Description
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.