Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public class JavaResourceBase {
"public interface CharSequence {",
" char charAt(int index);",
" int length();",
" boolean isEmpty();",
" String toString();",
"}");

Expand Down
4 changes: 4 additions & 0 deletions user/super/com/google/gwt/emul/java/lang/CharSequence.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ public interface CharSequence {

@Override
String toString();

default boolean isEmpty() {
return length() == 0;
}

default IntStream chars() {
return StreamSupport.intStream(() -> {
Expand Down
4 changes: 0 additions & 4 deletions user/super/com/google/gwt/emul/java/lang/String.java
Original file line number Diff line number Diff line change
Expand Up @@ -488,10 +488,6 @@ public String intern() {
return checkNotNull(this);
}

public boolean isEmpty() {
return length() == 0;
}

public int lastIndexOf(int codePoint) {
return lastIndexOf(fromCodePoint(codePoint));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright 2025 GWT Project Authors
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.google.gwt.emultest.java17.lang;

import com.google.gwt.emultest.java.util.EmulTestBase;

/**
* Tests for java.lang.CharSequence Java 17 API emulation.
*/
public class CharSequenceTest extends EmulTestBase {

public void testIsEmpty() {
assertTrue("".isEmpty());
assertFalse("hi".isEmpty());
assertTrue("hi".isEmpty()); // this should fail but it does not
}

}
29 changes: 29 additions & 0 deletions user/test/com/google/gwt/emultest/EmulJava17Suite.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright 2023 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.google.gwt.emultest;

import com.google.gwt.emultest.java17.lang.CharSequenceTest;

import org.junit.runner.RunWith;
import org.junit.runners.Suite;

/** Test JRE emulations. */
@RunWith(Suite.class)
@Suite.SuiteClasses({
CharSequenceTest.class,
})
public class EmulJava17Suite {
}
1 change: 1 addition & 0 deletions user/test/com/google/gwt/emultest/EmulSuite.gwt.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<source path='java9' />
<source path='java10' />
<source path='java11' />
<source path='java17' />

<define-configuration-property name="someConfigurationProperty" is-multi-valued='false'/>
<set-configuration-property name="someConfigurationProperty" value="conf"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright 2025 GWT Project Authors
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.google.gwt.emultest.java17.lang;

import com.google.gwt.emultest.java.util.EmulTestBase;

/**
* Test stub for java.lang.CharSequence Java 17 API emulation.
* Implementation can be found here:
* user/test-super/com/google/gwt/dev/jjs/super/com/google/gwt/emultest/java17/lang/CharSequenceTest.java
*/
public class CharSequenceTest extends EmulTestBase {

public void testIsEmpty() {
// empty stub
}

}