--- a/JavaMethod.st Thu Jun 25 15:54:39 2015 +0100
+++ b/JavaMethod.st Wed Jul 01 07:14:28 2015 +0100
@@ -1562,9 +1562,17 @@
!JavaMethod methodsFor:'debugging'!
breakPoint
- Debugger enter:thisContext sender withMessage:'breakpoint'
+
+ <resource: #skipInDebuggersWalkBack>
+
+ BreakPointInterrupt
+ raiseRequestWith: self
+ errorString:('Breakpoint encountered')
+
"Modified: / 9.1.1998 / 23:01:17 / cg"
+ "Modified: / 29-06-2015 / 16:00:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+
!
clearBreakPoint
--- a/JavaNativeMethodImpl_OpenJDK6.st Thu Jun 25 15:54:39 2015 +0100
+++ b/JavaNativeMethodImpl_OpenJDK6.st Wed Jul 01 07:14:28 2015 +0100
@@ -10694,7 +10694,7 @@
%{
union {
float flt;
- INT i;
+ int i;
} u;
u.flt = __shortFloatVal(f);
RETURN ( __MKINT( u.i ) );
@@ -10715,7 +10715,7 @@
%{
union {
float flt;
- INT i;
+ int i;
} u;
u.i = __signedLongIntVal(ii);
__shortFloatVal(ff) = u.flt;
--- a/JavaVM.st Thu Jun 25 15:54:39 2015 +0100
+++ b/JavaVM.st Wed Jul 01 07:14:28 2015 +0100
@@ -1980,12 +1980,9 @@
Java initializeRelease.
- "Java requires a huge stack. Change default to 16 MB.
- Observations:
- - Groovy 'rnd = new java.security.SecureRandom()' requires > 4MB
- - ant run on Groovy 1.8.7 source requires > 8MB
+ "Interpreted Java requires a huge stack. Change default to 4MB (32bit) / 8MB (64bit).
"
- Process defaultMaximumStackSize: ((1024 * 1024 * 4) max: Process defaultMaximumStackSize).
+ Process defaultMaximumStackSize: ((1024 * 1024 * (ExternalAddress pointerSize // 4)) max: Process defaultMaximumStackSize).
"Java Classes are huge and there is a (unfixed) bug in 2-phase oldspace
compress, so try to avoid it by pre-allocating more oldspace."
--- a/Make.proto Thu Jun 25 15:54:39 2015 +0100
+++ b/Make.proto Wed Jul 01 07:14:28 2015 +0100
@@ -78,6 +78,15 @@
all:: java_compile
+doc:
+ $(MAKE) -C docs/user html
+
+doc-install:
+ $(MAKE) -C docs/user html-install
+
+clean::
+ $(MAKE) -C docs/user clean
+
zlib:
cd $(ZLIB_DIR); $(MAKE) $(MAKE_ZLIB_ARG)
--- a/bc.mak Thu Jun 25 15:54:39 2015 +0100
+++ b/bc.mak Wed Jul 01 07:14:28 2015 +0100
@@ -70,6 +70,15 @@
ALL:: java_compile
+doc:
+ pushd docs\user & $(MAKE_BAT) html
+
+doc-install:
+ pushd docs\user & $(MAKE_BAT) html-install
+
+
+clean::
+ pushd docs\user & $(MAKE_BAT) clean
$(ZLIB):
cd $(ZLIB_DIR)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/user/Makefile Wed Jul 01 07:14:28 2015 +0100
@@ -0,0 +1,93 @@
+#!/usr/bin/make
+
+XSLTPROC = xsltproc
+LATEX = pdfcslatex
+
+# Defines root of DocBook-XSL style scheets
+DOCBOOK_XSL =
+
+SOURCE_DIR = .
+DOCUMENT = stx_libjava_user
+
+DOCUMENT_SOURCE = $(SOURCE_DIR)/$(DOCUMENT).xml
+DOCUMENT_SOURCES= $(SOURCE_DIR)/*.xml
+
+PROFILED_DOCUMENT_SOURCE = $(SOURCE_DIR)/$(DOCUMENT).xml.profiled
+
+PROFILE_STYLE=styles/profile.xsl
+
+OUTPUT_DIR=output
+
+HTML_DIR=$(OUTPUT_DIR)/html
+HTML_STYLE=styles/html.unix.xsl
+
+PDF_DIR=$(OUTPUT_DIR)/pdf
+PDF_STYLE=styles/latex.xsl
+
+# A directory where to install HTML help
+HELP_DIR=../../../doc/online/english/programming
+
+default: html
+
+html: $(HTML_DIR)/index.html $(HTML_DIR)/stx_libjava_user.css
+
+pdf: $(PDF_DIR)/$(DOCUMENT).pdf
+
+$(PROFILED_DOCUMENT_SOURCE): $(DOCUMENT_SOURCES) $(SCHEMAS) $(PROFILE_STYLE)
+ $(XSLTPROC) --xinclude -o $(PROFILED_DOCUMENT_SOURCE) \
+ $(PROFILE_STYLE) $(DOCUMENT_SOURCE)
+
+
+
+#---- HTML format --------------------------
+$(HTML_DIR):
+ mkdir -p $(HTML_DIR)
+
+$(HTML_DIR)/stx_libjava_user.css: $(HTML_DIR) styles/stx_libjava_user.css
+ mkdir -p $(HTML_DIR)
+ cp styles/stx_libjava_user.css $(HTML_DIR)/stx_libjava_user.css
+
+$(HTML_DIR)/index.html: $(HTML_DIR) $(PROFILED_DOCUMENT_SOURCE) $(HTML_STYLE) $(HTML_DIR)/stx_libjava_user.css $(HTML_DIR)/images
+ $(XSLTPROC) -o $(HTML_DIR)/ $(HTML_STYLE) $(PROFILED_DOCUMENT_SOURCE)
+
+$(HTML_DIR)/images: $(HTML_DIR)
+ mkdir -p $(HTML_DIR)/images
+ -cp -a images/* $(HTML_DIR)/images
+
+# Special target to install HTML documentation to
+html-install: html
+ mkdir -p $(HELP_DIR)
+ cp -ar $(HTML_DIR)/* $(HELP_DIR)
+
+#---- PDF format ---------------------------
+$(PDF_DIR):
+ mkdir -p $(PDF_DIR)
+
+$(PDF_DIR)/$(DOCUMENT).pdf: $(PDF_DIR) $(PDF_DIR)/$(DOCUMENT).tex
+ mkdir $(PDF_DIR) && \
+ cd $(PDF_DIR) && \
+ $(LATEX) $(DOCUMENT).tex && \
+ makeindex using-xmlsuite.idx && \
+ $(LATEX) $(DOCUMENT).tex && \
+ makeindex using-xmlsuite.idx && \
+ $(LATEX) $(DOCUMENT).tex
+
+$(PDF_DIR)/$(DOCUMENT).tex: $(PROFILED_DOCUMENT_SOURCE) $(PDF_STYLE)
+ $(XSLTPROC) -o $(PDF_DIR)/$(DOCUMENT).tex $(PDF_STYLE) $(PROFILED_DOCUMENT_SOURCE)
+
+
+#---- SUPPORT -----------------------------
+clean:
+ rm -rf $(HTML_DIR)
+ rm -rf $(PDF_DIR)
+ find ./ -name '*~' -exec rm {} \;
+ rm -f $(SOURCE_DIR)/*.xml.tmp
+ rm -f $(PROFILED_DOCUMENT_SOURCE)
+
+clobber: clean
+
+archive:
+ zip -r /tmp/$(DOCUMENT).zip ./*
+
+publish: html
+ scp -r $(HTML_DIR)/* fray1.fit.cvut.cz:/home/zam/vranyj1/www_users/data/tmp/libjava-doc
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/user/bc.mak Wed Jul 01 07:14:28 2015 +0100
@@ -0,0 +1,78 @@
+#!/usr/bin/make
+
+XSLTPROC = xsltproc
+LATEX = pdfcslatex
+
+# Defines root of DocBook-XSL style scheets
+DOCBOOK_XSL = C:\xsltproc\docbook-xsl-1.78.0
+
+
+SOURCE_DIR = .
+DOCUMENT = stx_libjava_user
+
+DOCUMENT_SOURCE = $(SOURCE_DIR)\$(DOCUMENT).xml
+DOCUMENT_SOURCES= $(SOURCE_DIR)\*.xml
+
+PROFILED_DOCUMENT_SOURCE = $(SOURCE_DIR)\$(DOCUMENT).xml.profiled
+
+PROFILE_STYLE=styles\profile.xsl
+
+OUTPUT_DIR=output
+
+HTML_DIR=$(OUTPUT_DIR)\html
+HTML_STYLE=styles\html.win32.xsl
+
+PDF_DIR=$(OUTPUT_DIR)\pdf
+PDF_STYLE=styles/latex.xsl
+
+# A directory where to install HTML help
+HELP_DIR=..\..\..\doc\online\english\programming
+
+default: html
+
+html: $(HTML_DIR)\index.html $(HTML_DIR)\stx_libjava_user.css
+
+pdf: $(PDF_DIR)\$(DOCUMENT).pdf
+
+$(PROFILED_DOCUMENT_SOURCE): $(DOCUMENT_SOURCES) $(SCHEMAS) $(PROFILE_STYLE)
+ $(XSLTPROC) --xinclude -o $(PROFILED_DOCUMENT_SOURCE) \
+ $(PROFILE_STYLE) $(DOCUMENT_SOURCE)
+
+
+$(OUTPUT_DIR)\nul:
+ mkdir $(OUTPUT_DIR)
+
+#---- HTML format --------------------------
+$(HTML_DIR)\nul: $(OUTPUT_DIR)\nul
+ mkdir $(HTML_DIR)
+
+$(HTML_DIR)\stx_libjava_user.css: $(HTML_DIR)\nul styles\stx_libjava_user.css
+ copy styles\stx_libjava_user.css $(HTML_DIR)\stx_libjava_user.css
+
+$(HTML_DIR)\index.html: $(HTML_DIR)\nul $(PROFILED_DOCUMENT_SOURCE) $(HTML_STYLE) $(HTML_DIR)\stx_libjava_user.css $(HTML_DIR)\images
+ $(XSLTPROC) -o $(HTML_DIR)/ $(HTML_STYLE) $(PROFILED_DOCUMENT_SOURCE)
+
+$(HTML_DIR)\images\nul: $(HTML_DIR)\nul
+ mkdir $(HTML_DIR)\images
+
+$(HTML_DIR)\images: $(HTML_DIR)\images\nul
+ xcopy /S /Q /Y images\*.* $(HTML_DIR)\images\
+
+# Special target to install HTML documentation to
+$(HELP_DIR)\nul:
+ mkdir $(HELP_DIR)
+
+html-install: html $(HELP_DIR)\nul
+ xcopy /S /Q /Y $(HTML_DIR)\*.* $(HELP_DIR)\
+
+
+#---- SUPPORT -----------------------------
+clean:
+ -rmdir /S /Q $(OUTPUT_DIR)
+ -del $(SOURCE_DIR)/*.tmp
+ -del $(PROFILED_DOCUMENT_SOURCE)
+
+clobber: clean
+
+archive:
+ zip -r /tmp/$(DOCUMENT).zip ./*
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/user/bmake.bat Wed Jul 01 07:14:28 2015 +0100
@@ -0,0 +1,12 @@
+@REM -------
+@REM make using Borland bcc32
+@REM type bmake, and wait...
+@REM do not edit - automatically generated from ProjectDefinition
+@REM -------
+@SET DEFINES=
+@REM Kludge got Mercurial, cannot be implemented in Borland make
+@FOR /F "tokens=*" %%i in ('hg root') do SET HGROOT=%%i
+@IF "%HGROOT%" NEQ "" SET DEFINES=%DEFINES% "-DHGROOT=%HGROOT%"
+make.exe -N -f bc.mak %DEFINES% %*
+
+
Binary file docs/user/images/browser-HelloWorld-1.png has changed
Binary file docs/user/images/stx_screenshot_016.png has changed
Binary file docs/user/images/stx_screenshot_017.png has changed
Binary file docs/user/images/stx_screenshot_018.png has changed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/user/stx_libjava_user.xml Wed Jul 01 07:14:28 2015 +0100
@@ -0,0 +1,553 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
+"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
+<article>
+ <chapterinfo>
+ <author>
+ <firstname>Jan</firstname>
+
+ <surname>Vraný</surname>
+
+ <email>jan.vrany[AT]fit.cvut.cz</email>
+ </author>
+ </chapterinfo>
+
+ <title>Java Support</title>
+
+ <subtitle>The Smalltalk/X Unified Virtual Machine</subtitle>
+
+ <?dbhtml filename="java.html"?>
+
+ <abstract>
+ <para>The Smalltalk/X virtual machine (runtime system) allows for Java
+ code to be executed within the Smalltalk environment. This integration is
+ virtually seamless - from a programmers point of view, there is no
+ difference between a Smalltalk object and a Java object. Java classes
+ inherit from Object - much like most other Smalltalk classes. This allows
+ for Java classes to be loaded into the system and used in the same way as
+ Smalltalk classes, giving Smalltalk/X user access to vast amount of Java
+ libraries.</para>
+ </abstract>
+
+ <section>
+ <title id="sec-instalation-and-configuration">Installation &
+ Configuration</title>
+
+ <?dbhtml filename="java-installation-and-configuration.html"?>
+
+ <para>TBW...</para>
+
+ <section>
+ <title>Loading Java support</title>
+
+ <para>STX:LIBJAVA is a part of Smalltalk/X. To load it into a
+ Smalltalk/X environment, execute following:</para>
+
+ <programlisting>Smalltalk loadPackage: #'stx:libjava'.
+Smalltalk loadPaclage: #'stx:libjava/tools'.</programlisting>
+ </section>
+
+ <section>
+ <title>Configuring Java</title>
+
+ <para/>
+ </section>
+
+ <section>
+ <title id="sec-inst_and_config-init">Initializing Java</title>
+
+ <para>Before any user Java code can be loaded and executed, the
+ STX:LIBJAVA has to be initialized. During the initialization, basic
+ classes are loaded and initialized - such as <ulink
+ url="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html">
+ <classname>java.lang.Object</classname>
+ </ulink>, <ulink
+ url="http://docs.oracle.com/javase/7/docs/api/java/lang/String.html">
+ <classname>java.lang.String</classname>
+ </ulink>. To initializa Java in running Smalltalk/X, execute:</para>
+
+ <programlisting>JavaVM boot.</programlisting>
+
+ <para>You may later shutdown or reboot Java by:</para>
+
+ <programlisting>JavaVM shutdown.
+JavaVM reboot.</programlisting>
+
+ <note>
+ <para>During shutdown, all pure-Java threads are uncoditionally
+ terminated and Java classes are unloaded. This may have funny
+ consequences, especially when a Smalltalk thread is actually executing
+ a Java code and it may be manifested in weird way. The shutdown is
+ here mainly for development purposes - in an application, you
+ shouldn't do a Java shutdown. If you do, result is undefined.</para>
+ </note>
+ </section>
+ </section>
+
+ <section id="sec-helloworld">
+ <title>Hello World!</title>
+
+ <?dbhtml filename="java-helloworld.html"?>
+
+ <subtitle>A quick tutorial for the impatient</subtitle>
+
+ <para>In this we'll provide a quick tour showing how to develop a simple
+ "Hello World!" application using Smalltalk/X and Java. You will need to
+ properly install following:</para>
+
+ <itemizedlist>
+ <listitem>
+ <para><ulink
+ url="https://swing.fit.cvut.cz/projects/stx-jv">Smalltalk/X
+ jv-branch</ulink>. Strictly speaking, this is not necessary and you
+ may use eXept's Smalltalk/X, however, at the time of writing this
+ document, <ulink
+ url="http://www.exept.de/en/products/smalltalk-x.html">eXept's
+ Smalltalk/X</ulink> does not come with up-to date STX:LIBJAVA,
+ Mercurial support and other tweaks.</para>
+ </listitem>
+
+ <listitem>
+ <para>JDK 6 or 7. We recommend using OpenJDK 7 on Linux and Zulu 7 on
+ Windows<footnote>
+ <para>
+ <ulink
+ url="http://www.azulsystems.com/products/zulu/downloads">http://www.azulsystems.com/products/zulu/downloads</ulink>
+ </para>
+ </footnote>.</para>
+ </listitem>
+
+ <listitem>
+ <para><ulink url="http://ant.apache.org/">Apache Ant</ulink>. An
+ Apache Ant is used to batch-compile Java sources.</para>
+ </listitem>
+
+ <listitem>
+ <para><ulink url="https://mercurial.selenic.com/">Mercurial</ulink>.
+ We'll use Mercurial as source code management for the "Hello World!"
+ project.</para>
+ </listitem>
+ </itemizedlist>
+
+ <section>
+ <title>Implementing the "Hello World!"</title>
+
+ <para>This simple application will consist of two classes:</para>
+
+ <itemizedlist>
+ <listitem>
+ <para>A Java class <code>
+ <classname>jv.demos.helloworld_1.core.HelloWorld</classname>
+ </code> that will actually print a greeting to standard output
+ (when run as standalone application from console) or to Transcript
+ (when executed within a Smalltalk/X IDE, i.e., from
+ workspace).</para>
+ </listitem>
+
+ <listitem>
+ <para>A Smalltalk class <code>
+ <classname>HelloWorldStartup</classname>
+ </code> that will serve as an entry point when application is run
+ standalone. This one will initialize STX:LIBJAVA (as it's not
+ initialized by default) and fire the Java code.</para>
+ </listitem>
+ </itemizedlist>
+
+ <para>We'll package both classes together into a single Smalltalk/X
+ package named <package>jv:demos/helloworld_1</package>.</para>
+
+ <para>Before we start, we have to initialize STX:LIBJAVA. For details,
+ refer to <xref linkend="sec-inst_and_config-init"/>, for now, just
+ execute in workspace:</para>
+
+ <programlisting>JavaVM boot.</programlisting>
+
+ <para>Once the STX:LIBJAVA is booted, create a Java class. In a class
+ browser, select <menuchoice>
+ <guimenuitem>Class</guimenuitem>
+
+ <guimenuitem>New</guimenuitem>
+
+ <guimenuitem>Java Class</guimenuitem>
+ </menuchoice>. In the browser's code pane, a template of Java class
+ definition appears. In our case, the new class's source code may look
+ like:</para>
+
+ <mediaobject>
+ <imageobject>
+ <imagedata fileref="images/browser-HelloWorld-1.png"/>
+ </imageobject>
+ </mediaobject>
+
+ <itemizedlist>
+ <listitem>
+ <para><emphasis>Line 1:</emphasis> A Java package to which the class
+ belongs. It's name could have any value, but we strongly recommend
+ to use a Smalltalk/X package name as prefix for Java package. It
+ makes the code easier to understand.</para>
+ </listitem>
+
+ <listitem>
+ <para><emphasis>Line 7</emphasis>: An annotation which actually
+ tells the Smalltalk/X IDE to which <emphasis>Smalltalk/X
+ package</emphasis> the class belongs to. WIthout this annotation,
+ Smalltalk/X IDE <emphasis>would not know</emphasis> so when later on
+ you commit the package from the browser, the Java class will not be
+ commited - which is not what you want!</para>
+ </listitem>
+ </itemizedlist>
+
+ <para>Once you accept the code, the Java class is compiled and loaded
+ into a running system. Now you should be able to use it from a
+ workspace. Open one and evaluate:</para>
+
+ <programlisting>helloworld := JAVA jv demos helloworld_1 core HelloWorld new.
+helloworld greet.
+</programlisting>
+
+ <mediaobject>
+ <imageobject>
+ <imagedata fileref="images/stx_screenshot_016.png"/>
+ </imageobject>
+ </mediaobject>
+
+ <para>The first line instantiates the <code>
+ <classname>HelloWorld</classname>
+ </code> class from Smalltalk. You may alternatively instantiate it as
+ follows:</para>
+
+ <programlisting><code>helloworld := (Java classForName:'jv. demos.helloworld_1.core.HelloWorld') new</code>.</programlisting>
+
+ <para>The second line invokes the <code>
+ <methodname>greet()</methodname>
+ </code> method. You may also invoke the <code>
+ <methodname>greet(String)</methodname>
+ </code> method as simply as:</para>
+
+ <programlisting><code>helloworld greet: 'Haya'</code>.</programlisting>
+
+ <para>Now let's define an application startup class:</para>
+
+ <programlisting>StandaloneStartup subclass:#HelloWorldStartup
+ instanceVariableNames:''
+ classVariableNames:''
+ poolDictionaries:''
+ category:'Hello World'</programlisting>
+
+ <para>And it's <code>
+ <methodname>#main:</methodname>
+ </code> method - this is the application entry point:</para>
+
+ <programlisting>main:argv
+ | helloworld |
+ JavaVM booted ifFalse:[
+ JavaVM boot.
+ ].
+ helloworld := JAVA jv demos helloworld_1 core HelloWorld new.
+ helloworld greet.
+ Smalltalk isStandAloneApp ifTrue:[
+ Smalltalk exit: 0
+ ].</programlisting>
+
+ <itemizedlist>
+ <listitem>
+ <para>First, the STX:LIBJAVA has to be initialized. We do it
+ conditionally only if it's not already. Strictly speaking, this is
+ not necessary as when a standalone application starts., STX:LIBJAVA
+ is not initialized, however, doing so allows to test the <code>
+ <methodname>#main:</methodname>
+ </code>method from running IDE.</para>
+ </listitem>
+
+ <listitem>
+ <para>Second, load the Java class <code>
+ <classname>jv.demos.helloworld_1.core.HelloWorld</classname>
+ </code>and invoke its <code>
+ <methodname>greet()</methodname>
+ </code>method.</para>
+ </listitem>
+
+ <listitem>
+ <para>Third, exit the application. We do it conditionally for the
+ very same reason - you don't want your Smalltalk IDE to terminate
+ when testing the <code>
+ <methodname>#main:</methodname>
+ </code>method.</para>
+ </listitem>
+ </itemizedlist>
+
+ <para>Don't forget to move class <code>
+ <classname>HelloWorldStartup</classname>
+ </code> to package <package>jv:demos/helloworld_1</package> (menu
+ <menuchoice>
+ <guimenuitem>Class</guimenuitem>
+
+ <guimenuitem>Move</guimenuitem>
+
+ <guimenuitem>To Package</guimenuitem>
+ </menuchoice>).</para>
+ </section>
+
+ <section>
+ <title>Commiting project</title>
+
+ <para>The initialal code has been developed so now it's time to commit
+ it to Mercurial repository. If you're not familiar with Mercurial under
+ Smalltalk/X, you may want to read <ulink
+ url="http://swing.fit.cvut.cz/projects/stx/doc/online/english/help/HG/">stx:libscm
+ User Guide</ulink>. In the following text, let's assume the Mercurial
+ repository for the package is located at
+ <filename>/home/user/SmalltalkXProjects/jv/demos/helloworld_1</filename>
+ (or <filename>C:\Users\user\SmalltalkXProjects\jv\demos\helloworld_1 on
+ Windows</filename>)</para>
+
+ <para>To commit the package, switch browser to package mode (menu
+ <menuchoice>
+ <guimenuitem>View</guimenuitem>
+
+ <guimenuitem>Package</guimenuitem>
+ </menuchoice>) and commit (menu <menuchoice>
+ <guimenuitem>Package</guimenuitem>
+
+ <guimenuitem>Mercurial+</guimenuitem>
+
+ <guimenuitem>Checkin...</guimenuitem>
+ </menuchoice>).</para>
+
+ <mediaobject>
+ <imageobject>
+ <imagedata fileref="images/stx_screenshot_017.png"/>
+ </imageobject>
+
+ <caption>
+ <para>Commiting package from Smalltalk/x class browser</para>
+ </caption>
+ </mediaobject>
+
+ <para>If the menu item <guimenuitem>Mercurial+</guimenuitem> does not
+ show the text "<guilabel>(default)</guilabel>" then something is wrong
+ with the Mercurial setup - check <ulink
+ url="http://swing.fit.cvut.cz/projects/stx/doc/online/english/help/HG/">stx:libscm
+ User Guide</ulink>.</para>
+
+ <para>Once the commit dialog appears, fill in the commit message and
+ click to <guibutton>Commit</guibutton> button.</para>
+
+ <mediaobject>
+ <imageobject>
+ <imagedata fileref="images/stx_screenshot_018.png"/>
+ </imageobject>
+
+ <caption>
+ <para>Commit dialog to commit a package</para>
+ </caption>
+ </mediaobject>
+
+ <para>Now the code has been commited to the repository. Let's check it
+ from command line: </para>
+
+ <programlisting>$ <command>cd /home/user/SmalltalkXProjects/jv/demos/helloworld_1</command>
+$ <command>hg log</command>
+<computeroutput>changeset: 0:2fc9b3286e10
+tag: tip
+user: Jan Vrany <jan.vrany@fit.cvut.cz>
+date: Sun Jun 14 08:14:54 2015 +0100
+summary: First shot on a cool "Hello World!" app
+</computeroutput>
+$
+</programlisting>
+ </section>
+
+ <section>
+ <title>Loading Hello World package</title>
+
+ <para>Before loading the package into freshly started Smalltalk/X IDE
+ you have to <emphasis>manually update</emphasis> Mercurial working copy
+ to desired revision. When a package is commited from Smalltalk/X, the
+ working copy in Smalltalk/X package path is not updated to the commited
+ revision<footnote>
+ <para>The main reason is that for binary-compiled classes the
+ sources are not loaded in the memory but loaded from the .st files
+ found in package path on demand. A method contains only offset into
+ this file. Of the file is changed the offset changes and therefore
+ the source shown in the browser will be wrong. To take safe side,
+ <ulink
+ url="https://bitbucket.org/janvrany/stx-libscm">stx:libscm</ulink>
+ (Mercurial) never updates the working copy. This may change in a
+ future.</para>
+ </footnote>. So you have to update the working copy by hand:</para>
+
+ <para><programlisting>$ <command>cd /home/user/SmalltalkXProjects/jv/demos/helloworld_1</command>
+$ <command>hg up</command>
+<computeroutput>17 files updated, 0 files merged, 0 files removed, 0 files unresolved</computeroutput>
+$
+</programlisting>Now the working copy should be updated to just-commited
+ revision. To load the package back into freshly started Smalltalk/X IDE,
+ load the package as usual: </para>
+
+ <programlisting>Smalltalk loadPackage: 'jv:demos/helloworld_1'.</programlisting>
+
+ <para>If there's no error while loading (there should not be), you may
+ want to try whether it works as expected. Evaluate:</para>
+
+ <programlisting>HelloWorldStartup main
+</programlisting>
+
+ <para>You should see text "Hello world!" in Transcript window. You
+ should be able to see <code>
+ <classname>jv.demos.helloworld_1.core.HelloWorld</classname>
+ </code> class in a system browser window. Now you can change classes
+ further and once done with it, commit and load it back using the same
+ process. </para>
+ </section>
+
+ <section>
+ <title>Topics not covered</title>
+
+ <itemizedlist>
+ <listitem>
+ <para><emphasis>Adding Java libraries (.jar) into a Smalltalk
+ package</emphasis>. In short, you have to create
+ <filename>ivy.xml</filename> file for the <ulink
+ url="http://ant.apache.org/ivy/"> Apache Ivy</ulink>dependency
+ manager. You may take a file from STX:LIBJAVA and modify it to fit
+ your needs: <ulink
+ url="https://bitbucket.org/janvrany/stx-libjava/src/tip/libs/java/ivy.xml?at=default">https://bitbucket.org/janvrany/stx-libjava/src/tip/libs/java/ivy.xml?at=default</ulink></para>
+ </listitem>
+
+ <listitem>
+ <para><emphasis>Packaging Smalltalk/X application with Java
+ code</emphasis>. The RuntimePackager has not yet been fixed to
+ support Java code. </para>
+ </listitem>
+ </itemizedlist>
+ </section>
+ </section>
+
+ <section id="sec-programming">
+ <title>Programming with Java</title>
+
+ <?dbhtml filename="java-programming.html"?>
+
+ <section>
+ <title>Structure of the mixed Smalltalk/Java package</title>
+
+ <para>Within Smalltalk/X package all Java code lives in subdirectory
+ named <filename>
+ <filename>java</filename>
+ </filename>, which itself contains various directories and
+ files.</para>
+
+ <itemizedlist>
+ <listitem>
+ <para><filename>build.xml</filename> - this is an Ant build file
+ used to compile Java code when building the application. This file
+ is never overwritten by any of the STX:LIBJAVA tools and thus can be
+ edited freely by hand. You may put all customization there. You
+ should import <filename>build.auto.xml</filename> into
+ <filename>build.xml</filename> to include all (generated)
+ dependencies and common targets.</para>
+ </listitem>
+
+ <listitem>
+ <para><filename>build.auto.xml</filename> - this is a fragment of an
+ Ant build file that is automatically generated (and overwritten)
+ upon commit from Smalltalk/X and should not be edited by hand
+ (changes will be lost after next commit). This file contains
+ generated dependencies and includes common targets (defined in
+ <filename>stx/libjava/build.common.xml</filename>)</para>
+ </listitem>
+
+ <listitem>
+ <para><filename>ivy.xml</filename> - this file may contain
+ dependency definitions for <ulink
+ url="http://ant.apache.org/ivy/">Apache Ivy</ulink> dependency
+ manager. This is the prefered way to manage dependencies on
+ third-party Java libraries.</para>
+ </listitem>
+
+ <listitem>
+ <para><filename>src</filename> - this directory contains Java source
+ files in directory structure as required by Java.</para>
+ </listitem>
+
+ <listitem>
+ <para><filename>libs</filename> - this directory contains all Java
+ libraries (as .jar files) required by that package. Except of
+ special cases, .jar files are not (should not) be commited in the
+ repository but rather managed by <ulink
+ url="http://ant.apache.org/ivy/">Apache Ivy</ulink> dependency
+ manager.</para>
+ </listitem>
+
+ <listitem>
+ <para><filename>libs-src</filename> - this directory may contain
+ source .jars for libraries in <filename>libs</filename> directory.
+ As for <filename>libs</filename>, sources are not (should not) be
+ commited in the respository but rather managed by Ivy.</para>
+ </listitem>
+ </itemizedlist>
+ </section>
+ </section>
+
+ <section>
+ <title>Tools</title>
+
+ <?dbhtml filename="java-tools.html"?>
+
+ <para>To be written...</para>
+ </section>
+
+ <section>
+ <title>Legal Info</title>
+
+ <?dbhtml filename="java-legal.html"?>
+
+ <formalpara>
+ <title>Copyright</title>
+
+ <para/>
+ </formalpara>
+
+ <programlisting>COPYRIGHT (c) 1996-2015 by Claus Gittinger
+
+New code and modifications done at SWING Research Group [1]:
+
+COPYRIGHT (c) 2010-2015 by Jan Vrany, Jan Kurs, Marcel Hlopko
+COPYRIGHT (c) 2014-2015 by Tomas Heger.
+
+ SWING Research Group, Czech Technical University in Prague
+
+ This software is furnished under a license and may be used
+ only in accordance with the terms of that license and with the
+ inclusion of the above copyright notice. This software may not
+ be provided or otherwise made available to, or used by, any
+ other person. No title to or ownership of the software is
+ hereby transferred.
+
+ [1] Code written at SWING Research Group contains a signature
+ of one of the above copright owners. For exact set of such code,
+ see the differences between this version and version stx:libjava
+ as of 1.9.2010</programlisting>
+
+ <formalpara>
+ <title>Restricted Use</title>
+
+ <para>As we provide these classes for no additional charge, we request
+ that any changes/modifications & enhancements made to them be
+ returned to us (in source), to be reintegrated into future versions.
+ This code is NOT public domain code, but provided for free with the
+ Smalltalk/X system. You are not allowed to sell this code or any
+ application built around this code unless special agreements are set up.
+ However, you are allowed to use this tool for your own
+ applications.</para>
+ </formalpara>
+
+ <formalpara>
+ <title>No Warranty</title>
+
+ <para>Java support is provided AS-IS without any warranty
+ whatsoever.</para>
+ </formalpara>
+ </section>
+</article>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/user/styles/fo.xsl Wed Jul 01 07:14:28 2015 +0100
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="ISO-8859-2" ?>
+<xsl:stylesheet
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:fo="http://www.w3.org/1999/XSL/Format"
+ xmlns:fox="http://xml.apache.org/fop/extensions"
+ version="1.0">
+ <xsl:import href="/usr/share/xml/docbook/stylesheet/nwalsh/fo/docbook.xsl"/>
+
+ <xsl:variable name="generate.toc">1</xsl:variable>
+
+ <xsl:output method="xml"
+ indent="yes"
+ encoding="UTF-8" />
+
+</xsl:stylesheet>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/user/styles/html.unix.xsl Wed Jul 01 07:14:28 2015 +0100
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="ISO-8859-2" ?>
+<xsl:stylesheet
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns="http://www.w3.org/1999/xhtml"
+ version="1.0">
+ <xsl:import href="/usr/share/xml/docbook/stylesheet/docbook-xsl/xhtml/chunk.xsl"/>
+ <xsl:import href="html.xsl" />
+
+</xsl:stylesheet>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/user/styles/html.win32.xsl Wed Jul 01 07:14:28 2015 +0100
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="ISO-8859-2" ?>
+<xsl:stylesheet
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns="http://www.w3.org/1999/xhtml"
+ version="1.0">
+ <xsl:import href="C:/xsltproc/docbook-xsl-1.78.0/xhtml/chunk.xsl"/>
+ <xsl:import href="html.xsl" />
+
+</xsl:stylesheet>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/user/styles/html.xsl Wed Jul 01 07:14:28 2015 +0100
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="ISO-8859-2" ?>
+<xsl:stylesheet
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns="http://www.w3.org/1999/xhtml"
+ version="1.0">
+ <xsl:variable name="lang-attr">en</xsl:variable>
+ <xsl:variable name="output.method">xml</xsl:variable>
+ <xsl:variable name="html.stylesheet">stx_libjava_user.css</xsl:variable>
+ <xsl:variable name="table.borders.with.css" select="1"/>
+ <xsl:variable name="html.ext" select="'.html'"/>
+ <xsl:variable name="html.cellpadding" select="'5'" />
+ <xsl:variable name="section.autolabel" select="1" />
+ <xsl:output method="xml"
+ indent="yes"
+ encoding="UTF-8" />
+
+</xsl:stylesheet>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/user/styles/latex.xsl Wed Jul 01 07:14:28 2015 +0100
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="ISO-8859-2" ?>
+<xsl:stylesheet
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:fo="http://www.w3.org/1999/XSL/Format"
+ xmlns:fox="http://xml.apache.org/fop/extensions"
+ version="1.0">
+
+ <xsl:import href="/usr/share/xml/docbook/stylesheet/db2latex/latex/docbook.xsl"/>
+
+ <xsl:param name="latex.documentclass.article">a4paper,10pt</xsl:param>
+ <xsl:param name="latex.use.babel">0</xsl:param>
+ <xsl:param name="toc.section.depth">4</xsl:param>
+ <xsl:param name="latex.article.preamble.pre">\usepackage{makeidx}
+ </xsl:param>
+ <xsl:param name="latex.article.preamble.post">\makeindex
+ </xsl:param>
+
+
+
+ <xsl:template match="biblioentry" mode="xref-to">
+ <xsl:param name="referrer"/>
+ <xsl:param name="xrefstyle"/>
+ <xsl:text>[</xsl:text>
+ <xsl:value-of select="$referrer/@linkend"/>
+ <xsl:text>]</xsl:text>
+ </xsl:template>
+
+
+ <xsl:template match="article/artheader|article/articleinfo" mode="standalone.article">
+ <xsl:apply-templates select="keywordset" />
+ <xsl:apply-templates select="legalnotice" />
+ <xsl:apply-templates select="abstract"/>
+ <xsl:call-template name="toc" />
+ </xsl:template>
+
+
+ <xsl:template match="indexterm">
+ <xsl:text>\index{</xsl:text>
+ <xsl:value-of select="./primary" />
+ <xsl:if test="./secondary">
+ <xsl:text>!</xsl:text>
+ <xsl:value-of select="./secondary" />
+ <xsl:if test="./tertiary">
+ <xsl:text>!</xsl:text>
+ <xsl:value-of select="./tertiary" />
+ </xsl:if>
+ </xsl:if>
+
+ <xsl:text>}</xsl:text>
+
+ </xsl:template>
+
+ <xsl:template match="index">
+ <xsl:text>
+ %\printindex
+ </xsl:text>
+ </xsl:template>
+
+
+</xsl:stylesheet>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/user/styles/profile.xsl Wed Jul 01 07:14:28 2015 +0100
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="iso-8859-2"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ version="1.0">
+
+<!-- Zkopírování celého dokumentu -->
+<xsl:template match="node()|@*">
+ <xsl:copy>
+ <xsl:apply-templates select="node()|@*"/>
+ </xsl:copy>
+</xsl:template>
+
+<xsl:template match="classname">
+ <!-- Zkopírování pùvodního elementu -->
+ <xsl:copy-of select="."/>
+ <!-- Vytvoøení rejstøíkového hesla -->
+ <indexterm>
+ <primary>class</primary>
+ <secondary><xsl:value-of select="."/></secondary>
+ </indexterm>
+</xsl:template>
+
+<xsl:template match="methodname">
+<!-- Zkopírování pùvodního elementu -->
+ <xsl:copy-of select="."/>
+ <!-- Vytvoøení rejstøíkového hesla -->
+ <indexterm>
+ <primary>method</primary>
+ <secondary><xsl:value-of select="."/></secondary>
+ </indexterm>
+</xsl:template>
+
+<xsl:template match="varname">
+<!-- Zkopírování pùvodního elementu -->
+ <xsl:copy-of select="."/>
+ <!-- Vytvoøení rejstøíkového hesla -->
+ <indexterm>
+ <primary>variable</primary>
+ <secondary><xsl:value-of select="."/></secondary>
+ </indexterm>
+</xsl:template>
+
+
+
+<xsl:template match="filename">
+<!-- Zkopírování pùvodního elementu -->
+ <xsl:copy-of select="."/>
+ <!-- Vytvoøení rejstøíkového hesla -->
+ <indexterm>
+ <primary>file</primary>
+ <secondary><xsl:value-of select="."/></secondary>
+ </indexterm>
+</xsl:template>
+
+
+
+
+<!-- Ka¾dé jméno souboru se také pøidá do rejstøíku -->
+<xsl:template match="filename">
+ <!-- Zkopírování pùvodního elementu -->
+ <xsl:copy-of select="."/>
+ <!-- Vytvoøení rejstøíkového hesla -->
+ <indexterm>
+ <primary><xsl:value-of select="."/></primary>
+ </indexterm>
+</xsl:template>
+
+</xsl:stylesheet>
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/user/styles/stx_libjava_user.css Wed Jul 01 07:14:28 2015 +0100
@@ -0,0 +1,138 @@
+body {
+ margin: 1cm 1cm 1cm 1cm;
+ font-family: sans-serif;
+ font-weight: normal;
+ color: black;
+ background: white;
+}
+
+ul,li {
+ margin-left: 2em;
+ margin-right: 2em;
+}
+
+ul p {
+ margin-left: 0em;
+ margin-right: 0em;
+}
+
+
+p {
+ text-indent: 0em;
+ text-align: justify;
+ margin-left: 2em;
+ margin-right: 2em;
+ margin-top: 1em;
+ margin-bottom: 1em;
+}
+
+div.simplesect {
+ margin-left: 2em;
+ margin-right: 2em;
+ margin-top: 1em;
+ margin-bottom: 1em;
+
+}
+
+table {
+ margin-left: 2em;
+ margin-right: 2em;
+}
+
+thead th {
+ background: silver;
+}
+
+/*
+tbody td {
+ background: #cccccc;
+}
+*/
+
+div.simplesect p {
+ margin-left: 0em;
+ margin-right: 0em;
+}
+
+
+
+pre {
+ margin-left: 1cm;
+ margin-right: 1cm;
+ margin-top: 1em;
+ margin-bottom: 1em;
+}
+
+
+
+pre.programlisting {
+ margin-left: 1cm;
+ margin-right: 1cm;
+ margin-top: 1em;
+ margin-bottom: 1em;
+ text-align: left;
+ font-size: 120%;
+ padding: 10px;
+
+ background: silver;
+ color: black;
+ border: 2px solid black;
+
+ }
+
+.abstract {
+ font-style: italic;
+}
+
+.prompt, .computeroutput {
+ color: black;
+}
+
+
+tt, .command {
+ font-family: monospace;
+}
+
+.figure {
+ text-align: center;
+ margin: 1cm auto 1cm auto;
+}
+
+.title {
+ color: maroon;
+}
+
+.methodname {
+ color: olive;
+ font-size: 120%;
+ }
+.classname {
+ color: olive;
+ font-weight: bold;
+ font-size: 120%;
+ }
+
+.varname {
+ color: olive;
+ }
+
+
+img { border-width: 0em }
+
+.sgmltag-element { font-weight: bold; }
+
+
+/* GENERIC LINK */
+
+a {
+ color: #588bef;
+ font-weight: normal;
+ text-decoration: none;
+ }
+
+a:hover { /* color: #1060ea; */
+ color: red;
+ font-weight: normal;
+ text-decoration: underline;
+ }
+
--- a/extensions.st Thu Jun 25 15:54:39 2015 +0100
+++ b/extensions.st Wed Jul 01 07:14:28 2015 +0100
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
"{ Package: 'stx:libjava' }"!
!Behavior methodsFor:'queries'!
@@ -1676,6 +1678,39 @@
"Created: / 19-01-2015 / 07:37:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+!ProjectDefinition class methodsFor:'description - actions - java'!
+
+postLoadJavaHook
+ "Package post-load hook for Jav packages. When a package
+ is loaded from sources (as opposite for binary-compiled by
+ stc), it also compiles all Java code (if any)."
+
+ <postLoad>
+
+ | javaDir |
+
+ "/ Do nothing if package is binary-compiled.
+ "/ The byteCode isNil test is a clumsy way to check whether the
+ "/ package has been binary-compiled or not.
+ (self class methodDictionary at:#classNamesAndAttributes) byteCode isNil ifTrue:[ ^ self ].
+
+ "/ Do nothing if package has no Java code...
+ self javaBundle isNil ifTrue:[ ^ self ].
+
+ javaDir := self packageDirectory / 'java'.
+ ((javaDir / 'build.xml') exists and:[ OperatingSystem canExecuteCommand: 'ant']) ifTrue:[
+ | topDir antCmd |
+
+ topDir := (Smalltalk getPackageDirectoryForPackage: #'stx:libbasic') directory.
+ antCmd := 'ant -DTOP=', topDir pathName.
+ (OperatingSystem executeCommand: antCmd inDirectory: javaDir pathName) ifFalse:[
+ self error: 'Failed to compile Java classes'.
+ ].
+ ].
+
+ "Created: / 15-06-2015 / 11:31:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
!Semaphore methodsFor:'waiting'!
parkWithTimeoutMs:milliSeconds
--- a/stx_libjava.st Thu Jun 25 15:54:39 2015 +0100
+++ b/stx_libjava.st Wed Jul 01 07:14:28 2015 +0100
@@ -192,6 +192,17 @@
additionalRules_bc_dot_mak
^ '
+doc:
+ pushd docs\user & $(MAKE_BAT) html
+
+doc-install:
+ pushd docs\user & $(MAKE_BAT) html-install
+
+
+clean::
+ pushd docs\user & $(MAKE_BAT) clean
+
+
$(ZLIB):
cd $(ZLIB_DIR)
$(MAKE) $(MAKE_ZLIB_ARG) $(ZLIB)
@@ -214,6 +225,16 @@
additionalRules_make_dot_proto
^ '
+doc:
+ $(MAKE) -C docs/user html
+
+doc-install:
+ $(MAKE) -C docs/user html-install
+
+clean::
+ $(MAKE) -C docs/user clean
+
+
zlib:
cd $(ZLIB_DIR); $(MAKE) $(MAKE_ZLIB_ARG)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/java/src/stx/libjava/tests/vm/ANEWARRAY.java Wed Jul 01 07:14:28 2015 +0100
@@ -0,0 +1,65 @@
+package stx.libjava.tests.vm;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+public class ANEWARRAY {
+
+ @Test
+ public void test_bounds_01() {
+ Object[] arr;
+ Object o;
+ arr = new Object[10];
+
+ try {
+ o = arr[-1];
+ fail();
+ } catch (ArrayIndexOutOfBoundsException abe) {
+ // OK
+ } catch (Exception e) {
+ fail();
+ }
+
+ arr = new Object[10];
+ try {
+ arr[-1] = new Object();
+ fail();
+ } catch (ArrayIndexOutOfBoundsException abe) {
+ // OK
+ } catch (Exception e) {
+ fail();
+ }
+
+ try {
+ o = arr[11];
+ fail();
+ } catch (ArrayIndexOutOfBoundsException abe) {
+ // OK
+ } catch (Exception e) {
+ fail();
+ }
+
+ arr = new Object[10];
+ try {
+ arr[11] = new Object();
+ fail();
+ } catch (ArrayIndexOutOfBoundsException abe) {
+ // OK
+ } catch (Exception e) {
+ fail();
+ }
+ }
+
+ @Test
+ public void test_negative_size_01() {
+ Object[] arr;
+ try {
+ arr = new Object[-1];
+ } catch (NegativeArraySizeException nase) {
+ // OK
+ } catch (Exception e) {
+ fail();
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/java/src/stx/libjava/tests/vm/ARRAYLENGTH.java Wed Jul 01 07:14:28 2015 +0100
@@ -0,0 +1,36 @@
+package stx.libjava.tests.vm;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+public class ARRAYLENGTH {
+
+ @Test
+ public void test() {
+ int l;
+ int[] i_arr = null;
+
+ try {
+ l = i_arr.length;
+ fail();
+ } catch (NullPointerException npe) {
+ // OK
+ } catch (Exception e) {
+ fail();
+ }
+
+ byte[] b_arr = null;
+
+ try {
+ l = b_arr.length;
+ fail();
+ } catch (NullPointerException npe) {
+ // OK
+ } catch (Exception e) {
+ fail();
+ }
+
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/java/src/stx/libjava/tests/vm/IADD_and_ISUB_and_IMUL_and_IDIV.java Wed Jul 01 07:14:28 2015 +0100
@@ -0,0 +1,93 @@
+package stx.libjava.tests.vm;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+public class IADD_and_ISUB_and_IMUL_and_IDIV {
+ public static int INT31_MAX_VAL = 1073741823; // SmallInteger maxVal on 32bit arch
+ public static int INT31_MIN_VAL = -1073741824; // SmallInteger minVal on 32bit arch
+ public static int INT32_MAX_VAL = Integer.MAX_VALUE;
+ public static int INT32_MIN_VAL = Integer.MIN_VALUE;
+
+ @Test
+ public void test_IADD() {
+ int i1, i2, r;
+
+ // Use variables to trick the compiler (and inhibit constant folding)
+ i1 = INT31_MAX_VAL;
+ i2 = 1;
+ r = i1 + i2;
+ assertEquals(1073741824, r);
+
+
+ i1 = INT32_MAX_VAL;
+ i2 = 1;
+ r = i1 + i2;
+ assertEquals(INT32_MIN_VAL, r);
+ }
+
+ @Test
+ public void test_ISUB() {
+ int i1, i2, r;
+
+ // Use variables to trick the compiler (and inhibit constant folding)
+ i1 = INT31_MIN_VAL;
+ i2 = 1;
+ r = i1 - i2;
+ assertEquals(-1073741825, r);
+
+
+ i1 = INT32_MIN_VAL;
+ i2 = 1;
+ r = i1 - i2;
+ assertEquals(INT32_MAX_VAL, r);
+ }
+
+ @Test
+ public void test_IMUL() {
+ int i1, i2, r;
+
+ // Use variables to trick the compiler (and inhibit constant folding)
+ i1 = INT31_MAX_VAL;
+ i2 = 2;
+ r = i1 * i2;
+ assertEquals(INT32_MAX_VAL - 1, r);
+
+ i1 = INT32_MIN_VAL;
+ i2 = 2;
+ r = i1 * i2;
+ assertEquals(0, r);
+ }
+
+ @Test
+ public void test_IDIV() {
+ int i1, i2, r;
+
+ // Use variables to trick the compiler (and inhibit constant folding)
+ i1 = INT32_MIN_VAL;
+ i2 = -1 ;
+ r = i1 / i2;
+ assertEquals(INT32_MIN_VAL, r);
+
+ i1 = INT32_MAX_VAL;
+ i2 = -1 ;
+ r = i1 / i2;
+ assertEquals(INT32_MIN_VAL + 1, r);
+
+
+ i1 = INT32_MIN_VAL;
+ i2 = 0;
+ try {
+ r = i1 / i2;
+ assertTrue("Failed to throw ArithmeticException", false);
+ } catch (ArithmeticException ai) {
+ // OK
+ } catch (Exception e) {
+ assertTrue("Failed to throw ArithmeticException", false);
+ }
+
+ }
+
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/java/src/stx/libjava/tests/vm/LADD_and_LSUB_and_LMUL_and_LDIV.java Wed Jul 01 07:14:28 2015 +0100
@@ -0,0 +1,168 @@
+package stx.libjava.tests.vm;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+public class LADD_and_LSUB_and_LMUL_and_LDIV {
+ public static long INT31_MAX_VAL = 1073741823; // SmallInteger maxVal on 32bit arch
+ public static long INT31_MIN_VAL = -1073741824; // SmallInteger minVal on 32bit arch
+ public static long INT32_MAX_VAL = Integer.MAX_VALUE;
+ public static long INT32_MIN_VAL = Integer.MIN_VALUE;
+
+ public static long INT63_MAX_VAL = 4611686018427387903L; // SmallInteger maxVal on 32bit arch
+ public static long INT63_MIN_VAL = -4611686018427387904L; // SmallInteger minVal on 32bit arch
+ public static long INT64_MAX_VAL = Long.MAX_VALUE;
+ public static long INT64_MIN_VAL = Long.MIN_VALUE;
+
+
+ @Test
+ public void test_LADD() {
+ long i1, i2, r;
+
+ // Use variables to trick the compiler (and inhibit constant folding)
+ i1 = INT31_MAX_VAL;
+ i2 = 1;
+ r = i1 + i2;
+ assertEquals(1073741824, r);
+
+
+ i1 = INT32_MAX_VAL;
+ i2 = 1;
+ r = i1 + i2;
+ assertEquals(2147483648L, r);
+
+ i1 = INT63_MAX_VAL;
+ i2 = 1;
+ r = i1 + i2;
+ assertEquals(4611686018427387904L, r);
+
+
+ i1 = INT64_MAX_VAL;
+ i2 = 1;
+ r = i1 + i2;
+ assertEquals(INT64_MIN_VAL, r);
+
+ }
+
+ @Test
+ public void test_LSUB() {
+ long i1, i2, r;
+
+ // Use variables to trick the compiler (and inhibit constant folding)
+ i1 = INT31_MIN_VAL;
+ i2 = 1;
+ r = i1 - i2;
+ assertEquals(-1073741825, r);
+
+
+ i1 = INT32_MIN_VAL;
+ i2 = 1;
+ r = i1 - i2;
+ assertEquals(-2147483649L, r);
+
+ i1 = INT63_MIN_VAL;
+ i2 = 1;
+ r = i1 - i2;
+ assertEquals(-4611686018427387905L, r);
+
+
+ i1 = INT64_MIN_VAL;
+ i2 = 1;
+ r = i1 - i2;
+ assertEquals(INT64_MAX_VAL, r);
+
+ }
+
+ @Test
+ public void test_LMUL() {
+ long i1, i2, r;
+
+ // Use variables to trick the compiler (and inhibit constant folding)
+ i1 = INT31_MAX_VAL;
+ i2 = 2;
+ r = i1 * i2;
+ assertEquals(INT32_MAX_VAL - 1, r);
+
+ i1 = INT32_MIN_VAL;
+ i2 = 2;
+ r = i1 * i2;
+ assertEquals(-4294967296L, r);
+
+ i1 = INT63_MAX_VAL;
+ i2 = 2;
+ r = i1 * i2;
+ assertEquals(INT64_MAX_VAL - 1, r);
+
+ i1 = INT64_MIN_VAL;
+ i2 = 2;
+ r = i1 * i2;
+ assertEquals(0, r);
+ }
+
+ @Test
+ public void test_regression_01() {
+ long a = 1517774901;
+ long b = 234233353;
+
+ long p = a * b;
+
+ assertEquals(355513504160473053L, p);
+
+
+ }
+
+ @Test
+ public void test_LDIV() {
+ long i1, i2, r;
+
+ // Use variables to trick the compiler (and inhibit constant folding)
+ i1 = INT32_MIN_VAL;
+ i2 = -1 ;
+ r = i1 / i2;
+ assertEquals(2147483648L, r);
+
+ i1 = INT32_MAX_VAL;
+ i2 = -1 ;
+ r = i1 / i2;
+ assertEquals(INT32_MIN_VAL + 1, r);
+
+
+ i1 = INT32_MIN_VAL;
+ i2 = 0;
+ try {
+ r = i1 / i2;
+ assertTrue("Failed to throw ArithmeticException", false);
+ } catch (ArithmeticException ai) {
+ // OK
+ } catch (Exception e) {
+ assertTrue("Failed to throw ArithmeticException", false);
+ }
+
+ i1 = INT64_MIN_VAL;
+ i2 = -1 ;
+ r = i1 / i2;
+ assertEquals(INT64_MIN_VAL, r);
+
+ i1 = INT64_MAX_VAL;
+ i2 = -1 ;
+ r = i1 / i2;
+ assertEquals(INT64_MIN_VAL + 1, r);
+
+
+ i1 = INT64_MIN_VAL;
+ i2 = 0;
+ try {
+ r = i1 / i2;
+ assertTrue("Failed to throw ArithmeticException", false);
+ } catch (ArithmeticException ai) {
+ // OK
+ } catch (Exception e) {
+ assertTrue("Failed to throw ArithmeticException", false);
+ }
+
+
+ }
+
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/java/src/stx/libjava/tests/vm/LAND_and_LOR_and_LXOR.java Wed Jul 01 07:14:28 2015 +0100
@@ -0,0 +1,19 @@
+package stx.libjava.tests.vm;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+public class LAND_and_LOR_and_LXOR {
+ final static long LONG_MASK = 0xffffffffL;
+
+ @Test
+ public void test_regression_01() {
+ int dl = 1517774901;
+ assertEquals(1517774901, dl & LONG_MASK);
+
+ int qhat = 234233353;
+ assertEquals(234233353, qhat & LONG_MASK);
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/java/src/stx/libjava/tests/vm/NEWARRAY.java Wed Jul 01 07:14:28 2015 +0100
@@ -0,0 +1,472 @@
+package stx.libjava.tests.vm;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+public class NEWARRAY {
+
+ @Test
+ public void test_bounds_boolean() {
+ boolean[] arr;
+ boolean o;
+ arr = new boolean[10];
+
+ try {
+ o = arr[-1];
+ fail();
+ } catch (ArrayIndexOutOfBoundsException abe) {
+ // OK
+ } catch (Exception e) {
+ fail();
+ }
+
+ arr = new boolean[10];
+ try {
+ arr[-1] = false;
+ fail();
+ } catch (ArrayIndexOutOfBoundsException abe) {
+ // OK
+ } catch (Exception e) {
+ fail();
+ }
+
+ try {
+ o = arr[11];
+ fail();
+ } catch (ArrayIndexOutOfBoundsException abe) {
+ // OK
+ } catch (Exception e) {
+ fail();
+ }
+
+ arr = new boolean[10];
+ try {
+ arr[11] = false;
+ fail();
+ } catch (ArrayIndexOutOfBoundsException abe) {
+ // OK
+ } catch (Exception e) {
+ fail();
+ }
+ }
+
+ @Test
+ public void test_negative_size_boolean() {
+ boolean[] arr;
+ try {
+ arr = new boolean[-1];
+ } catch (NegativeArraySizeException nase) {
+ // OK
+ } catch (Exception e) {
+ fail();
+ }
+ }
+
+
+ // === char ====
+ @Test
+ public void test_bounds_char() {
+ char[] arr;
+ char o;
+ arr = new char[10];
+
+ try {
+ o = arr[-1];
+ fail();
+ } catch (ArrayIndexOutOfBoundsException abe) {
+ // OK
+ } catch (Exception e) {
+ fail();
+ }
+
+ arr = new char[10];
+ try {
+ arr[-1] = '0';
+ fail();
+ } catch (ArrayIndexOutOfBoundsException abe) {
+ // OK
+ } catch (Exception e) {
+ fail();
+ }
+
+ try {
+ o = arr[11];
+ fail();
+ } catch (ArrayIndexOutOfBoundsException abe) {
+ // OK
+ } catch (Exception e) {
+ fail();
+ }
+
+ arr = new char[10];
+ try {
+ arr[11] = '0';
+ fail();
+ } catch (ArrayIndexOutOfBoundsException abe) {
+ // OK
+ } catch (Exception e) {
+ fail();
+ }
+ }
+
+ @Test
+ public void test_negative_size_char() {
+ char[] arr;
+ try {
+ arr = new char[-1];
+ } catch (NegativeArraySizeException nase) {
+ // OK
+ } catch (Exception e) {
+ fail();
+ }
+ }
+
+ // === byte ====
+ @Test
+ public void test_bounds_byte() {
+ byte[] arr;
+ byte o;
+ arr = new byte[10];
+
+ try {
+ o = arr[-1];
+ fail();
+ } catch (ArrayIndexOutOfBoundsException abe) {
+ // OK
+ } catch (Exception e) {
+ fail();
+ }
+
+ arr = new byte[10];
+ try {
+ arr[-1] = 0;
+ fail();
+ } catch (ArrayIndexOutOfBoundsException abe) {
+ // OK
+ } catch (Exception e) {
+ fail();
+ }
+
+ try {
+ o = arr[11];
+ fail();
+ } catch (ArrayIndexOutOfBoundsException abe) {
+ // OK
+ } catch (Exception e) {
+ fail();
+ }
+
+ arr = new byte[10];
+ try {
+ arr[11] = 0;
+ fail();
+ } catch (ArrayIndexOutOfBoundsException abe) {
+ // OK
+ } catch (Exception e) {
+ fail();
+ }
+ }
+
+ @Test
+ public void test_negative_size_byte() {
+ byte[] arr;
+ try {
+ arr = new byte[-1];
+ } catch (NegativeArraySizeException nase) {
+ // OK
+ } catch (Exception e) {
+ fail();
+ }
+ }
+
+ // === short ====
+ @Test
+ public void test_bounds_short() {
+ short[] arr;
+ short o;
+ arr = new short[10];
+
+ try {
+ o = arr[-1];
+ fail();
+ } catch (ArrayIndexOutOfBoundsException abe) {
+ // OK
+ } catch (Exception e) {
+ fail();
+ }
+
+ arr = new short[10];
+ try {
+ arr[-1] = 0;
+ fail();
+ } catch (ArrayIndexOutOfBoundsException abe) {
+ // OK
+ } catch (Exception e) {
+ fail();
+ }
+
+ try {
+ o = arr[11];
+ fail();
+ } catch (ArrayIndexOutOfBoundsException abe) {
+ // OK
+ } catch (Exception e) {
+ fail();
+ }
+
+ arr = new short[10];
+ try {
+ arr[11] = 0;
+ fail();
+ } catch (ArrayIndexOutOfBoundsException abe) {
+ // OK
+ } catch (Exception e) {
+ fail();
+ }
+ }
+
+ @Test
+ public void test_negative_size_short() {
+ short[] arr;
+ try {
+ arr = new short[-1];
+ } catch (NegativeArraySizeException nase) {
+ // OK
+ } catch (Exception e) {
+ fail();
+ }
+ }
+
+ // === int ====
+ @Test
+ public void test_bounds_int() {
+ int[] arr;
+ int o;
+ arr = new int[10];
+
+ try {
+ o = arr[-1];
+ fail();
+ } catch (ArrayIndexOutOfBoundsException abe) {
+ // OK
+ } catch (Exception e) {
+ fail();
+ }
+
+ arr = new int[10];
+ try {
+ arr[-1] = 0;
+ fail();
+ } catch (ArrayIndexOutOfBoundsException abe) {
+ // OK
+ } catch (Exception e) {
+ fail();
+ }
+
+ try {
+ o = arr[11];
+ fail();
+ } catch (ArrayIndexOutOfBoundsException abe) {
+ // OK
+ } catch (Exception e) {
+ fail();
+ }
+
+ arr = new int[10];
+ try {
+ arr[11] = 0;
+ fail();
+ } catch (ArrayIndexOutOfBoundsException abe) {
+ // OK
+ } catch (Exception e) {
+ fail();
+ }
+ }
+
+ @Test
+ public void test_negative_size_int() {
+ int[] arr;
+ try {
+ arr = new int[-1];
+ } catch (NegativeArraySizeException nase) {
+ // OK
+ } catch (Exception e) {
+ fail();
+ }
+ }
+
+ // === long ====
+ @Test
+ public void test_bounds_long() {
+ long[] arr;
+ long o;
+ arr = new long[10];
+
+ try {
+ o = arr[-1];
+ fail();
+ } catch (ArrayIndexOutOfBoundsException abe) {
+ // OK
+ } catch (Exception e) {
+ fail();
+ }
+
+ arr = new long[10];
+ try {
+ arr[-1] = 0;
+ fail();
+ } catch (ArrayIndexOutOfBoundsException abe) {
+ // OK
+ } catch (Exception e) {
+ fail();
+ }
+
+ try {
+ o = arr[11];
+ fail();
+ } catch (ArrayIndexOutOfBoundsException abe) {
+ // OK
+ } catch (Exception e) {
+ fail();
+ }
+
+ arr = new long[10];
+ try {
+ arr[11] = 0;
+ fail();
+ } catch (ArrayIndexOutOfBoundsException abe) {
+ // OK
+ } catch (Exception e) {
+ fail();
+ }
+ }
+
+ @Test
+ public void test_negative_size_long() {
+ long[] arr;
+ try {
+ arr = new long[-1];
+ } catch (NegativeArraySizeException nase) {
+ // OK
+ } catch (Exception e) {
+ fail();
+ }
+ }
+
+ // === float ====
+ @Test
+ public void test_bounds_float() {
+ float[] arr;
+ float o;
+ arr = new float[10];
+
+ try {
+ o = arr[-1];
+ fail();
+ } catch (ArrayIndexOutOfBoundsException abe) {
+ // OK
+ } catch (Exception e) {
+ fail();
+ }
+
+ arr = new float[10];
+ try {
+ arr[-1] = 0;
+ fail();
+ } catch (ArrayIndexOutOfBoundsException abe) {
+ // OK
+ } catch (Exception e) {
+ fail();
+ }
+
+ try {
+ o = arr[11];
+ fail();
+ } catch (ArrayIndexOutOfBoundsException abe) {
+ // OK
+ } catch (Exception e) {
+ fail();
+ }
+
+ arr = new float[10];
+ try {
+ arr[11] = 0;
+ fail();
+ } catch (ArrayIndexOutOfBoundsException abe) {
+ // OK
+ } catch (Exception e) {
+ fail();
+ }
+ }
+
+ @Test
+ public void test_negative_size_float() {
+ float[] arr;
+ try {
+ arr = new float[-1];
+ } catch (NegativeArraySizeException nase) {
+ // OK
+ } catch (Exception e) {
+ fail();
+ }
+ }
+
+ // === double ====
+ @Test
+ public void test_bounds_double() {
+ double[] arr;
+ double o;
+ arr = new double[10];
+
+ try {
+ o = arr[-1];
+ fail();
+ } catch (ArrayIndexOutOfBoundsException abe) {
+ // OK
+ } catch (Exception e) {
+ fail();
+ }
+
+ arr = new double[10];
+ try {
+ arr[-1] = 0;
+ fail();
+ } catch (ArrayIndexOutOfBoundsException abe) {
+ // OK
+ } catch (Exception e) {
+ fail();
+ }
+
+ try {
+ o = arr[11];
+ fail();
+ } catch (ArrayIndexOutOfBoundsException abe) {
+ // OK
+ } catch (Exception e) {
+ fail();
+ }
+
+ arr = new double[10];
+ try {
+ arr[11] = 0;
+ fail();
+ } catch (ArrayIndexOutOfBoundsException abe) {
+ // OK
+ } catch (Exception e) {
+ fail();
+ }
+ }
+
+ @Test
+ public void test_negative_size_double() {
+ double[] arr;
+ try {
+ arr = new double[-1];
+ } catch (NegativeArraySizeException nase) {
+ // OK
+ } catch (Exception e) {
+ fail();
+ }
+ }
+}
--- a/tools/JavaSyntaxHighlighter.st Thu Jun 25 15:54:39 2015 +0100
+++ b/tools/JavaSyntaxHighlighter.st Wed Jul 01 07:14:28 2015 +0100
@@ -111,7 +111,7 @@
preferences isNil ifTrue:[
preferences := UserPreferences current.
].
- JavaVM booted ifFalse:[
+ (JavaVM booted not or: [self doLexicalHighlightingOnly]) ifTrue:[
^ self format: source string.
].
@@ -143,32 +143,29 @@
ifTrue:[source copy]
ifFalse:[source asText].
- self doLexicalHighlightingOnly ifTrue:[
- sourceText := self format: source string.
- ] ifFalse:[
+
- sourceUnit := (Java classForName:'stx.libjava.tools.Source') new.
- sourceUnit setContents: source string.
- parser := (Java classForName:'stx.libjava.tools.text.Highlighter') new.
- parser setMarker: marker.
- (sourceIndex notNil and:[sourceIndex isKindOf: SmallSense::ParseTreeIndex]) ifTrue:[
- | indexer |
+ sourceUnit := (Java classForName:'stx.libjava.tools.Source') new.
+ sourceUnit setContents: source string.
+ parser := (Java classForName:'stx.libjava.tools.text.Highlighter') new.
+ parser setMarker: marker.
+ (sourceIndex notNil and:[sourceIndex isKindOf: SmallSense::ParseTreeIndex]) ifTrue:[
+ | indexer |
- indexer := Indexer new.
- indexer index: sourceIndex.
- parser setIndexer: indexer.
- ].
+ indexer := Indexer new.
+ indexer index: sourceIndex.
+ parser setIndexer: indexer.
+ ].
- "/ Following is support JImport expecco plugin. For classes loaded by
- "/ JImport plugin, do not resolve classes. The LookupEnvironment cannot
- "/ find them as they are not installed in class registry...
- resolve := class notNil and:[class isJavaClass and:[ (loader := class theNonMetaclass classLoader) isNil or:[loader isJavaObject] ] ].
+ "/ Following is support JImport expecco plugin. For classes loaded by
+ "/ JImport plugin, do not resolve classes. The LookupEnvironment cannot
+ "/ find them as they are not installed in class registry...
+ resolve := class notNil and:[class isJavaClass and:[ (loader := class theNonMetaclass classLoader) isNil or:[loader isJavaObject] ] ].
- tree := parser parse: sourceUnit diet: false resolve: resolve.
- (sourceIndex notNil and:[sourceIndex isKindOf: SmallSense::ParseTreeIndex]) ifTrue:[
- sourceIndex tree: tree.
- sourceIndex source: sourceText.
- ].
+ tree := parser parse: sourceUnit diet: false resolve: resolve.
+ (sourceIndex notNil and:[sourceIndex isKindOf: SmallSense::ParseTreeIndex]) ifTrue:[
+ sourceIndex tree: tree.
+ sourceIndex source: sourceText.
].
^ cacheIt ifTrue:[
@@ -275,7 +272,7 @@
].
process := process parentProcess.
].
- ^ false
+ ^ false
"Created: / 09-09-2013 / 02:25:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 25-03-2014 / 13:32:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
--- a/tools/java/src/stx/libjava/tools/compiler/CompileError.java Thu Jun 25 15:54:39 2015 +0100
+++ b/tools/java/src/stx/libjava/tools/compiler/CompileError.java Wed Jul 01 07:14:28 2015 +0100
@@ -55,7 +55,7 @@
field.set(null, "stx/libjava/tools/compiler/CompileError".toCharArray());
} catch (SecurityException e) {
- throw new RuntimeException("Failed to modify ConstantPool.JavaLangErrorConstantPoolName field!",e);
+ throw new RuntimeException("Failed to modify ConstantPool.JavaLangErrorConstantPoolName field!",e);
} catch (NoSuchFieldException e) {
throw new RuntimeException("Failed to modify ConstantPool.JavaLangErrorConstantPoolName field!",e);
} catch (IllegalArgumentException e) {
--- a/tools/java/src/stx/libjava/tools/compiler/CompilerAdapter.java Thu Jun 25 15:54:39 2015 +0100
+++ b/tools/java/src/stx/libjava/tools/compiler/CompilerAdapter.java Wed Jul 01 07:14:28 2015 +0100
@@ -44,7 +44,7 @@
try {
Class.forName("stx.libjava.tools.compiler.CompileError").newInstance();
} catch (Exception e) {
- throw new RuntimeException("Failed to initialize CompilerError class", e);
+ throw new RuntimeException("Failed to initialize CompilerError class: "+e.getMessage(), e);
}
}