Skip to content

Does current target support mean that boolean nativeTryWithResources = isAtLeast(b, JAVA7); in XbaseCompiler.java is always true? #3709

@dilyanpalauzov

Description

@dilyanpalauzov

The release notes for Xtext 2.42.0 contain:

This will be the last release with Java 17 support.

The release notes for Xtext 2.26.0 contain:

Xtext now supports running on Java 17 with Java 8 and 11 targets. Source and Target 17 are not supported yet and are planned for Xtext 2.27.0. This will also require dropping Java 8 in the next release.

  • Can in XbaseCompiler be assumed that both variables boolean nativeTryWithResources = isAtLeast(b, JAVA7) are always true?

That said, are n xbase/compiler/XbaseCompiler.java:_toJavaStatement() these Java 7 blocks necessary:

                // Resources declared before the try-statement, for java versions < 7
                if (isTryWithResources && !nativeTryWithResources) {
                        for (XVariableDeclaration res : resources) {
                                b.newLine();
                                // resource has to be declared and initialized with null before
                                // try and with real AutoClosable implementation within try
                                // has to be var not val (final)
                                res.setWriteable(true);
                                LightweightTypeReference type = appendVariableTypeAndName(res, b);
                                resourceMap.put(res.getName(), type);
                                b.append(" = null;");
                        }
                }
…                
                // Resources for java versions < 7
                // constructed at the beginning of try-statement
                if (isTryWithResources && !nativeTryWithResources) {
                        for (XVariableDeclaration res : resources) {
                                b.newLine();
                                b.append(getVarName(res, b));
                                b.append(" = ");
                                LightweightTypeReference type = resourceMap.get(res.getName());
                                compileAsJavaExpression(res.getRight(), b, type);
                                b.append(";");
                        }
                }

In the source code there are also checks for isAtLeast(JAVA6)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions