When "ab".equals("ab") returns false

One thing that really ticks me off in java is the narrow-mindedness of equals. Given the specifications laid out in Object.equals(), it becomes extremely tricky to ever have equals return true for comparison of Objects of different types.
"So what?" You say. Well, back to the original title of this topic, it is possible for ab to not equal ab in the following cases.
String ab = "ab";
StringBuffer buffer = new StringBuffer(ab);
char[] buf2 = new char[] {'a','b'}
ab.equals(buffer) == always false
buffer.equals(ab) == always false
ab.equals(buf2) == always false
buf2.equals(ab) == always false
I could see how you probably couldn't and shouldn't make a String equal to a character array, but what about a StringBuffer??? I mean, come on! No one's going to try to compare a stringbuffer to a string or vice versa and get frustrated when it doesn't work?
"Well," perhaps you are saying to yourself, "perhaps those that don't understand the way java is implemented could fall into that trap". While you are considering this thought, download the jdk1.5 source code and have a look at java.text.ChoiceFormat, especially applyPattern and how it uses equals

One thing that really ticks me off in java is the
narrow-mindedness of equals. Given the specifications
laid out in Object.equals(), it becomes extremely
tricky to ever have equals return true for comparison
of Objects of different types.
the equals method in the object class does the same thing as == does, meaning only when you are comparing the same object, it returns true. it is meant to be overridden in subclasses for real situations.
"So what?" You say. Well, back to the original title
of this topic, it is possible for ab to not equal ab
in the following cases.
the title is misleading, "ab" will always equals to "ab". the following is a different matter:
String ab = "ab";
StringBuffer buffer = new StringBuffer(ab);
char[] buf2 = new char[] {'a','b'}
ab.equals(buffer) == always falsethe equals implementation will return true only two objects are of string type. stringbuffer is not, so it will always return false.
buffer.equals(ab) == always falsestringbuffer does no have its own implementation of the equals method, it uses the one in the object class, which will return true if you are comparing the same object, only if == is true, equals will be true. here it is apparently not the xase, so it will reuturn false always.
ab.equals(buf2) == always false
buf2.equals(ab) == always false
see above.
I could see how you probably couldn't and shouldn't
make a String equal to a character array, but what
about a StringBuffer??? I mean, come on! No one's
going to try to compare a stringbuffer to a string or
vice versa and get frustrated when it doesn't work?
see above.
considering this thought, download the jdk1.5 source
code and have a look at java.text.ChoiceFormat,
especially applyPattern and how it uses equalsi dont see any difference in 1.5, as comapred to 1.4. you were probabally not so careful, as i saw in the src a line labled as "tempBuffer", but it was actually a string.

Similar Messages

  • How can I send an email when a function returns false?

    Im trying to make this code work, but i still receive an email when the function is equal to false. Can anyone assist me in finding the issue? What the program does is look for servers that has a set limit (in GB) on specific drives.
    #This Program goes through all the servers and informs any level below the limit
    $ErrorActionPreference = "SilentlyContinue";
    $scriptpath = $MyInvocation.MyCommand.Definition
    $dir = Split-Path $scriptpath
    #=================Function============
    Function isLow($server, $drive, $limit)
    $disk = Get-WmiObject -ComputerName $server -Class Win32_LogicalDisk -Filter "DriveType = 3 and DeviceID = '$drive'";
    [float]$size = $disk.Capacity;
    [float]$freespace = $disk.FreeSpace;
    $sizeGB = [Math]::Round($size / 1073741824, 2);
    $freeSpaceGB = [Math]::Round($freespace / 1073741824, 2);
    if($freeSpaceGB -lt $limit){
    return $true;
    else{
    return $false;
    #================Servers==============
    #------------------###server1--------------
    $server = "###server1";
    $drive = "C:";
    $lim = 25;
    if(isLow $server $drive $lim)
    $Alert += $server + " || " + $drive + " is low<br>"
    $server = "###server1";
    $drive = "D:";
    $lim = 35;
    if(isLow $server $drive $lim)
    $Alert += $server + " || " + $drive + " is low<br>"
    #-----------------###(more servers ect.)--------------
    #================EMAIL===============
    $smtpServer = "192.168.x.x"
    $ReportSender = "[email protected]"
    $users = "[email protected]"
    $MailSubject = "ALERT!!! Low DiskSpace"
    foreach($user in $users){
    if($true){
    Write-Host "Sending Email notification to $user"
    $smtp = New-Object Net.Mail.SmtpClient($smtpServer)
    $msg = New-Object Net.Mail.MailMessage
    $msg.To.Add($user)
    $msg.From = $ReportSender
    $msg.Subject = $MailSubject
    $msg.IsBodyHTML = $True
    $msg.Body = $Alert
    $smtp.Send($msg)
    else($false){
    Write-Host "No one is pass the limit"

    Using a CSV is good.  Just load the "$servers" hash array from a CSV and the rest will work the same. The overall structure would work better if it was more like this.
    Function isLow($server, $drive, $limit){
    $disk = Get-WmiObject -ComputerName $server -Class Win32_LogicalDisk -Filter "DriveType = 3 and DeviceID = '$drive'"
    if($disk.FreeSSpace -lt $limit){
    $true
    }else{
    $false
    $servers=@()
    $servers=@{
    Server="###server1"
    Drive='C:'
    Limit=25Gb
    $servers=@{
    Server="###server2"
    Drive='D:'
    Limit=15Gb
    $servers=@{
    Server="###server3"
    Drive='C:'
    Limit=50Gb
    $results=foreach($servers in $servers){
    if(isLow $server.Server $server.Drive $server.Limit){
    '{0} || {1} is low<br>' -f $servers.Server,$server.Drive
    if($results){
    Write-Host 'Sending Email notification' -fore green
    $mailprops=@{
    SmtpServer='192.168.x.x'
    From='[email protected]'
    To=$users
    Subject='ALERT!!! Low DiskSpace'
    Body=$results
    BodyAsHtml=$true
    Send-MailMessage @mailprops
    }else{
    Write-Host 'No one is past the limit' -ForegroundColor green
    The biggest issue is to realize that this is a computer.  If you type the same thing more than once then consider that the computer can do it for you.  Once you learn to think like a computer all of this becomes easier.
    ¯\_(ツ)_/¯

  • Bug Report: ResultSet.isLast() returns false when queries return zero rows

    When calling the method isLast() on a resultset that contains zero (0) rows, false is returned. If a resultset contains no rows, isLast() should return true because returning false would indicate that there are more rows to be retrieved.
    Try the following Java source:
    import java.io.*;
    import java.sql.*;
    import java.util.*;
    import oracle.jdbc.driver.*;
    public class Test2 {
    public static void main (String [] args) throws Exception {
    Connection conn = null;
    String jdbcURL = "jdbc:oracle:thin:@" +
    "(DESCRIPTION=(ADDRESS=(HOST=<host computer>)"+
    "(PROTOCOL=tcp)(PORT=<DB port number>))"+
    "(CONNECT_DATA=(SID=<Oracle DB instance>)))";
    String userId = "userid";
    String password = "password";
    try{
    // Load the Oracle JDBC Driver and register it.
    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    // *** The following statement creates a database connection object
    // using the DriverManager.getConnection method. The first parameter is
    // the database URL which is constructed based on the connection parameters
    // specified in ConnectionParams.java.
    // The URL syntax is as follows:
    // "jdbc:oracle:<driver>:@<db connection string>"
    // <driver>, can be 'thin' or 'oci8'
    // <db connect string>, is a Net8 name-value, denoting the TNSNAMES entry
    conn = DriverManager.getConnection(jdbcURL, userId, password);
    } catch(SQLException ex){ //Trap SQL errors
    // catch error
    //conn = new OracleDriver().defaultConnection(); // Connect to Oracle 8i (8.1.7), use Oracle thin client.
    PreparedStatement ps = conn.prepareStatement("select 'a' from dual where ? = ?", ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); // Use any query that will return zero rows.
    ps.setInt(1, 1); // Set the params so that the query returns 0 rows.
    ps.setInt(2, 2);
    ResultSet rs = ps.executeQuery();
    System.out.println("1. Last here? " + rs.isLast());
    while (rs.next()) {
    // do whatever
    System.out.println("2. Last here? " + rs.isLast());
    ps.close();
    rs.close();
    EXPECTED RESULT -
    1. Last here? true
    2. Last here? true
    ACTUAL RESULT -
    1. Last here? false
    2. Last here? false
    This happens to me on Oracle 9.2.0.1.0.

    387561,
    For your information, I discovered this problem from
    running a query that did access an actual DB table.
    Try it and let me know.I did say I was only guessing, and yes, I did try it (after I posted my reply, and before I read yours). And I did check the query plan for the queries I tried -- to verify that they were actually doing some database "gets".
    In any case, the usual way that I determine whether a "ResultSet" is empty is when the very first invocation of method "next()" returns 'false'. Is that not sufficient for you?
    Good Luck,
    Avi.

  • File.exists() returns false even when the file exists

    hi,
    the exists() function of java.io.File function returns false even when the file exists on the file system. why is this? i checked the path of the file which gives me the correct path, but exists returns false. can anyone help?

    post some of the code you�re using - then maybe I can help you out
    //Anders

  • File.exists() returns false for existing file, help :)

    Hi all,
    I'm having the STRANGEST behavior... I'm working on a simple DNS management system, and before I overwrite a zone file, I want to check if it exists... but exists() is returning false even when the file exists.
    Here is my code snippet:
    finest( "Checking the existance of "+filename ) ;
    File zoneFile = new File( filename ) ;
    if ( zoneFile.exists() ) {
        finest( "Zone File "+zoneFile+" already exists." ) ;
        throw( new ZoneFileExistsException( fqdn ) ) ;
    else {
        finest( "Creating Zone File "+zoneFile ) ;
        ...It's producing this in the log (I cut off the timestamp parts):
    Checking the existance of /opt/DNS/db.testingbutler222.com
    Creating Zone File /opt/DNS/db.testingbutler222.com
    but...
    # ls -l /opt/DNS/db.testingbutler222.com
    -rw-r--r-- 1 root other 733 Aug 27 19:23 /opt/DNS/db.testingbutler222.com
    So... as you can see, the file CLEARLY exists... what the heck am I doing wrong or misunderstanding? This can't really be a bug in File, can it?
    Kenny Smith

    Hi,
    Thanks for your response, but as I showed in my first post, I'm using absolute paths. My log file contains this:
    Checking the existance of /opt/DNS/db.testbutler222.com...
    Existance of /opt/DNS/db.testbutler222.com=false
    # ls -l /opt/DNS/db.testbutler222.com
    -rw-r--r-- 1 root other 695 Aug 29 12:17 /opt/DNS/db.testbutler222.com
    I don't understand what is happening... I wrote a separate class that just tests the existance of a file, and that one is reporting the existance correctly.... (the source code is found in the second post above) I don't understand why my servlet code can see the file.
    I have jakarta-tomcat running as root, and the file I'm checking was created by the same servlet. I've double checked permissions and such, just to make sure it wasn't that.. but it's still not working.
    I even added code to create a FileReader from the file, that way if it throws a FileNotFoundException, I would know the file doesn't exist... and even though the file does exist, it throws the exception. :(
    Kenny

  • How to make reader.ready() return false

    reader.ready() method returned false for me when reading from
    when reader is obtained from databse. eg. Clob reader.
    So that can be acceptable that next call may block thats why ready() returned false.
    But i want to simulate situation when reader.ready() returns false even if reader is eg. FileReader, directy reading from
    existing file on local unix machine. (and this file is having content)
    So can it happen? And in which cases?

    can you telll me those few cases for this method ?
    I am interested in cases when io operations on local non empty file may lead to blocking call so that this method will return false

  • BufferedReader.ready() keeps returning false using JSSE 1.0.2/jdk 1.2.2

    I'm running into difficulties reading a response data stream from a server via HTTPS. The SSL sets up fine (I can see both the client side and server side certificate chains, and the two sides can handshake and agree on a cipher (SSL_RSA_WITH_RC4_128_SHA in this case)). I get no errors getting the output or input streams from the socket, and the GET request seems to work (no errors reported by the PrintWriter), but in.ready() returns false, and the while loop exits immediately. But I know there is data available (I can paste the printed url into Netscape and get data back). Since this should not be all that complex once the SSL session is established, I'm probably missing something silly, Can someone tell me what it is please?
    Thanks
    Doug
    // code excerpt
    // just finished printing the cipher suite, cert chains, etc
    try{
    out = new PrintWriter(
    new BufferedWriter(
    new outputStreamWriter(socket.getOutputStream() )));
    } catch(Exception e) {
    System.out.println("Error getting input and output streams from socket ");
    System.out.println(e.getMessage());
    e.printStackTrace();
    throw(e);
    try{   // time to submit the request and get the data
    // build the URL to get
    // tried constructing it here and nailing it up at declaration time - no difference
    // path = "https://" + dlp.host + ":" + Integer.toString(dlp.port) + "/" +
    // dlp.basePath + "?StartDate=" + longDateFmtURL.format(dlp.startDate) +
    // "&EndDate=" + longDateFmtURL.format(dlp.endDate);
    System.out.println("Sending request for URL" );
    System.out.println(path);
    out.println("GET " + path );
    out.println();
    out.flush();
    * Make sure there were no errors
    if (out.checkError()){
    System.out.println("Error sending request to server");
    throw(new IOException("Error sending request to server")
    try{
         in = new BufferedReader(
              new InputStreamReader(
              socket.getInputStream() ));
    } catch(Exception e) {
    System.out.println("Error getting input stream from socket ");
    System.out.println(e.getMessage());
    e.printStackTrace();
    //System.exit(3);
    throw(e);
    if (!in.ready()) {   //  in.ready() keeps returning false
    System.out.println("Error - socket input stream not ready for reading");
    while ((inputLine = in.readLine()) != null) {
    // loop over and process lines if it was ever not null
    }

    Never mind.
    The problem seems to be related to the development/debugging enviroment (Oracle JDeveloper 3.2.3), When I run things outside of that eviroment using the "plain" runtime, it works as expected (back to System.out.println() for debugging). That said, I usually find it to be a nice development/debugging enviroment for Java.

  • Default hostnameverifier always returns false ...

    Hi,
    I am trying to run wsdl2java by supplying an https URL. The JVM args that I am using are:
    javax.net.ssl.trustStore=E:/Romil/projects/AirDeccanPlugin/localhost.ks
    java.protocol.handler.pkgs=com.sun.net.ssl.internal.www.protocol
    On running wsdl2java, I end up getting the following exception:
    java.io.IOException: wrong hostname : should be <...>
    I've verified that the hostname (IP address) in the URL exactly matches the CN (IP address) in the server certificate .
    When I look at the JSSE code, it seems like the default HostnameVerifier always returns "false".
    I also couldnt figure out a non-programatical way of supplying my own
    HostnameVerfier to JSSE that returns a "true"
    Any solutions/thoughts ?
    Thanks and regards,
    Romil

    try this code before creating a connection
    com.sun.net.ssl.HostnameVerifier hv=new com.sun.net.ssl.HostnameVerifier() {
    public boolean verify(String urlHostname, String certHostname) {
    System.out.println("Warning: Hostname is not matched for cert: "+urlHostname+ certHostname);
    return true;
    com.sun.net.ssl.HttpsURLConnection.setDefaultHostnameVerifier(hv);
    this should solve your problem
    cheers

  • Captivate 8:  Getting this message "Unable to locate LMS's API, content may not play properly".  Then I get a debug message of "44:Tue Feb 17 2015 : InIsLoaded, returning false".  Has anyone else seen this?

    Captivate 8:  Getting this message "Unable to locate LMS's API, content may not play properly".  Then I get a debug message of "44:Tue Feb 17 2015 : InIsLoaded, returning false".  I also see a message in the preview pane when I view the .htm file in the project folder "This course requires JavaScript to be enabled in your browser.  Please enable JavaScript, then relaunch the course."   JavaScript is already enabled and I'm getting this in IE9 and Chrome 40....Has anyone else seen this? 

    The first part of your issue will be resolved if you load your course from an LMS. If you are not hosting your content on LMS, you can disable the reporting in your Quiz settings (Edit > Preferences > Quiz > Reporting).
    Not sure about the Javascript related issues.
    Sreekanth

  • ServletAuthentication.weak() makes isUserInRole() always return false

    I have a problem with SSO and authentification. If I authenticate with the weak()
    method(have tried alle of them) authentication works fine and it seem to be single
    signed-on, but
    if we call the isUserInRole() method it always return false.
    If I try to "call" pages from the client the declerativ security-constraints also
    works fine preventing the user from accessing the pages. It is only when we use
    the forward() method that we also use isUserInRole() to check if the user is permitted
    to be forwarded(). WLS 6.1 sp2 tells us that the user is never in Role, no matter
    what, if we use the weak() method to authenticate.
    If I switch to using a j_sec_check form to authenticate the isUserInRole() works
    fine. I can't use j_sec_check as a permanent solution though, because I need to
    do a lot of pre- and post- processing in the login/authenication process.
    Have any of you figured out a solution to this problem? Shouldn't isUserInRole()
    work the same way regardless of if you logged in using SA.weak() or a j_security_check
    form?

    Hi ,
    If I switch to using a j_sec_check form to authenticate the isUserInRole()works
    fine. I can't use j_sec_check as a permanent solution though, because Ineed to
    do a lot of pre- and post- processing in the login/authenication process.You can use the j_security_check and still do the pre and post processing as
    you want.
    You have to following code,
    package examples.servlets;
    import java.io.PrintStream;
    import javax.servlet.ServletRequest;
    import javax.servlet.ServletResponse;
    import weblogic.servlet.security.AuthFilter;
    public class AuthFilterImpl extends AuthFilter
    public AuthFilterImpl()
    System.out.println("New AuthFilterImpl has been created.");
    public void doPreAuth(ServletRequest servletrequest, ServletResponse
    servletresponse)
    System.out.println("AuthFilterImpl.doPreAuth has been called.");
    System.out.println("Password is " +
    servletrequest.getParameter("j_password"));
    public boolean doSuccessAuth(ServletRequest servletrequest,
    ServletResponse servletresponse)
    System.out.println("AuthFilterImpl.doSuccessAuth has been called.");
    return true;
    public void doFailAuth(ServletRequest servletrequest, ServletResponse
    servletresponse)
    System.out.println("AuthFilterImpl.doFailAuth has been called.");
    In your weblogic.xml have this entry,
    <weblogic-web-app>
    <auth-filter>
    examples.servlets.AuthFilterImpl
    </auth-filter>
    </weblogic-web-app>
    I am not sure about problem with SA.weak().
    -utpal
    "Morten" <[email protected]> wrote in message
    news:[email protected]...
    >
    I have a problem with SSO and authentification. If I authenticate with theweak()
    method(have tried alle of them) authentication works fine and it seem tobe single
    signed-on, but
    if we call the isUserInRole() method it always return false.
    If I try to "call" pages from the client the declerativsecurity-constraints also
    works fine preventing the user from accessing the pages. It is only whenwe use
    the forward() method that we also use isUserInRole() to check if the useris permitted
    to be forwarded(). WLS 6.1 sp2 tells us that the user is never in Role, nomatter
    what, if we use the weak() method to authenticate.
    If I switch to using a j_sec_check form to authenticate the isUserInRole()works
    fine. I can't use j_sec_check as a permanent solution though, because Ineed to
    do a lot of pre- and post- processing in the login/authenication process.
    Have any of you figured out a solution to this problem? Shouldn'tisUserInRole()
    work the same way regardless of if you logged in using SA.weak() or aj_security_check
    form?

  • REP-1825: Before Report Trigger returned FALSE

    Is there any work around for this error...??
    I am running a report in a batch mode. I have an old version 3.0.5.14 for unix.
    There is logic on the Before Report Trigger and an email is sent. A blank email if nothing needs to be reported or with data if there is anything to be reported.
    I updated the report (a different program unit), recompiled it and now I am getting this error and no email.
    any ideas?
    thanks
    simona

    Hi Simona,
    Does this happen when you are not running in batch mode? It sounds like you will need to step through the report, possibly with some srw.message calls to output some of the data values to find out why the Before Report Trigger is now returning false. Without seeing the logic, it's difficult to say.
    Toby

  • SelectInputMethod() method of InputContext always returning false in JWS

    Hi,
    I am setting the Locale on a textArea using the api:
    TextArea.getInputContext().selectInputMethod(Locale).
    This api is always returning false, when run on Java Web Start.
    However, it returns the correct value, when run on Java.
    Has any one faced such issue?
    Thanks,
    Charanjeet
    Message was edited by:
    jannyguy

    When I trace the nativePath of the file I am trying to find it shows "C:\Users\User\AppData\Roaming\Arakaron.debug\Local Store". This is the exact path I am following in Explorer. Now, instead of applicationStorageDirectory I can do documentsDirectory and it reads that the file is in fact there. With the applicationStorageDirectory it only registers that the file exists after I copy from the embedded db file. 

  • PartialPageUtils.isPartialRequest(fctx) always return false

    Hi All ,
    I am using Jdeveloper 11g and i can't solve the problem with getting always false from
    PartialPageUtils.isPartialRequest(fctx);
    If i use partialSubmit="true" PartialPageUtils.isPartialRequest(fctx) return false.
    If i don't use partialSubmit PartialPageUtils.isPartialRequest(fctx) return false.
    Could you please give me a solution.
    Thanks in advance,
    JavaDeveLoper

    Hi Mr. Frank Nimphius
    I have a creation form with 7 input text fields. 3 of them are required fields.
    These 3 fields have valueChangeListener , validator and autoSubmit="true".
    The problem is that when i enter info in field 1 and tab to the next field after passing the validator for field1 i get error message, because i've entered nothing in the other required fields.
    Also i've ovveride public void validateModelUpdates(LifecycleContext lifecycleContext) {...}
    public void validateModelUpdates(LifecycleContext lifecycleContext) {
    FacesContext fctx = FacesContext.getCurrentInstance();
    boolean isPPR = PartialPageUtils.isPartialRequest(fctx);
    if (isPPR) {
    System.out.println("No Refresh");
    } else {
    super.validateModelUpdates(lifecycleContext);
    This method always return false.

  • GSSContext.isEstablished() always return false

    I'm writing a servlet filter for Kerberos single-signon between IE and websphere 5 on Win2000 through JGSS-API and SPNEGO. I use com.ibm.security.auth.module.Krb5LoginModule as the login module and I've created the keytab and put in the app. server. I can see that the Kerberos credentials is retrieved from the keytab and Login is sucessful. When I call gsscontext.acceptSecContext(), a token (should be AP-REP) is returned. I checked gsscontext.isEstablished() and it returns false. So, I wrap this token in a NegTokenTarg with status "accept_incomplete" and send it back to the browser. However, the browser send the same request over and over again and the context is never established.
    Here's the extract of the browser request keep receiving:
    A1 82 04 D3 (NegTokenTarg - 0xa1)
    30 82 04 CF (sequence)
    A2 82 04 CB (sequence element 2 - response token)
    04 82 04 C7
    60 82 04 C3
    06 09 2A 86 48 86 F7 12 01 02 02
    01 00 6E 82 04 B2 30 82 04 AE A0 03 02 01 05 A1 03 02 01 0E A2 07 03 05 00 20 00 00 00 A3 82 03 D6 61 82 03 D2 30 82 03 CE A0 03 02 01 05 A1 10 1B 0E 44 4D 5F 43 42 ...
    Here's the extract of my response to the browser:
    A1 82 01 42 (NegTokenTarg - 0xa1)
    30 82 01 3E (sequence)
    A0 03 0A 01 01 (sequence element 0 - negResult accept_incomplete)
    A1 0B 06 09 2A 86 48 86 F7 12 01 02 02 (sequence element 1 - supported mech)
    A2 82 01 28 (sequence element 2 - response token)
    04 82 01 24
    60 82 01 20
    06 09 2A 86 48 86 F7 12 01 02 02
    03 00 7E 82 01 0F 30 82 01 0B A0 03 02 01 05 A1 03 02 01 1E A4 11 18 0F 32 30 30 35 30 33 30 31 30 36 31 37 35 33 5A A5 05 02 03 05 24 68 A6 03 02 01 00 A9 10 1B 0E ...
    It seems that the NegTokenTarg from browser contains only the responsetoken. There's no negResult in it.
    Any help would be appreciated!

    NativeProcess will not work in a .air file. You will have to create a native installer for the undelying platform for NativeProcess to work.
    You may find some help at:
    http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/desktop/NativePro cess.html
    For testing purpose only, you can use adl -profile extendedDesktop <path to app descriptor> <path to swf>
    Hope this helps,
    Neha

  • AFGetScriptingContext returns false

    I'm trying to rewrite an old plug-in that works in acrobat 4, but needs to be upgraded to Acrobat 9 SDK.
    The plug-in compiles and links without any errors or warnings, but when starting Acrobat 9 the plug-in is loaded and initialized until it reaches a call to AFGetScriptingContext. Here it stops because AFGetScriptingContext returns false?
    Also if I create a new plug-in with very little code (like below) using the plug-in wizard, AFGetScriptingContext still returns false. If I remove Init_AcroFormHFT an exception is thrown (as expected).
    AFGetScriptingContext is required to the jsapi that is used to expose functions and objects (JS_DefineFunctions, JS_DefineObject...)  that is required for by the JavaScript in a number of pdf documents.
    According to the documentation AFGetScriptingContext is deprecated as of Acrobat 8.0, but does that mean it doesn't work at all? and what is the alternative? AFGetScriptingContextEx is not very well documented and I can't find any examples where it is used.
    Any suggestions on what can be wrong here is appreciated.
    best regards
    Ulrik
    code: (initCallback)
        void* cx;
        void* obj;
        AVAlertNote("test 1n");
        gAcroFormHFT = Init_AcroFormHFT;
        if (!gAcroFormHFT)
            return false;
        AVAlertNote("test 2n");
        if (!AFGetScriptingContext(&cx, &obj))
            return false;
        AVAlertNote("test 3n");   //never reached

    then I think it would be fair if it was removed from the SDK so you get compile errors and don't waist a lot of time trying to make it work

Maybe you are looking for

  • Help for purchasing photoshop touch

    I have recently become really interested in photo editing and projects. I was browsing the Apple App Store and came across photoshop touch, a perfect way to get my feet wet. I immediately tried purchase it, yet informed me I had to have a flash on my

  • Short Dump while fetching values from a Database view

    Hi ALL, Here is the code that is giving short dump SELECT * FROM ZVMATLMOVE INTO TABLE I_MATLMOVE     WHERE BUDAT >= V_LASTRUN_DATE     AND   WERKS IN S_WERKS     AND   LIFNR IN S_LIFNR     AND   EBELN IN S_EBELN     AND   MATNR IN S_MATNR     AND  

  • How can I add/edit a category to multiple contacts at once?

    I have a few lists created in Thunderbird which I'd like to access for other purposes via categories. How can I edit several contacts all part of a list to assign/edit categories at once?

  • How do I get my plugins to work?

    I have just upgraded (?)  to Elements 13 but I cannot get my plugins to work...... If I use the "Additional Plugins"  option you can only have 1 plugin at a time working.   I use the Nik collection and also DXO Viewpoint 2 if they are not going to wo

  • How to use custom function.

    i write a custom funciton contain a sql sentence like this: SELECT sum(QTY) INTO SUM_OUTPUTQTY FROM V_DW_SALE_INVOICE WHERE V_DW_SALE_INVOICE.INVOICEDATE LIKE 'aaa%' AND P2=MENUFACTURER_ID AND P3=METERIELNAME AND P4 =SPEC AND P5=ORG_ID; the table V_D