From david at walend.net Wed Jul 4 09:49:37 2007 From: david at walend.net (David Walend) Date: Wed, 4 Jul 2007 12:49:37 -0400 Subject: Generics: accessing type parameters' type parameters Message-ID: <422FCC0F-936A-4354-A93F-E893E6BF1F57@walend.net> I'd like to start work on a KSL project to get dot access to type parameters' type parameters like I described last year in http://weblogs.java.net/blog/dwalend/archive/2006/05/ tilting_at_the_1.html . I spent some time poking around the compiler code and the Java language specification. I think getting the specification right will be harder. And I haven't touched language/compiler work since a class in grad school ten years ago. I think the most relevant section in the language specification is the section on Reference Types and Values at http://java.sun.com/docs/ books/jls/third_edition/html/typesValues.html#4.3 . That section lays out some simple rules, and looks like the right place to touch. I think I need to augment TypeVariable with something like TypeVariableSpecifier: TypeVariable TypeVariableSpecifier . TypeVariable , change ReferenceType to ReferenceType: ClassOrInterfaceType TypeVariableSpecifier ArrayType and add a note along these lines: "In a TypeVariable, a dot-accessed TypeVariable must resolve to the name of a TypeParameter within the context of the outer TypeVariable." How close is that to what needs to be there? Is using TypeVariables directly this way OK? Or should I imitate TypeName and define the works using Identifiers? Should I do anything for accessible member types (inner classes and their kin) in the dot expansion? Thanks, Dave David Walend david at walend.net From complystill at gmail.com Thu Jul 5 12:46:04 2007 From: complystill at gmail.com (Compl Yue Still) Date: Fri, 6 Jul 2007 03:46:04 +0800 Subject: javac code generator based java source interpreter, then... genuine scripted Java language Message-ID: Hi there, I'm recently working on an open source piece that will open scripting access to running applications in a server JVM, through SSH (with publickey authentication). It's maining concerning monitoring and management of thte server application over client/server connectivity. I've just done with the server side SSH part, and started the *Java Shell* support. I had been planning www.BeanShell.org for this, but get quite unhappy about that it hasn't get to support Generics / var args and etc yet. Coz what I got to support is a new object database system makes heavy use of these new features. And after some investigation I found several other *Scripting Java* products neither get this well. The result I'm expecting is that a Java application administrator or developer can interactively type and execute Java statements against his running application environment, with a text terminal remotely connected through SSH. No extra management tools should be needed for this because he is just typing *RAW* *NATIVE* Java statements as *scripts* into the server JVM, and most ideally he should be able to copy & paste his *scripts* into java source files of his static project without modification. This should increase his productivity and best help new comers to existing Java applications or base environments. However since all current *Java Scripting* tools fall far behind the evolution of Java, that lacks new but heavily used (by emerging applications) language features, I put thoughts about leveraging AST from javac or ecj to produce an up-to-date Java Interpreter that can *execute* Java statements in most recent syntax. After thoughts and some investigation, I have come to a rough idea that we can just copy code generator in current javac and refactor it to *perform* the bytecodes instead of to *generate* and *store* them to classfile format. Since resolving functions are already their for the attribution phase, the core task for such an interpreter seems to be a virtual *Callstack* that not only calculates space requirements but also actually stores objects and values. I (roughly) think this will be enough for a single-threaded interpreter that doesn't support constructing anonymous class instances to pass to compiled class methods. So what do you people think about this? Is it possible and practically viable from your views? Thanks & Regards, Compl From peter at ahe.dk Thu Jul 5 13:39:26 2007 From: peter at ahe.dk (=?ISO-8859-1?Q?Peter_Ah=E9?=) Date: Thu, 5 Jul 2007 13:39:26 -0700 Subject: javac code generator based java source interpreter, then... genuine scripted Java language In-Reply-To: References: Message-ID: I don't understand why you want to interpret, the JVM is good at that. Consider using the approach of this demo which compiles and evaluates Java expressions: https://ksl.dev.java.net/source/browse/ksl/trunk/compiler/test/tools/javac/api/evalexpr/ Cheers, Peter From complystill at gmail.com Thu Jul 5 14:19:46 2007 From: complystill at gmail.com (Compl Yue Still) Date: Fri, 6 Jul 2007 05:19:46 +0800 Subject: javac code generator based java source interpreter, then... genuine scripted Java language In-Reply-To: References: Message-ID: Hi Peter, Thanks for the quick and informative reply, I didn't get to this example before, and it seems very promising. But my concern is still about interactivly executing Java statements, like scrirpts, idealy like in a Shell (with word completion etc.), This is why I'd been considering BeanShell at the beginning. I havn't walked close enough to the Java Compiler API based approach so far, mainly in worries about Java class loading. I often heard JSP containers run OutOfMemory with default size for perm gen of heap, while the main heap is still free, simply because frequently recompiling of JSP pages i.e. class loading. I quite like the example you showed here, since it will just do EXACTLY what an state-of-the-art JVM does, but I'm still afraid of such an implementation within a long-run app-server JVM will cause problems sooner or later. I'm expecting positive opinions from you regarding your expertise in all these around. And another issue with this approache come to me that to prompt user inputs from an interactive shell, where complex constructs beyond simple expressions should be allowed, like for() loops etc. An AST parser knows well whether it has received enough input as to construct an evaluable node, but how could my code deal with that when it's not doing parsing jobs? One single line expression a time is not enough for it to be really useful. Best Regards, Compl On 7/6/07, Peter Ah? wrote: > I don't understand why you want to interpret, the JVM is good at that. > Consider using the approach of this demo which compiles and evaluates > Java expressions: > > https://ksl.dev.java.net/source/browse/ksl/trunk/compiler/test/tools/javac/api/evalexpr/ > > Cheers, > Peter > From complystill at gmail.com Wed Jul 11 08:07:16 2007 From: complystill at gmail.com (Compl Yue Still) Date: Wed, 11 Jul 2007 23:07:16 +0800 Subject: javac code generator based java source interpreter, then... genuine scripted Java language In-Reply-To: References: Message-ID: Hello, I have finished the part with Java Compiler API support, which is suggested by Peter, it seems work quite fine. I'm very happy that javac compiles really fast!! I have requested this piece of work as a dev.java.net project at: http://sjsh.dev.java.net it is pending approval now but if any of you can access its files, I packed the latest src under Document and Files/src-release. It is BSD licensed and I hope everyone enjoy it. Trying it out is quite easy, there's a pre-built sjsh.jar, just run java -jar sjsh.jar and it will start output some info, an authorized private key will be automatically generated. then run in another terminal: chmod 600 SJSH-Root/home/sjsh/.ssh/id_rsa ssh -l sjsh -p 22022 -i SJSH-Root/home/sjsh/.ssh/id_rsa if you have OpenSSH client installed. or you may need to convert id_rsa to your favorite SSH client's format and use it to login. After accept the host key and logged in, the terminal should display something like: This is an interactive Java(TM) shell, type in Java(TM) statements to get them executed. Type in Ctrl^D to logout. Type in ? or help for a list of available commands. Type in to complete commands. Use ?? ?? arrow keys for command history. SecueJSH Java(TM) Compiler Ready. [jsh ]$ ? Built-in commands: class + Start defining a new class in current package def [ [ | -] | - ] Define a field that persists across statements feedback [ on | off ] Control display of feedbacks fields Show all fields currently defined import .* | static .* Add an import imports Show all imports in current import list lineNo [ on | off ] Control display of line numbers package [ ] Specify current package preview [ on | off ] Control display of previews redef [ [ | -] | - ] Redefine a field that persists across statements undef Undefine an existing field unimport | * Remove specified import Type in: help|? [] for more details of a built-in command. [jsh ]$ Try some interactive java and, have fun ;-) cheers, Compl On 7/6/07, Compl Yue Still wrote: > Hi Peter, > > Thanks for the quick and informative reply, I didn't get to this > example before, and it seems very promising. > > But my concern is still about interactivly executing Java statements, > like scrirpts, idealy like in a Shell (with word completion etc.), > This is why I'd been considering BeanShell at the beginning. > > I havn't walked close enough to the Java Compiler API based approach > so far, mainly in worries about Java class loading. I often heard JSP > containers run OutOfMemory with default size for perm gen of heap, > while the main heap is still free, simply because frequently > recompiling of JSP pages i.e. class loading. > > I quite like the example you showed here, since it will just do > EXACTLY what an state-of-the-art JVM does, but I'm still afraid of > such an implementation within a long-run app-server JVM will cause > problems sooner or later. I'm expecting positive opinions from you > regarding your expertise in all these around. > > And another issue with this approache come to me that to prompt user > inputs from an interactive shell, where complex constructs beyond > simple expressions should be allowed, like for() loops etc. An AST > parser knows well whether it has received enough input as to construct > an evaluable node, but how could my code deal with that when it's not > doing parsing jobs? One single line expression a time is not enough > for it to be really useful. > > Best Regards, > Compl > > On 7/6/07, Peter Ah? wrote: > > I don't understand why you want to interpret, the JVM is good at that. > > Consider using the approach of this demo which compiles and evaluates > > Java expressions: > > > > https://ksl.dev.java.net/source/browse/ksl/trunk/compiler/test/tools/javac/api/evalexpr/ > > > > Cheers, > > Peter > > > From Jonathan.Gibbons at Sun.COM Wed Jul 11 08:37:48 2007 From: Jonathan.Gibbons at Sun.COM (Jonathan Gibbons) Date: Wed, 11 Jul 2007 08:37:48 -0700 Subject: javac code generator based java source interpreter, then... genuine scripted Java language In-Reply-To: References: Message-ID: <40C7FFD8-E254-4B6C-8F5D-0067BF7BD741@sun.com> Compl, With respect, this alias is for discussion of issues related to the development of the javac compiler, and related tools in the OpenJDK source base. Your news is interesting, but somewhat off-topic. -- Jonathan Gibbons On Jul 11, 2007, at 8:07 AM, Compl Yue Still wrote: > Hello, > > I have finished the part with Java Compiler API support, which is > suggested by Peter, it seems work quite fine. I'm very happy that > javac compiles really fast!! > > I have requested this piece of work as a dev.java.net project at: > http://sjsh.dev.java.net it is pending approval now but if any of you > can access its files, I packed the latest src under Document and > Files/src-release. It is BSD licensed and I hope everyone enjoy it. > > Trying it out is quite easy, there's a pre-built sjsh.jar, just run > > java -jar sjsh.jar > > and it will start output some info, an authorized private key will be > automatically generated. then run in another terminal: > > chmod 600 SJSH-Root/home/sjsh/.ssh/id_rsa > ssh -l sjsh -p 22022 -i SJSH-Root/home/sjsh/.ssh/id_rsa > > if you have OpenSSH client installed. or you may need to convert > id_rsa to your favorite SSH client's format and use it to login. > After accept the host key and logged in, the terminal should display > something like: > > This is an interactive Java(TM) shell, type in Java(TM) > statements to get them executed. > > Type in Ctrl^D to logout. > > Type in ? or help for a list of available commands. > > Type in to complete commands. > > Use ?? ?? arrow keys for command history. > > SecueJSH Java(TM) Compiler Ready. > > [jsh ]$ ? > Built-in commands: > > class + > Start defining a new class in current package > def [ [ | -] | - ] > Define a field that persists across statements > feedback [ on | off ] > Control display of feedbacks > fields > Show all fields currently defined > import .* | static .* > Add an import > imports > Show all imports in current import list > lineNo [ on | off ] > Control display of line numbers > package [ ] > Specify current package > preview [ on | off ] > Control display of previews > redef [ [ | -] | - ] > Redefine a field that persists across statements > undef > Undefine an existing field > unimport | * > Remove specified import > > Type in: help|? [] > for more details of a built-in command. > > [jsh ]$ > > Try some interactive java and, have fun ;-) > > cheers, > Compl > > On 7/6/07, Compl Yue Still wrote: >> Hi Peter, >> >> Thanks for the quick and informative reply, I didn't get to this >> example before, and it seems very promising. >> >> But my concern is still about interactivly executing Java statements, >> like scrirpts, idealy like in a Shell (with word completion etc.), >> This is why I'd been considering BeanShell at the beginning. >> >> I havn't walked close enough to the Java Compiler API based approach >> so far, mainly in worries about Java class loading. I often heard JSP >> containers run OutOfMemory with default size for perm gen of heap, >> while the main heap is still free, simply because frequently >> recompiling of JSP pages i.e. class loading. >> >> I quite like the example you showed here, since it will just do >> EXACTLY what an state-of-the-art JVM does, but I'm still afraid of >> such an implementation within a long-run app-server JVM will cause >> problems sooner or later. I'm expecting positive opinions from you >> regarding your expertise in all these around. >> >> And another issue with this approache come to me that to prompt user >> inputs from an interactive shell, where complex constructs beyond >> simple expressions should be allowed, like for() loops etc. An AST >> parser knows well whether it has received enough input as to >> construct >> an evaluable node, but how could my code deal with that when it's not >> doing parsing jobs? One single line expression a time is not enough >> for it to be really useful. >> >> Best Regards, >> Compl >> >> On 7/6/07, Peter Ah? wrote: >> > I don't understand why you want to interpret, the JVM is good at >> that. >> > Consider using the approach of this demo which compiles and >> evaluates >> > Java expressions: >> > >> > https://ksl.dev.java.net/source/browse/ksl/trunk/compiler/test/ >> tools/javac/api/evalexpr/ >> > >> > Cheers, >> > Peter >> > >> From jesse.glick at sun.com Wed Jul 11 12:27:25 2007 From: jesse.glick at sun.com (Jesse Glick) Date: Wed, 11 Jul 2007 15:27:25 -0400 Subject: javac code generator based java source interpreter, then... genuine scripted Java language In-Reply-To: References: Message-ID: Compl Yue Still wrote: > [...] I [thought] about leveraging AST from javac or ecj to produce > an up-to-date Java Interpreter that can *execute* Java statements in > most recent syntax. Probably this is a topic for scripting.dev.java.net, where there is already a very simple script engine based on JSR 199 that could surely be extended. -J. -- jesse.glick at sun.com netbeans.org ant.apache.org hudson.dev.java.net http://google.com/search?q=e%5E%28pi*i%29%2B1 From Jonathan.Gibbons at Sun.COM Sat Jul 14 07:58:03 2007 From: Jonathan.Gibbons at Sun.COM (Jonathan Gibbons) Date: Sat, 14 Jul 2007 07:58:03 -0700 Subject: Survey: NetBeans features for working on the compiler Message-ID: Team, We're well underway with work to reorganize the compiler and related tools into a separate workspace within OpenJDK. In the short term, this means a separate TeamWare workspace at Sun and a separate top level directory sibling to j2se in the OpenJDK repositories. In the Mercurial world, it will (eventually) mean a separate stand-alone Mercurial repository for everybody. As part of this work, the build for the compiler has been changed to use Ant, with a Makefile wrapper for those that still prefer GNU make (such as the main j2se build.) This is with the intent that there should be one single build file used by the official j2se build, the NetBeans projects, and the primary contributors to this part of the code base. I'm getting to the point of dotting "i"s and crossing "t"s with respect to the Netbeans support for this workspace -- i.e. hooking up NetBeans features to "do the right thing". And here's where I'm looking for your input. I'm working through the "Advanced Free-Form Project Configuration" at http://www.netbeans.org/kb/41/freeform-config.html, and I'm wondering how many of these features we should support. Hooking up build/debug/test are no-brainers -- but the note lists 15 standard targets, and I'm wondering if anyone would notice if any were not implemented. So here's your chance to give your wish-list for NetBeans features that you would like to use when working on the compiler. Existing features only, please; send requests for new features to the NetBeans guys! By the way, so far we do not need any of the new features only available in NetBeans 6, so I'm targetting NetBeans 5 for this work. -- Jon G. From jesse.glick at sun.com Tue Jul 17 11:41:17 2007 From: jesse.glick at sun.com (Jesse Glick) Date: Tue, 17 Jul 2007 14:41:17 -0400 Subject: Survey: NetBeans features for working on the compiler In-Reply-To: References: Message-ID: Jonathan Gibbons wrote: > I'm working through the "Advanced Free-Form Project Configuration" at > http://www.netbeans.org/kb/41/freeform-config.html, and I'm > wondering how many of these features we should support. Hooking up > build/debug/test are no-brainers -- but the note lists 15 standard > targets, and I'm wondering if anyone would notice if any were not > implemented. debug.fix is very useful and not hard to add. BTW you can also add support for using the NB Profiler if that is desirable. It is easiest to just get the Freeform Project Extras module from Auto Update, then make a "skeletal" project to play with, and copy and paste with edits from its build scripts as desired. -J. -- jesse.glick at sun.com netbeans.org ant.apache.org hudson.dev.java.net http://google.com/search?q=e%5E%28pi*i%29%2B1 From Jonathan.Gibbons at Sun.COM Tue Jul 17 11:48:35 2007 From: Jonathan.Gibbons at Sun.COM (Jonathan Gibbons) Date: Tue, 17 Jul 2007 11:48:35 -0700 Subject: Survey: NetBeans features for working on the compiler In-Reply-To: References: Message-ID: <469D0F03.9070301@sun.com> Jesse, Yes, in the end, I ended up with a merge of the IDE actions I find useful and of those in the OpenJDK projects, including debug.fix. It seemed the simplest way to minimize surprise. -- Jon Jesse Glick wrote: > Jonathan Gibbons wrote: >> I'm working through the "Advanced Free-Form Project Configuration" at >> http://www.netbeans.org/kb/41/freeform-config.html, and I'm >> wondering how many of these features we should support. Hooking up >> build/debug/test are no-brainers -- but the note lists 15 standard >> targets, and I'm wondering if anyone would notice if any were not >> implemented. > > debug.fix is very useful and not hard to add. BTW you can also add > support for using the NB Profiler if that is desirable. It is easiest > to just get the Freeform Project Extras module from Auto Update, then > make a "skeletal" project to play with, and copy and paste with edits > from its build scripts as desired. > > -J. > From robilad at kaffe.org Thu Jul 19 15:12:18 2007 From: robilad at kaffe.org (Dalibor Topic) Date: Fri, 20 Jul 2007 00:12:18 +0200 Subject: jtreg regressions around deprecated warning Message-ID: <469FE1C2.6070902@kaffe.org> Hi all, I've ran jtreg on the current javac sources with the latest java 6 binary from sun for x86-linux, and I'm seeing 12 failed regression tests, that all look a bit like this one: ==snip== #Test Results (version 2) #Thu Jul 19 18:32:14 CEST 2007 #checksum:5d07645553e1f00b #-----testdescription----- $file=/home/topic/gsoc/work/openjdk/j2se/src/share/opensource/javac/test/tools/javac/mandatoryWarnings/deprecated/Test.java $root=/home/topic/gsoc/work/openjdk/j2se/src/share/opensource/javac/test/tools/javac id=id13 keywords=bug5047307 run=USER_SPECIFIED compile/ref=Test4d.out -XDstdout -XDrawDiagnostics -nowarn -Xlint:deprecation -Xmaxwarns 3 A.java B.java\n source=Test.java title=javac -nowarn improperly suppresses JLS-mandated warnings #-----environment----- #-----testresult----- description=file:///home/topic/gsoc/work/openjdk/j2se/src/share/opensource/javac/test/tools/javac/mandatoryWarnings/deprecated/Test.java#id13 end=Thu Jul 19 18:32:14 CEST 2007 environment=regtest execStatus=Failed. Output does not match reference file: Test4d.out, line 1 javatestOS=Linux 2.6.22-8-generic (i386) javatestVersion=3.2.2_02 script=com.sun.javatest.regtest.RegressionScript sections=script_messages compile start=Thu Jul 19 18:32:14 CEST 2007 test=mandatoryWarnings/deprecated/Test.java#id13 work=/home/topic/gsoc/work/openjdk/j2se/src/share/opensource/javac/build/jtreg/work/mandatoryWarnings/deprecated #section:script_messages ----------messages:(4/188)---------- JDK under test: (/usr/lib/jvm/java-6-sun-1.6.0.02) java version "1.6.0_02" Java(TM) SE Runtime Environment (build 1.6.0_02-b05) Java HotSpot(TM) Client VM (build 1.6.0_02-b05, mixed mode) #section:compile ----------messages:(3/486)---------- command: compile -XDstdout -XDrawDiagnostics -nowarn -Xlint:deprecation -Xmaxwarns 3 /home/topic/gsoc/work/openjdk/j2se/src/share/opensource/javac/test/tools/javac/mandatoryWarnings/deprecated/A.java /home/topic/gsoc/work/openjdk/j2se/src/share/opensource/javac/test/tools/javac/mandatoryWarnings/deprecated/B.java reason: User specified action: run compile/ref=Test4d.out -XDstdout -XDrawDiagnostics -nowarn -Xlint:deprecation -Xmaxwarns 3 A.java B.java elapsed time (seconds): 0.417 ----------System.out:(5/562)---------- A.java:10:9: compiler.warn.has.been.deprecated: A1, compiler message file broken: key=compiler.misc.unnamed.package arguments={0}, {1}, {2}, {3}, {4}, {5}, {6}, {7} A.java:10:21: compiler.warn.has.been.deprecated: A1, compiler message file broken: key=compiler.misc.unnamed.package arguments={0}, {1}, {2}, {3}, {4}, {5}, {6}, {7} B.java:11:9: compiler.warn.has.been.deprecated: B1, compiler message file broken: key=compiler.misc.unnamed.package arguments={0}, {1}, {2}, {3}, {4}, {5}, {6}, {7} - compiler.note.deprecated.filename.additional: B.java 3 warnings ----------System.err:(0/0)---------- result: Failed. Output does not match reference file: Test4d.out, line 1 test result: Failed. Output does not match reference file: Test4d.out, line 1 ==snip== i.e. it seems that something's going wrong with the message lookup code for the compiler.warn.has.been.deprecated property. Is that a known bug/feature? cheers, dalibor topic