<commit_before># Kahvi

**Work in progress**

Java compiler partially based on [Janino](http://www.janino.net), but mostly
written from scratch.

It's purpose is to create minor improvements for the Java language, not to
create a completely new programming language for JVM.

Here are some of the features:

## Default visibility

Since im tired of writing `public` everywhere, types, fields, constructors and
methods all have a default visibility. For types, constructors and methods,
it's `public` and for fields it's `private`.

~~~~
class Example
{
    String value;

    Example(String value)
    {
        this.value = value;
    }

    String getValue()
    {
        return this.value;
    }
}
~~~~

You can still use package level visibility, but it must be prefixed with the
`package` keyword:

~~~~
package void greet()
{
    System.out.println("Hello, World!");
}
~~~~

## Type inference

Java is statically compiled language, so the compiler already knows type of
each method and variable. With `var` keyword you can skip explicit type
declarations and let the compiler to determine type of variable or method.

### Local variables

~~~~
var foo = "bar";
~~~~

Translates into this:

~~~~
String foo = "bar";
~~~~

### Methods

If return type of a method is omitted, it is determined by the compiler from
return values inside the method body.

~~~~
foo()
{
    return 5;
}
~~~~

The return type of the method above is clearly `int`, so the compiler declares
it as `int foo()`.

If method has multiple return values, the *least generic type* from these
values is used as the return type of the method.

~~~~
foo(boolean someCondition)
{
    if (someCondition)
    {
        return new java.util.LinkedList<String>();
    } else {
        return new java.util.HashSet<String>();
    }
}
~~~~

In above example, two different kinds of objects are returned, but they have a
common super class *java.util.Collection* which is used as the return type.

## Non-nullable variables

Parameters and local variables can be declared as *non-nullable*, which means<commit_msg>typo fixes<commit_after># Kahvi

**Work in progress**

Java compiler partially based on [Janino](http://www.janino.net), but mostly
written from scratch.

It's purpose is to add minor improvements for the Java language, not to create
a completely new programming language for JVM.

Here are some of the planned features:

## Default visibility

Since i'm tired of writing `public` everywhere, types, fields, constructors and
methods all have a default visibility. For types, constructors and methods,
default visibility is `public` and for fields it's `private`.

~~~~
class Example
{
    String value;

    Example(String value)
    {
        this.value = value;
    }

    String getValue()
    {
        return this.value;
    }
}
~~~~

You can still use package level visibility, but it must be prefixed with the
`package` keyword:

~~~~
package void greet()
{
    System.out.println("Hello, World!");
}
~~~~

## Type inference

Java is statically typed language, so the compiler already knows type of each
method and variable. With `var` keyword you can skip explicit type declarations
and let the compiler to determine type of variable or method.

### Local variables

~~~~
var foo = "bar";
~~~~

Translates into this:

~~~~
String foo = "bar";
~~~~

### Methods

If return type of method is omitted, it is determined by the compiler from
return values inside the method body.

~~~~
foo()
{
    return 5;
}
~~~~

Return type of the method above is clearly `int`, so the compiler declares it
as `int foo()`.

If method has multiple return values, the *least generic type* from these
values is used as the return type of the method.

~~~~
someMethod(boolean someCondition)
{
    if (someCondition)
    {
        return new java.util.LinkedList<String>();
    } else {
        return new java.util.HashSet<String>();
    }
}
~~~~

In above example, two different kinds of objects are returned, but they have a
common super class *java.util.Collection* which is used as the return type.

## Non-nullable variables

Parameters and local variables can be declared as *non-nullable*, which means
{'fraction_non_alphanumeric': 0.09592326139088729, 'fraction_numerical': 0.00047961630695443646, 'mean_word_length': 3.712994350282486, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '153530', 'n_tokens_mistral': 1143, 'n_tokens_neox': 1120, 'n_words': 541}