Commit Graph

40 Commits

Author SHA1 Message Date
William S Fulton ef0d38bffd Support JDK 21 and std::list
Fixes removeFirst() and removeLast() incompatibilities with methods
of the same name in the Java base class java.util.AbstractSequentialList
which were added in JDK 21 as part of JEP-431.

configure.ac has been modified to detect the version of JDK/Java for use
in testing the test-suite via the JAVA_VERSION_MAJOR variable.

Needed to continue testing removeFirst(), removeLast(), addFirst(), addLast().

Closes #3156
2025-04-02 22:56:11 +01:00
William S Fulton aaeef05f72 Fix javac -Xlint warning [this-escape] - JDK 21 in STL containers
[this-escape] possible 'this' escape before subclass is fully initialized
in std::list, std::vector, std::set, std::unordered_set constructors.
2025-04-02 22:55:18 +01:00
William S Fulton af65817279 Fix javac -Xlint warnings:
- [cast] redundant cast in std::unordered_map wrappers put method
- [rawtypes] found raw type in std::list constructor wrapper
2025-04-02 22:54:39 +01:00
William S Fulton 280b3a908e Java STL changes to use Java int, support 64-bit size_t
std::vector::capacity and std::vector::reserve signature changes.

Java api changes from:
  public long capacity() { ... }
  public void reserve(long n) { ... }
to:
  public int capacity() { ... }
  public void reserve(int n) { ... }
to fit in with the usual Java convention of using int for container
indexing and sizing.

The original api for std::vector::reserve can be also be made available via
%extend to add in an overloaded method as follows:

  %include <std_vector.i>
  %extend std::vector {
    void reserve(jlong n) throw (std::length_error, std::out_of_range) {
      if (n < 0)
        throw std::out_of_range("vector reserve size must be positive");
      self->reserve(n);
    }
  }

This change is partially driven by the need to seamlessly support the full
64-bit range for size_t generically, apart from the customisations for the
STL containers, by using:

  %apply unsigned long long { size_t };
  %apply const unsigned long long & { const size_t & };

Similarly for std::array::size.

Also enhance docs for applying unsigned long long typemaps for 64-bit
size_t.
2023-10-06 19:42:39 +01:00
William S Fulton be491506a4 Java std::vector improvements for types that do not have a default constructor.
The std::vector wrappers have been changed to work by default for elements that are
not default insertable, i.e. have no default constructor. This has been achieved by
not wrapping:

  vector(size_type n);

Previously the above had to be ignored via %ignore.

If the above constructor is still required it can be added back in again via %extend:

  %extend std::vector {
    vector(size_type count) { return new std::vector< T >(count); }
  }

Alternatively, the following wrapped constructor could be used as it provides near-enough
equivalent functionality:

  vector(jint count, const value_type& value);

The equivalent change to std::list has also been made (std::list
wrappers were not in the previous release [3.0.12] though).
2019-03-01 18:01:14 +00:00
Zachary Hensley d812a4291c Handle review comments 2019-02-22 10:55:20 -06:00
William S Fulton 6d27ead9c0 Add STL container copy constructors where missing
Also provide consistent copy constructor declarations.
2019-02-14 18:53:05 +00:00
William S Fulton 440264e479 Add missing typedefs to std::list + typedef corrections
Numerous missing typedefs added.
std::list<T*>::const_reference and std::list<T*>::reference
specialization typedef fixes.
2019-02-14 07:31:21 +00:00
William S Fulton 06c275935b Add readme info for Java container wrappers 2017-07-18 07:17:03 +01:00
William S Fulton 44cd658a53 Add in missing Java std::list listIterator index range checking 2017-06-29 19:32:34 +01:00
William S Fulton fccf5c29b4 Minor correction in C# std::list doNextIndex 2017-06-29 15:34:05 +01:00
William S Fulton d04eb88742 Consistent destructor declarations 2017-06-26 13:53:49 +01:00
William S Fulton d92faa7f7f Remove Java std::list::max_size
Not in any Java equivalent containers nor std::vector wrapper.
2017-06-26 13:43:57 +01:00
William S Fulton 6daed2cea1 Remove Java std::list::assign
This doesn't exist in equivalent Java containers. If we put it back, the
full set of overloaded assign wrappers ought to be added.
2017-06-26 12:28:02 +01:00
William S Fulton ecebbdd0df Additional add/remove methods added to Java std::list wrappers
Add functions similar to java.util.LinkedList<E>:
  addFirst
  addLast
  removeFirst
  removeLast
2017-06-25 00:10:06 +01:00
William S Fulton c686045f55 More efficient add implementation for Java std::list
The default implementation in AbstractSequentialList<E>
calls add(size(), e) and size() might be expensive.
2017-06-24 23:33:31 +01:00
William S Fulton a8e948e96d Java std::vector std::list: add missing exception handling 2017-06-24 22:53:11 +01:00
William S Fulton ea55c5bba0 Java std::vector std::list enhancements
- Add missing vector copy constructor
- Add constructor to initialize the containers. Note that Java's
  equivalent constructor for ArrayList just sets the capacity, whereas
  the wrappers behave like the C++ constructor and set the size. I've
  done this mainly because there has been a vector(size_type) constructor
  in the Java wrappers for many years, so best to keep this unchanged.
2017-06-24 14:30:03 +01:00
William S Fulton b40b9aee83 Modify std::list declarations to match the C++ standard 2017-06-23 20:10:26 +01:00
William S Fulton 2d99027935 Fix removing elements from std::list Java wrapper
Add missing remove method on Java side (without it elements aren't
removed).
2017-06-23 16:17:00 +01:00
William S Fulton 428b332e68 Improve Java std::list std::vector runtime tests and wrap std::list::clear 2017-06-23 15:42:59 +01:00
William S Fulton 990c597365 Wrap std::list::empty as isEmpty in Java 2017-06-23 15:26:53 +01:00
William S Fulton 109a60add6 javabase typemap improvement for std::list 2017-06-22 22:17:59 +01:00
William S Fulton 430376e115 Java std::list - fully qualifiy Java class name to avoid potential name ambiguity 2017-06-22 22:11:02 +01:00
William S Fulton 7b7f921ccb cosmetics 2017-06-22 20:38:19 +01:00
William S Fulton 02a00db9f5 Remove redundant code 2017-06-22 20:33:16 +01:00
William S Fulton dd25f5b722 Java std::list rework to be consistent with std::vector wrappers 2017-06-22 20:33:09 +01:00
Alan Woodland 0083d451db Switched from autobox to jboxtype per #842 2017-06-05 21:58:58 +01:00
Alan Woodland c5a724f1bb Made the conversion from long->int for size_type mapping onto Java interfaces cleaner. 2016-05-31 21:43:13 +01:00
Alan Woodland 5eb46d5f9f Be consistent in semantics of %extend on std::list::iterator 2016-05-31 21:06:09 +01:00
Alan Woodland 00ac1f38e5 Comment on consideration of making iterator non-static. 2016-05-31 21:06:09 +01:00
Alan Woodland 1f4a8e6231 Java style fix: iterator->Iterator 2016-05-31 20:28:08 +01:00
Alan Woodland 583fdce790 Moving iterator functionality into nested Java class now. 2016-05-31 20:22:39 +01:00
Alan Woodland e561a78205 Added a best case workaround for std::list::size_type vs jint problem. There's a bit of commentry added around it too for clarity. 2016-05-31 14:49:03 +01:00
Alan Woodland b09fce84a4 just use a forward declaration for C++ iterator types to fix enum errors 2016-05-31 14:49:02 +01:00
Alan Woodland d217a68908 added more comments in a few places 2016-05-31 14:49:02 +01:00
Alan Woodland a2b092ab7e Don't expose sort() to avoid adding dependencies on all std::list users 2016-05-31 14:49:01 +01:00
Alan Woodland 0094e3c90d Target each method specificly for setting modifiers 2016-05-31 14:49:01 +01:00
Alan Woodland b0de71857e Don't expose remove() method from std::list to avoid confusing it with Java's remove() in List 2016-05-31 14:49:01 +01:00
Alan Woodland 6a4467721b - added std_list.i implemenatation that extends Java's AbstractSequentialList base class
- added autobox.i that provides supporting typemaps for generics in containers
2016-05-31 14:49:00 +01:00