php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #3973 Java support Makefiles are incorrect in Solaris
Submitted: 2000-03-29 22:14 UTC Modified: 2000-04-03 11:41 UTC
From: jesusmc at scripps dot edu Assigned: rubys (profile)
Status: Closed Package: Compile Failure
PHP Version: 4.0 Release Candidate 1 OS: Solaris 2.6
Private report: No CVE-ID: None
 [2000-03-29 22:14 UTC] jesusmc at scripps dot edu
(This is related to bug ID # 3972)

The only way I could get Java support to compile for PHP 4.0RC1 in Solaris 2.6, was to manually create the jar files.

I used the following config command:

./configure --prefix=/asd/dredox3/development/php4 \
--with-config-file-path=/asd/dredox3/development/php4 \
--enable-track-vars --enable-magic-quotes \
--enable-xml --enable-wddx --disable-debug\
--with-servlet=/asd/metallo1/server/jserv/JSDK2.0\
--enable-bcmath --enable-trans-id\
--with-java=/asd/prog/opt/jdk1.2 \
--with-gd=/asd/metallo1/server/libs/gd \
--with-mysql\
--with-apxs=/asd/dredox3/development/apache/sbin/apxs

And noticed several errors when compiling, mostly in the "sapi/servlet/" dir. One was related to the file "sapi/servlet/servlet.java", which was using an incorrect method (at least for Sun's JSDK 2.0). The diff is below:

*** php-4.0RC1/sapi/servlet/servlet.java        Tue Mar 28 16:14:32 2000
--- orig-php-4.0RC1/sapi/servlet/servlet.java   Thu Mar  9 05:07:24 2000
***************
*** 86,94 ****
          } else {
            int colon = data.indexOf(": ");
            if (colon > 0) {
!             /*response.addHeader(data.substring(0,colon),*/
!                       /* JSDK 2.0 uses setHeader instead. JMC */
!             response.setHeader(data.substring(0,colon),
                data.substring(colon+2));
            } else {
              response.getWriter().println(data);
--- 86,92 ----
          } else {
            int colon = data.indexOf(": ");
            if (colon > 0) {
!             response.addHeader(data.substring(0,colon),
                data.substring(colon+2));
            } else {
              response.getWriter().println(data);
***************
*** 134,141 ****
         try {
           if (stream != null) stream.close();
         } catch (IOException e) {
!                /* JSDK 2.0 - Exception is a sting - JMC */
!          throw new ServletException(e.toString());
         }
      }
  
--- 132,138 ----
         try {
           if (stream != null) stream.close();
         } catch (IOException e) {
!          throw new ServletException(e);
         }
      }

Even after this was done, the generated makefile was still giving trouble. So I manually compiled the jar file:

% cd sapi/servlet
% mkdir net; mkdir net/php
% echo library=php4 | tee net/php/reflect.properties > net/php/servlet.properties
% cp formatter.java servlet.java net/php
% cp ../../ext/java/reflect.java net/php
% javac -classpath .:/asd/metallo1/server/jserv/JSDK2.0/lib/jsdk.jar:/asd/prog/opt/jdk1.2:./net/php net/php/*.java
% jar cf phpsrvlt.jar net/php/*.class net/php/*.properties

And once this was done, the problem was in "ext/java", where for some reason, the Makefile was not created, so I did also a manual jar file creation, following the Makefile.in steps.

Just to make sure it was not a problem w/ my inital config. I did "make clean", removed the "*.cache" and configured again, this time w/ a JDK 1.1.x, same result. The "ext/java/Makefile" was not existent, and there were problems w/ the jar file creation in the "sapi/servlet" dir.

This is a problem that seems correlated w/ the failures I mentioned in bug report ID # 3972.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-03-29 22:32 UTC] rubys at cvs dot php dot net
1) I did my development with JSDK 2.2.  I'll take a look at your changes and see if I can add support for JSDK 2.0.  This may be difficult as Java does not have an #ifdef...

2) You say that "the generated makefile was still giving trouble". Can you be more specific?

3) If you specify --with-servlet, there is no need for a Makefile in the java directory.  The java code is copied into the servlet directory and compiled into a single shared library.  I'll look into adding a comment into the readme so that others will not be confused.
 [2000-03-30 20:10 UTC] jesusmc at scripps dot edu
That is good info:

Re: 1) I will download the JSDK 2.2 later and try a clean compile,
and will see how it fares. That JSDK supports "setHeader" still,
so you could just use that or a kludge like the one below, it compiles
but I have not tested it so I can't tell if it does the right thing:
(it uses the introspection classes)

% diff -c php-4.0RC1/sapi/servlet/servlet.java orig-php-4.0RC1/sapi/servlet/servlet.java

*** php-4.0RC1/sapi/servlet/servlet.java        Thu Mar 30 17:02:04 2000
--- orig-php-4.0RC1/sapi/servlet/servlet.java   Thu Mar  9 05:07:24 2000
***************
*** 23,30 ****
  import java.util.Enumeration;
  import javax.servlet.*;
  import javax.servlet.http.*;
- import java.lang.Class;
- import java.lang.reflect.Method;
  
  public class servlet extends HttpServlet {
  
--- 23,28 ----
***************
*** 88,112 ****
          } else {
            int colon = data.indexOf(": ");
            if (colon > 0) {
!                         /* 
!                          * JSDK 2.0 uses setHeader instead but JDSK 2.2 uses addHeader,
!                          * although setHeader is still valid -- JMC
!                          */
!                         // kludge because in Java there's no #ifdef
!                         String params[] = {data.substring(0,colon), data.substring(colon+2)};
!                         try {
!                               Method methodHeader =
!                                 this.getClass().getMethod("addHeader",null).getName().equals("") ?
!                                       this.getClass().getMethod("setHeader",null) :
!                                       this.getClass().getMethod("addHeader",null);
!                               methodHeader.invoke (this, params);
!                         } catch (Exception e) {
!                               System.err.println("Could not invoke header method");
!                         }
!         } else {
!         response.getWriter().println(data);
          }
-       }
        } catch (IOException e) {
          System.err.print(data);
        }
--- 86,97 ----
          } else {
            int colon = data.indexOf(": ");
            if (colon > 0) {
!             response.addHeader(data.substring(0,colon),
!               data.substring(colon+2));
!           } else {
!             response.getWriter().println(data);
!           }
          }
        } catch (IOException e) {
          System.err.print(data);
        }
***************
*** 142,154 ****
         send(request.getMethod(), request.getQueryString(),
              request.getPathInfo(), contextPath,
              request.getContentType(), request.getContentLength(),
!       request.getRemoteUser(), display_source_mode);
  
         try {
           if (stream != null) stream.close();
         } catch (IOException e) {
!          /* JSDK 2.0 - Exception is a string - JMC */
!          throw new ServletException(e.toString());
         }
      }
  
--- 127,138 ----
         send(request.getMethod(), request.getQueryString(),
              request.getPathInfo(), contextPath,
              request.getContentType(), request.getContentLength(),
!           request.getRemoteUser(), display_source_mode);
  
         try {
           if (stream != null) stream.close();
         } catch (IOException e) {
!          throw new ServletException(e);
         }
      }



Re: 2) The "still giving trouble" comment referred to the problem
that the makefile was dying on the "@test" lines (when creating
the net/php" subdir and later on the class compilation line and
the jar creation. Might be a cobined problem from the previous 
messed up compilations.

Re: 3) I noticed that. So only the jar file in the sapi/servlet dir
is needed. 

Question: Do I need to add the servlet support to gain the
java support? Can I just get java support alone?


 [2000-03-30 21:11 UTC] rubys at cvs dot php dot net
1) I'll look into introspection (JServ is popular and is stuck at JSDK 2.0).  Looking at your code, I think there are a few things that need to be fixed (example: getMethod should be passed new Class[] {} instead of null, and will throw an exception if the method is not found).

2) If test is failing on Solaris, then I did something wrong.  Not every OS supports the same options, so I need to settle on the least common denominator.

3) No, you don't need servlet support to get Java support.


 [2000-04-03 11:41 UTC] rubys at cvs dot php dot net
1) I've modified the code to use introspection.  It should work on both JSDK 2.0 and JSDK 2.2 now.  I have verified that it clean compiles, but I haven't run it.  If you have any problems, let me know.

2) It seems that Solaris doesn't have "test -e".  I've substituted "test -d".  This should fix the problem.

As (3) was already answered, I'm going ahead and closing this bug at this time.  

Again, as I don't do development on Solaris or with JSDK 2.0, let me know if you have any further problems.
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Sun Jun 28 12:00:02 2026 UTC