hg: valhalla/valhalla: Scanner, parser, semantic analysis and attribution support for value types
Srikanth
srikanth.adayapalam at oracle.com
Tue Jan 30 09:21:47 UTC 2018
Hello,
The commit below is the record of the change set I pushed to valhalla
"exp" branch
that contains the javac changes for scanner, parser, semantic analysis
and attribution
support for value types. Most of this is leveraged from the existing
prototype
and tweaked for the present work.
No code generation support exists at the moment. I will look into it now.
See below for the summary of changes and a couple of questions.
Summary of changes:
- Tag a type declaration as being a value type with __ByValue
modifier (>= JDK11)
- Value types may not declare a super class not even j.l.O
- Value class declarations and their instance fields must be final.
- Value types may not declare fields of their own types either
directly or indirectly.
- Null cannot be assigned to value types
- Null cannot be casted to or compared with value types.
- Support for static value factories and value instance creation
via __MakeDefault()
- Values have no instance lock and so may not be synchronized upon.
- Values have no identity and consequently the method
java.lang.System.identityHashCode
may not be invoked on them and
- The following methods from j.l.O are not allowed on value receivers:
- clone()
- finalize()
- wait()
- wait(long),
- wait(long, int)
- notify
- notifyAll
- Value instances may not be compared with == or !=
- Tests for the above restrictions.
Questions:
1. ATM, javac forbids comparison of values using != or ==. This
behavior is simply
brought forward from the original valhalla implementation. Is this what
we want in
the present prototype ? (in the context of acmp performance
characterization ?)
2. The support in the parser allows inner class to be declared as
__ByValue. Do we want
to restrict values to top level classes ? I seem to recall this being
suggested a while
ago - but I am unable to dig up the context.
Thanks!
Srikanth
On Tuesday 30 January 2018 02:49 PM, srikanth.adayapalam at oracle.com wrote:
> Changeset: 8d76e47a91e7
> Author: sadayapalam
> Date: 2018-01-30 14:45 +0530
> URL: http://hg.openjdk.java.net/valhalla/valhalla/rev/8d76e47a91e7
>
> Scanner, parser, semantic analysis and attribution support for value types
>
> ! src/java.compiler/share/classes/javax/lang/model/element/Modifier.java
> ! src/jdk.compiler/share/classes/com/sun/source/tree/NewClassTree.java
> ! src/jdk.compiler/share/classes/com/sun/tools/javac/code/Flags.java
> ! src/jdk.compiler/share/classes/com/sun/tools/javac/code/Source.java
> ! src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java
> ! src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java
> ! src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java
> ! src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Flow.java
> ! src/jdk.compiler/share/classes/com/sun/tools/javac/comp/MemberEnter.java
> ! src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TypeEnter.java
> ! src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java
> ! src/jdk.compiler/share/classes/com/sun/tools/javac/parser/Tokens.java
> ! src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties
> ! src/jdk.compiler/share/classes/com/sun/tools/javac/tree/JCTree.java
> ! src/jdk.compiler/share/classes/com/sun/tools/javac/util/Names.java
> ! src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Utils.java
> ! src/jdk.jshell/share/classes/jdk/jshell/CompletenessAnalyzer.java
> ! test/langtools/tools/javac/diags/examples.not-yet.txt
> + test/langtools/tools/javac/diags/examples/ValuesNotSupported.java
> + test/langtools/tools/javac/valhalla/lworld-values/CheckClone.java
> + test/langtools/tools/javac/valhalla/lworld-values/CheckClone.out
> + test/langtools/tools/javac/valhalla/lworld-values/CheckCyclicMembership.java
> + test/langtools/tools/javac/valhalla/lworld-values/CheckCyclicMembership.out
> + test/langtools/tools/javac/valhalla/lworld-values/CheckEquals.java
> + test/langtools/tools/javac/valhalla/lworld-values/CheckEquals.out
> + test/langtools/tools/javac/valhalla/lworld-values/CheckExtends.java
> + test/langtools/tools/javac/valhalla/lworld-values/CheckExtends.out
> + test/langtools/tools/javac/valhalla/lworld-values/CheckFinal.java
> + test/langtools/tools/javac/valhalla/lworld-values/CheckFinal.out
> + test/langtools/tools/javac/valhalla/lworld-values/CheckFinalize.java
> + test/langtools/tools/javac/valhalla/lworld-values/CheckFinalize.out
> + test/langtools/tools/javac/valhalla/lworld-values/CheckIdentityHash.java
> + test/langtools/tools/javac/valhalla/lworld-values/CheckIdentityHash.out
> + test/langtools/tools/javac/valhalla/lworld-values/CheckIdentityHash01.java
> + test/langtools/tools/javac/valhalla/lworld-values/CheckIdentityHash01.out
> + test/langtools/tools/javac/valhalla/lworld-values/CheckMakeDefault.java
> + test/langtools/tools/javac/valhalla/lworld-values/CheckMakeDefault.out
> + test/langtools/tools/javac/valhalla/lworld-values/CheckNullAssign.java
> + test/langtools/tools/javac/valhalla/lworld-values/CheckNullAssign.out
> + test/langtools/tools/javac/valhalla/lworld-values/CheckNullCastable.java
> + test/langtools/tools/javac/valhalla/lworld-values/CheckNullCastable.out
> + test/langtools/tools/javac/valhalla/lworld-values/CheckStaticValueFactory.java
> + test/langtools/tools/javac/valhalla/lworld-values/CheckStaticValueFactory.out
> + test/langtools/tools/javac/valhalla/lworld-values/CheckSuperCompileOnly.java
> + test/langtools/tools/javac/valhalla/lworld-values/CheckSync.java
> + test/langtools/tools/javac/valhalla/lworld-values/CheckSync.out
> + test/langtools/tools/javac/valhalla/lworld-values/CheckSynchronized.java
> + test/langtools/tools/javac/valhalla/lworld-values/CheckSynchronized.out
> + test/langtools/tools/javac/valhalla/lworld-values/CheckValueFactoryWithReference.java
> + test/langtools/tools/javac/valhalla/lworld-values/CheckValueFactoryWithReference.out
> + test/langtools/tools/javac/valhalla/lworld-values/CheckValueModifier.java
> + test/langtools/tools/javac/valhalla/lworld-values/CheckValueModifier.out
> + test/langtools/tools/javac/valhalla/lworld-values/Point.java
>
More information about the valhalla-dev
mailing list