What are “sugar”, “desugar” terms in context of Java 8?

前端 未结 4 887
予麋鹿
予麋鹿 2021-01-30 10:03

I hear about \'sugaring\' and \'desugaring\' more often in Java 8, what does these terms mean ? are they conceptual or syntactical.

Some Example:

Defa

4条回答
  •  无人共我
    2021-01-30 10:19

    "Desugaring" appears to have a very specific meaning in Java 8. It seems to be a catch-all term to express the various ways a lambda expression may be bound to an actual concrete method call.

    This document on "Translation of Lambda Expressions" has the real details of what's going on if you're interested in specifics.

    A key phrase from the document:

    The first step of translating lambdas into bytecode is desugaring the lambda body into a method.

提交回复
热议问题