Problems passing std::vector char by reference

I'm currently developing an InDesign Server plug-in off the CS5 SDK (Build 335).
I've written some code that attempts to return the image bytes of a JPEG via a function
     bool CJPEGImage::Copy( std::vector<char>& Data );
The typical usage is...
     std::vector<char> ImageData;
     if (ptrJPEGImage->Copy( ImageData ))
          // Do something with the data
Having created the vector, the debugger shows the value to be [0x00000000](), which is correct as it is empty. On passing it to the function, vector now has a value of [0xffd55784](0xfd,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x6a ..................). I resize the vector to the number of bytes in the file, create a read stream and then use XferByte( (uchar *)&Data[0], FileSize ) to copy the image data into the vector.
The contents of the vector are not changed and any attempt to use the buffer will lead to a crash elsewhere in the code. It's clearly wrong, as it is a reference and the value should be [0x00000000](0). It's as if the vector is pointing at some random memory. If you pass by copy the new vector is set up correctly.
The same error occurs for <unsigned char>. But switch to <int> and everything behaves as expected. So what is it about std::vector<char>& that InDesign SDK has changed?
I know that InDesign has its own K2Vector implementation. However I have a number of static libs that expect a std::vector<char>& and if so I'd like to use that.
Has anyone seen this before and know a way to work around it?
Thanks in advance,
Andrew

You cannot pass anything "by reference".
no you are wrong. While invoking remote methods, RMI passes primitive types and abject types by value and remote objects by reference. "Pass by value" is implemented by deep copy. Pass by reference for remote objects is implemented by remote references- remote stubs. So to be more excat they are passed by remote reference. Thats why u extend unicastRemoteObject, remoteServer or remoteObject etc.
Both the Client and the Server are two separate Java
Virtual Machines. In order to pass anything, the RMI
Runtime must serialize the data into a byte stream and
pass the byte stream to the other machine using a
network. This is why everything you need to pass
either way must implement Serializable. Yes I agree with this part.

Similar Messages

  • Problem passing arguments by reference

    Okay, so I'm trying to pass two variables to a function by reference, but when I go to arithmetically manipulate the variables in the function that's receiving the arguments, it's multiplying their values by four, for what reason I cannot understand. Here's my code (the relevant parts of it) -- it's a casino game:
    void BuyChips(int *, int *);
    int main()
        int money = 5000;
        int chips = 0;
        BuyChips(money, chips);
    void BuyChips(int *mny, int *chps)
        int numChipsBought;
        printf("How many chips would you like to buy? ");
        scanf("%d", &numChipsBought);
        chps += numChipsBought;
        mny -= numChipsBought;
        printf("\nYou purchase $%d in chips. You now have $%d in chips
                and $%d remaining in cash.", numChipsBought, chps, mny);
    If I type in "20" for the input for how many chips I want to buy, here's the output I get:
    You purchase $20 in chips. You now have $80 in chips and $4920 remaining in cash.
    For the life of me I can not figure this out. I can't figure out why it has multiplied the values by four. I know it has something to do with passing the arguments to the function by reference, though, because (for debugging's sake) I tried creating regular variables for chips and money within the BuyChips() function itself instead of passing them to the function from main(), and it worked fine. But for some reason, when I pass the variables there by reference, it multiplies them by four.
    Can someone please help me with this? Thanks!

    nt main()
        int money = 5000;
        int chips = 0;
         BuyChips( &money, &chips);
         (send the address of the variables)
         *chps += numChipsBought;
         *mny -= numChipsBought;
        printf("\nYou purchase $%d in chips. You now have $%d in chips
                and $%d remaining in cash.", numChipsBought, *chps, *mny);
    (access the variable through the address)

  • Is it possible to display the content of complex mutlidimensional datastructures (e.g. std::vectors (dim = 2) of (non-primitive) types) in Xcode debugger?

    Hi,
    First, let me say that I like Xcode and coding in OS X. However, there is something I miss:
    Let me demonstrate what i mean:
    This is the representation of a 2D-Vector in Xcode Debugging environment:
    v          'std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >'          [{...}]
    0          'std::vector<int, std::allocator<int> >'          [{...}]
    1          'std::vector<int, std::allocator<int> >'          [{...}]
    2          'std::vector<int, std::allocator<int> >'          [{...}]
    3          'std::vector<int, std::allocator<int> >'          [{...}]
    4          'std::vector<int, std::allocator<int> >'          [{...}]
    5          'std::vector<int, std::allocator<int> >'          [{...}]
    6          'std::vector<int, std::allocator<int> >'          [{...}]
    7          'std::vector<int, std::allocator<int> >'          [{...}]
    8          'std::vector<int, std::allocator<int> >'          [{...}]
    So, the above representation is what I would call bad (even useless).
    The problem is that the current Linux Kernel (3.1.1) has some problems with the new MBA 2011 (which is really sad) so I can not show you the representation of a 2D-Vector in Qt-Creator for Linux right now (I'm not sure if the Qt-Creator for OS X could display the content properly, since I've never tried it). But you can believe me, that the represantation would look something like the one in Eclipse (which would be a good representation).
    So my question: is there a "fix" for this?

    What you want is a custom data formatter. I would give you some links, but my iPad wants to convert them into the documentation viewer.
    You aren't going to find much help with C++ debugging. While Apple's Clang has made great improvements in C++ support compared to GCC, C++ is really not something that Mac or iOS programmers typically use. The Cocoa containers and objects are so much more versatile. You kind of have to have a masochist streak and a 7 year development schedule to use C++. C++ is experiencing a bit of a resurgence, especially in defense markets. For a long time, compilers had such poor support for C++ that it just wasn't possible. After simplifying the language a little, compilers can now compile and link C++. Consultants have realized they can provide C++ services and burn though billable hours better than any other language on the market. Independent developer, however, don't have those schedules and budgets so they tend to use NSArray. Xcode supports it better in the debugg and, chances are, you don't need to debug it anyway. There are a number of matrix classes built on Cocoa.

  • Unresolved symbol: std::basic_ostream char,std::char_trai ...

    Hi,
    Below is a simple app that I created which demonstrates the mysterious compilation problems that I am seeing. I get the following unresolved symbol :
    Undefined first referenced
    symbol in file
    std::basic_ostream<char,std::char_traits<char> >&std::operator<<(std::basic_ostream<char,std::char_traits<char> >&,const char*) ./libIOTestSD.a(iotest.o)
    std::cout ./libIOTestSD.a(iotest.o)
    [Hint: static member std::cout must be defined in the program]
    I am using workshop 6.1 for comilation. I would appreciate any help on this.
    Thanks in advance.
    Ranga.
    #ifndef COM4
    #include <iostream>
    using namespace std ;
    #else
    #include <iostream.h>
    #endif
    class IOTest {
    public:
    IOTest() ;
    void test(const char* str) ;
    private:
    ostream _os ;
    #include <iotest.hpp>
    IOTest::IOTest()
    _os = &cout ;
    void IOTest::test(const char* str)
    _os << str ;
    #include "iotest.hpp"
    int main(int argc, char** argv)
    IOTest iotest ;
    const char* SAY = "Hello World!!!\n" ;
    iotest.test(SAY) ;
    return 0 ;
    Compilation commands:
    CC -g -pto -mt -D_POSIX_PTHREAD_SEMANTICS -D_REENTRANT -D_DEBUG -DDEBUG -KPIC -I. -I../../include -I/opt/ws6.1/SUNWs
    pro/WS6U1/include/CC/Cstd -o iotest.o -c iotest.cpp
    CC -o ./libIOTestSD.a -g -pto -mt -D_POSIX_PTHREAD_SEMANTICS -D_REENTRANT -D_DEBUG -DDEBUG -xar iotest.o
    CC -g -pto -mt -D_POSIX_PTHREAD_SEMANTICS -D_REENTRANT -D_DEBUG -DDEBUG -KPIC -I. -I../../include -I/opt/ws6.1/SUNWs
    pro/WS6U1/include/CC/Cstd -o testapp.o -c testapp.cpp
    CC -o testapp -g -instances=static -mt +d -D_POSIX_PTHREAD_SEMANTICS -D_REENTRANT -DUNIX -DUNICODE -D_UNICODE  -D_DEB
    UG -DDEBUG -z text -z defs -G -KPIC testapp.o -Bstatic -lCstd -lCrun -Bstatic -lIOTestSD -Bdynamic -lgen -lm -lw -lcx
    -lc

    This went away when I moved around the libraries on the link line. Some how I was under the impression that order is not important in newer versions of compilers, but whatever it worked... Also I had to remove -z text.
    So, the new compilation command would be
    CC -o testapp -g -instances=static -mt +d -D_POSIX_PTHREAD_SEMANTICS -D_REENTRANT -DUNIX -DUNICODE -D_UNICODE -D_DEB
    UG -DDEBUG -z defs -G -KPIC testapp.o -Bstatic -lIOTestSD -lCstd -lCrun -Bstatic -Bdynamic -lgen -lm -lw -lcx -lc
    Thanks all,
    Rg

  • Bool std::operator== char,std::char_traits........ undefined symbol error

    Hi
    I saw some issues related with this error in forum but this error is a little bit different from others I think. when I compile my code in OPTIMIZE (release) mode, there is nothing wrong. it can be compiled. but when i try to compile in debug mode (compiling with -g flag) compilation throws
    Undefined first referenced
    symbol in file
    bool std::operator==<char,std::char_traits<char>,std::allocator<char> >(const std::basic_string<__type_0,__type_1,__type_2>&,const __type_0*) /dev/aykut/src/aaa.o
    bool std::operator==<char,std::char_traits<char>,std::allocator<char> >(const __type_0*,const std::basic_string<__type_0,__type_1,__type_2>&) /dev/aykut/src/bbb.o
    errors. I compiled with stlport4 library but in this time, some definitions cant be found like
    Error: The function "strlen" must have a prototype.
    Error: The function "strcasecmp" must have a prototype.
    libCstd has ignored I think.
    what is the reason of these errors ?
    System info :
    CC -V
    CC: Sun C++ 5.8 Patch 121017-19 2009/03/12
    uname -a
    SunOS hitit 5.8 Generic_108528-03 sun4u sparc SUNW,Ultra-250

    The missing symbols are due to an out-of-date /usr/lib/libCstd.so.1. Please get the current C++ runtime library patch for your version of Solaris and install it. You can get all patches here:
    [http://developers.sun.com/sunstudio/downloads/patches/index.jsp]
    The reason you see the problem only when compiling for debug is that compiling with -g disables function inlining, and the compiler needs to find more functions in the system library. An out-of-date library is often missing needed functions. If you compile with -g0 (g zero) instead, function inlining will occur as usual. Programs run faster when functions are inlined, and you have less dependence on the system libraries, but you can't debug a function if it has been inlined.
    You don't see that particular problem with STLport because libstlport comes with the compiler, not as part of Solaris.
    The reason you have problems with missing declarations when using STLport is because your code has failed to include standard headers that provide those declarations.
    The C++ standard allows, but does not require, any of the C++ standard headers to include other standard headers. Implementations vary in what other headers, if any, a given standard header includes.
    The rule is that if you use a standard library facility, you must explicitly include the associated header. For example, if you use strlen, you must explicitly include <string.h> or <cstring>. By accident, one of the C++ headers you include might include that header for you, but you can't depend on it.

  • XSLT problem passing raw XML

    Hello,
    I've a problem passing a piece of raw XML code to an external assembly to do some tasks.
    The problem is that if I use an XSLT like this:
    <xsl:template name="xml-to-string-called-template">
       <xsl:param name="param1" />
              <xsl:element name="ns0:Root">
                  <xsl:variable name="tryThisTemplate">
                      <xsl:text disable-output-escaping="yes"></xsl:text>
                          <xsl:call-template name="identity" />
                      <xsl:text disable-output-escaping="yes"></xsl:text>
                  </xsl:variable>
    <xsl:copy-of select="$tryThisTemplate" />
               </xsl:element>
    </xsl:template>
    <xsl:template name="identity" match="@*|node()">
       <xsl:copy>
    <xsl:apply-templates select="@*|node()" />
       </xsl:copy>
     </xsl:template>
    I have as output the XML with all tags like expected (the TestFunction take a string as input ad return the same string as output), like this:
    <ns0:Root xmlns:ns0="http://BizTalk_Server_ProjectDemo.SchemaOut1Node">
    - <ns0:Travel xmlns:ns0="http://BizTalk_Server_ProjectDemo.SchemaIN">
      <DateTimeStart>1999-05-31T13:20:00.000-05:00</DateTimeStart>
      <Field>Field_0</Field>
      </ns0:Travel>
     </ns0:Root>
    The problem is that if I try to pass the variable to my external assembly, in this way:
    <xsl:template name="xml-to-string-called-template">
       <xsl:param name="param1" />
              <xsl:element name="ns0:Root">
                  <xsl:variable name="tryThisTemplate">
                      <xsl:text disable-output-escaping="yes"></xsl:text>
                          <xsl:call-template name="identity" />
                      <xsl:text disable-output-escaping="yes"></xsl:text>
                  </xsl:variable>
                  <xsl:variable name="pCC" xmlns:ScriptNS0="http://schemas.microsoft.com/BizTalk/2003/ScriptNS0"
    select="ScriptNS0:TestFunction($tryThisTemplate)" />
                    <xsl:text disable-output-escaping="yes"></xsl:text>
    <xsl:copy-of select="$pCC" />
                    <xsl:text disable-output-escaping="yes"></xsl:text>
               </xsl:element>
    </xsl:template>
    saving its return value and printing it, I have as output the values of fields contained in $tryThisTemplate variable, and not all the XML like I need:
    <ns0:Root xmlns:ns0="http://BizTalk_Server_ProjectDemo.SchemaOut1Node">1999-05-31T13:20:00.000-05:00
    Field_0</ns0:Root>
    What can I do to pass all the raw XML to my function and not the values of its fields?
    I tried to declare the output method as like xml than html or text but nothing changed

    First, of all your input xml has invalid namespace declaration, is this like below what mean to say:
    <ns0:Root xmlns:ns0="http://BizTalk_Server_ProjectDemo.SchemaOut1Node">
      <ns1:Travel xmlns:ns1="http://BizTalk_Server_ProjectDemo.SchemaIN">
        <DateTimeStart>1999-05-31T13:20:00.000-05:00</DateTimeStart>
        <Field>Field_0</Field>
      </ns1:Travel>
    </ns0:Root>
    Second, you can achieve what you are trying to map using very simple map like below:
    and you can see the xslt is generated like below:
    <?xml version="1.0" encoding="UTF-16"?><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:var="http://schemas.microsoft.com/BizTalk/2003/var" exclude-result-prefixes="msxsl var s0 userCSharp" version="1.0" xmlns:s0="http://BizTalk_Server_ProjectDemo.SchemaIN" xmlns:ns0="http://BizTalk_Server_ProjectDemo.SchemaOut1Node" xmlns:userCSharp="http://schemas.microsoft.com/BizTalk/2003/userCSharp">  <xsl:output omit-xml-declaration="yes" method="xml" version="1.0" />  <xsl:template match="/">    <xsl:apply-templates select="/ns0:Root" />  </xsl:template>  <xsl:template match="/ns0:Root">    <xsl:variable name="var:v1" select="userCSharp:StringConcat(string(s0:Travel/DateTimeStart/text()) , &quot;  &quot; , string(s0:Travel/Field/text()))" />    <ns0:Root>      <xsl:value-of select="$var:v1" />    </ns0:Root>  </xsl:template>  <msxsl:script language="C#" implements-prefix="userCSharp"><![CDATA[public string StringConcat(string param0, string param1, string param2){   return param0 + param1 + param2;}]]></msxsl:script></xsl:stylesheet>
    Third, if you are really interested passing your whole using xslt, then probably this artical will be helpful to you
    http://connectedpawns.wordpress.com/2009/08/01/how-to-copy-the-entire-node-to-element-of-string-type-in-a-map/
    Please mark it as Answer if this answers your question
    Thanks.
    Mo
    The contents I write here is my personal views, not the view of my employer and anyone else.
    Thank you, yes you're right about the namespaces, but this is only a proof of concept ant I have to adjust it.
    What is the functoid you put in the map? And can I pass its output to an external assembly as parameter? (I need to do it and return the output to a certain schema node).
    Thank you

  • Passing a Vector object as a parameter to a method

    Hi,
    How can I pass a Vector object as a parameter to a method?
      void buttonAdd_actionPerformed(ActionEvent e) {
        Vector studentHobbies = new Vector();
          String[] items = listHobbies.getSelectedItems();
          for (int i=0; i<items.length; i++) {
            studentHobbies.addElement(items);
    newStudent = new Student(Name,StudentNumber,studentHobbies);
    studentenlist.addTo(newStudent);
    So I want to pass the Vector object 'studentHobbies'  to a method.
    Would I do something like this :import java.util.Vector;
    public Student(String Name, int StudentenNumber, Vector studentHobbies){
    this.Name = Name;
    this.StudentNumber = StudentNumber;
    this.studentHobbies = StudentenHobbies;

    yes, thats how you do it.
    maybe you should first try your idea and then ask people questions?
    also, use ArrayList instead of Vector, its better - google as to why if you care.

  • Strange Problem with a Vector wraped inside a Hashtable

    Hi all ,
    I'm having a strange problem with a Vector wraped within a Hashtable inherited Class.
    My goal is to keep the order of the elements of the Hashtable so what I did was to extend Hashtable and wrap a Vector Inside of it.
    Here is what it looks like :
    package somepackage.util;
    import java.util.Enumeration;
    import java.util.Hashtable;
    import java.util.Vector;
    public class OrderedHashTable extends Hashtable {
        private Vector index;
        /** Creates a new instance of OrderedHashTable */
        public OrderedHashTable() {      
            this.index = new Vector();
    //adds a key pair value to the HashTable and adds the key at the end of the index Vector
       public synchronized Object put(Object key,Object value){      
           index.addElement(key);
           Object obj = super.put(key,value);
           System.out.println("inside OrderedHashTable Put method index size = " + index.size());
           return obj;    
    public synchronized Object remove(Object key){
           int indx = index.indexOf(key);
           index.removeElementAt(indx);
           Object obj = super.remove(key);
           return obj;
    public synchronized Enumeration getOrderedEnumeration(){
           return index.elements();
    public synchronized Object getByIndex(int indexValue){
           Object obj1 = index.elementAt(indexValue);
           Object obj2 = super.get(obj1);      
           return obj2;
       public synchronized int indexOf(Object key){
        return index.indexOf(key);
        public synchronized int getIndexSize() {
            return index.size();
        }Everything seemed to work fine util I tried to add objects using a "for" loop such as this one :
    private synchronized void testOrderedHashTable(){
            OrderedHashTable test = new OrderedHashTable();
            for (int i = 1 ; i<15; i++){
                 System.out.println("adding Object No " + i);
                 String s = new String("string number = "+i);
                 test.put(new Integer(i),s);
                 System.out.println("-----------------------------------");
            //try to list the objects
            Enumeration e = test.getOrderedEnumeration();
            while (e.hasMoreElements()){
                Integer intObj = (Integer) e.nextElement();
                System.out.println("nextObject Number = "+ intObj);
        }Here is the console output :
    Generic/JSR179: adding Object No 1
    Generic/JSR179: inside OrderedHashTable Put method index size = 1
    Generic/JSR179: -----------------------------------
    Generic/JSR179: adding Object No 2
    Generic/JSR179: inside OrderedHashTable Put method index size = 2
    Generic/JSR179: -----------------------------------
    Generic/JSR179: adding Object No 3
    Generic/JSR179: inside OrderedHashTable Put method index size = 3
    Generic/JSR179: -----------------------------------
    Generic/JSR179: adding Object No 4
    Generic/JSR179: inside OrderedHashTable Put method index size = 4
    Generic/JSR179: -----------------------------------
    Generic/JSR179: adding Object No 5
    Generic/JSR179: inside OrderedHashTable Put method index size = 5
    Generic/JSR179: -----------------------------------
    Generic/JSR179: adding Object No 6
    Generic/JSR179: inside OrderedHashTable Put method index size = 6
    Generic/JSR179: -----------------------------------
    Generic/JSR179: adding Object No 7
    Generic/JSR179: inside OrderedHashTable Put method index size = 7
    Generic/JSR179: -----------------------------------
    Generic/JSR179: adding Object No 8
    Generic/JSR179: inside OrderedHashTable Put method index size = 8
    Generic/JSR179: -----------------------------------
    Generic/JSR179: adding Object No 9
    Generic/JSR179: inside OrderedHashTable Put method index size = 10
    Generic/JSR179: inside OrderedHashTable Put method index size = 10
    Generic/JSR179: -----------------------------------
    Generic/JSR179: adding Object No 10
    Generic/JSR179: inside OrderedHashTable Put method index size = 11
    Generic/JSR179: -----------------------------------
    Generic/JSR179: adding Object No 11
    Generic/JSR179: inside OrderedHashTable Put method index size = 12
    Generic/JSR179: -----------------------------------
    Generic/JSR179: adding Object No 12
    Generic/JSR179: inside OrderedHashTable Put method index size = 13
    Generic/JSR179: -----------------------------------
    Generic/JSR179: adding Object No 13
    Generic/JSR179: inside OrderedHashTable Put method index size = 14
    Generic/JSR179: -----------------------------------
    Generic/JSR179: adding Object No 14
    Generic/JSR179: inside OrderedHashTable Put method index size = 15
    Generic/JSR179: -----------------------------------
    Generic/JSR179: nextObject Number = 1
    Generic/JSR179: nextObject Number = 2
    Generic/JSR179: nextObject Number = 3
    Generic/JSR179: nextObject Number = 4
    Generic/JSR179: nextObject Number = 5
    Generic/JSR179: nextObject Number = 6
    Generic/JSR179: nextObject Number = 7
    Generic/JSR179: nextObject Number = 8
    Generic/JSR179: nextObject Number = 9
    Generic/JSR179: nextObject Number = 9
    Generic/JSR179: nextObject Number = 10
    Generic/JSR179: nextObject Number = 11
    Generic/JSR179: nextObject Number = 12
    Generic/JSR179: nextObject Number = 13
    Generic/JSR179: nextObject Number = 14
    You can notice that the output seems correct until the insertion of object 9.
    At this point the vector size should be 9 and the output says it is 10 elements long ...
    In the final check you can notice the 9 was inserted twice ...
    I think the problem has something to do with the automatic resizing of the vector but I'm not really sure. Mybe the resizing is done in a separate thread and the new insertion occurs before the vector is resized ... this is my best guess ...
    I also tested this in a pure J2SE evironment and I don't have the same strange behavior
    Can anybody tell me what I am doing wrong or how I could avoid this problem ?
    Thanks a lot !
    Cheers Alex

    Am i doing anything wrong?Uhm, yes. Read the API doc for addElement() and for addAll()

  • How to pass a Vector as a Query String to a URL

    is there a way to pass a vector as a query string in a URL in Java. If so how?
    thanks in advance

    Yeah may need some more detail, but if you are trying to pass the Vector object itself from one JSP/Servlet to another, you can simply put the object in one of the scopes like session or request then forward page on.
    e.g.
    FirstServletVector things = new Vector();
    things.add("one thing");
    things.add("another thing");
    request.setAttribute("objThings",things);
    getServletContext().getRequestDispatcher("/NextServlet").forward(request, response);SecondServletVector things = new Vector();
    Object o = request.getAttribute("objThings");
    if(o instanceOf Vector) things = (Vector)o;Hope that helps!!

  • KM Problem in Portal 7.3  JSF References

    Hi Everyone,
    I'm having trouble with references in my JSF applications.
    The application has been developed for Portal 7.0 but later on we decided to deploy it on Portal 7.3 . Our application uses KM for some stuff and at that point we are facing Application was not properly initialized at startup, could not find Factory: javax.faces.context.FacesContextFactory problem
    There is another thread which is similar to our problem at JSF 1.2 KM reference error
    but that thread is not helpfull anymore because necessary ticket has been removed or something else happened.
    here we have application-j2ee-engine.xml references which causes problem.
    <reference reference-type="weak">
    <reference-target target-type="application" provider-name="sap.com">
    com.sap.km.application
    </reference-target>
    </reference>
    How can we define application-j2ee-engine.xml in another way to fix it?
    Thanks in advance

    Hello,
    you can download SP7 here: https://nwds.sap.com/swdc/downloads/updates/netweaver/nwds/nw/730/doc/auto_latest_distributions.html
    anyway, thanks for your suggestion. As I probably need to download the jar files, can you suggest where I find them in SWDC?
    edit: oh I see, I might have to pull them from the portal server
    Many thanks
    Stefan
    Edited by: Stefan Ernst on Mar 8, 2012 2:18 PM

  • Problem passing arguments with air.swf

    I'm attempting to launch my AIR application using
    launchApplication() in air.swf. I'm having problems passing
    arguments to my application due to what appears to be some
    restriction in allowed characters. To get around this, I've even
    tried URL encoding and Base-64 encoding my arguments to make them
    more friendly, but it's still failing:
    Error: Invalid argument: PG5vIGlkZW50aWZpZXI+
    at AIR$/escapeArguments()
    at AIR/launchApplication()
    at
    adlm_launcher/onDownloadClick()[E:\adlm\launcher\src\adlm_launcher.mxml:181]
    It seems that any kind of punctuation is not allowed in
    arguments. URL encoding them doesn't work either because the % is
    rejected. Is there any other way around this?

    Yes; it's a security restriction. Browser invocation require
    process creation, and many process creation APIs giving special
    meanings to certain characters. Letting those characters through
    has in the past been a source of security vulnerabilities. While we
    also try to avoid using APIs with this behavior, extra layers of
    defense are also good.
    I think + and / may actually be safe choices; you make a good
    point that they're useful for Base64. If you could submit a feature
    request at www.adobe.com/go/wish, we'll definitely consider it.
    Another option, btw, is to use the LocalConnection API to
    pass data between the web page and your application once your app
    is launched. LocalConnection has fewer restrictions on the data
    passed.

  • Problems passing parameters

    I have problems passing parameters from the html to the applet which is driving me crazy !!!
    HTML:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>Test</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    <body>
    <APPLET code="com.b4.test.AppletTest.class" width="250" height="250">
    <PARAM NAME="val" value="9999">
    </APPLET>
    </body>
    </html>And here the Java Code:
    package com.b4.test;
    import java.awt.Dimension;
    import javax.swing.JApplet;
    import javax.swing.JComponent;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    public class TestAp extends javax.swing.JApplet {
         private String val;
         private JLabel jlblVal;
         public static void main(String[] args) {
              JFrame frame = new JFrame();
              TestAp inst = new TestAp();
              frame.getContentPane().add(inst);
              ((JComponent)frame.getContentPane()).setPreferredSize(inst.getSize());
              frame.pack();
              frame.setVisible(true);
         public void init(){
              val = this.getParameter("val");
         public TestAp() {
              super();
              initGUI();
              jlblVal.setText(this.val);
         private void initGUI() {
              try {
                   this.setSize(200, 200);
                   this.getContentPane().setBackground(new java.awt.Color(0,255,0));
                        jlblVal = new JLabel();
                        this.getContentPane().add(jlblVal);
                        jlblVal.setText("Nothing");
              } catch (Exception e) {
                   e.printStackTrace();
    }

    constructor TestApp gets called before init.
    import java.applet.Applet;
    public class test extends Applet {
         private String val;
         public void init() {
              val = this.getParameter("val");
         public test() {
              super();
              System.out.println(this.val);
    }This will work
    import java.applet.Applet;
    public class test extends Applet {
         private String val;
         public void init() {
              val = this.getParameter("val");
              System.out.println(this.val);
         public test() {
              super();
    }

  • Passing primitive Wrapper class by reference

    Hello,
    Can we pass int value by reference?
    At least by passing it's wrapper class.
    class Test
         public static void main(String args[])
              Integer myInt = 0;
              Test.testInteger(myInt, 5);
              System.out.println("MyInt: " + myInt);
         static void testInteger(Integer val, int value)
              Integer newVal = value;
              val = newVal;
    }The code above surprisingly instead of outputting '5', it outputs '0'.
    Isn't it passing object is always by reference?
    Why it's not the case for primitive Wrapper class?
    Is there any way to do this (pass by reference)?
    Regards,
    Heru

    No! References to objects are passed by copy soif
    you chage the copy you do not change theoriginal.
    All values in Java are passed by copy. But when it's an object of a class, it works "by
    reference".Java references are like pointer in C++ and not
    references in C++. They are just called references
    even though they are pointers.Yeah, but Integer is "just the same" with other class created by me (subclass of Object), why is the behavior different?

  • Problem passing param to a java function from xslt

    HI all,
    A thousand thankyou's to any who can help me.
    Documentation is scarce, and I got to bed late last night. It has been a hard day of fruitless searching for a solution to this.
    Problem:
    Calling a named template in xsl using the with-param tag to pass in a parameter.
    attempting to call a java function, specifying that parameter as an argument.
    getting parse error:
    ERROR: 'Cannot convert argument/return type in call to method 'java.lang.String.new(java.util.Date)''
    sample code:
    calling the named template
              <xsl:call-template name="calc-age">
                   <xsl:with-param name="dob">
                        <xsl:value-of select="/FullRecord/Patient/dob"/>
                   </xsl:with-param>
              </xsl:call-template>the template itself
         <xsl:template name="calc-age">
              <xsl:param name="dob"/>          
             <xsl:variable name="date" select="java:util.Date.new()"/>
             <xsl:value-of select="java:toString($date)"/>
              <xsl:variable name="sdob" select="java:lang.String.new($date)"/>
         </xsl:template>          the error
    ERROR:  'Cannot convert argument/return type in call to method 'java.lang.String.new(java.util.Date)''
    FATAL ERROR:  'Could not compile stylesheet'
    javax.xml.transform.TransformerConfigurationException: Could not compile stylesheet
         at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:824)
         at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTransformer(TransformerFactoryImpl.java:613)does anyone know what is wrong here?
    And if they do, where I can find examples or a reference on how this is supposed to work?
    It's driving me mad!
    Thanks all!
    svaens
    Edited by: svaens on Apr 14, 2008 9:16 AM

    ok.
    What I had pasted was wrong, But I was it was only confused because I had tried quite a few different things to get it working, and had made a mistake somewhere along the way.
    HOWEVER!!!
    This code, I believe should work, (below) but doesn't.
    the error is different, but similar.
    The call to the template remains the same, but the template itself is now different.
    What is wrong with it?
    Do i need to convert a xml document string to a java string somehow?
    template:     <xsl:template name="calc-age">
              <xsl:param name="dob"/>          
             <xsl:variable name="sdob" select="java:lang.String.new($dob)"/>
             <xsl:value-of select="java:toString($sdob)"/>        
         </xsl:template>     the error:
    ERROR:  'Cannot convert argument/return type in call to method 'java.lang.String.new(reference)''
    FATAL ERROR:  'Could not compile stylesheet'To be more clear, I am translating XML via XSL which is transformed using Java 6, and the packages:
    import javax.xml.transform.Transformer;
    import javax.xml.transform.TransformerFactory;

  • Pass an int64 variable by reference from CVI to Teststand

    I tried searching for this problem but couldn’t find a solution. I run test scripts that call a function in C AA_Dat_Get_Statistic( Stats_Record *p_stats ). If I call this function, I sometimes get system level errors (-17001, -17002), TestStand will sometimes crash, and a load of other problems. These errors do not occur until steps after. If I take out this call, TestStand will not crash. There is an obvious problem with this function.
    I wrote a program in C that calls this function. By bypassing TestStand, I avoid crashes too.
    Stats_Records contains a few unsigned _int64 variables. The custom struct in TestStand uses another custom struct called Int64. Int64 contains two double variables, High and Low. In short, the variables being passed as a 64 integer are being stored in two 32 double.
    Does anyone know if passing by reference an int64 will cause these memory crashes? Is this how I should handle this or is there a better way.
    Thanks in advance. ⨪

    Below is the structure and function:
    typedef struct
        unsigned __int64 frame_count;
        double                                   BER;
      }   Stats_Record;
    AA_Dat_Get_Statistics
                       (int p_card, int p_channel, Stats_Record *p_stats)
        typedef union
          { __int64  int64_BER;
            double   float64_BER;
          }  BER_Union;                  
       BER_Union  BER;
        memset (&aa_stats, 0, sizeof(aaSTATS_DATA64));
        aa_status = aa_datGet (aa_handle, aa_channel, AA_DATAID_STATISTICS64, &aa_d_ptr);
        p_stats->frame_count           = aa_stats.ullFrameCount;
       BER.int64_BER        = aa_stats.floatCumulativeBER;
        p_stats->BER         = BER.float64_BER;
        return (status);
     }⨪

Maybe you are looking for

  • ISync palm conduit in 10.5 - won't work under user imported from 10.4?

    My Palm m500 was syncing fine with my PowerBook G4 running Mac OS 10.4 I recently got a spiffy new MacBook Pro (Penryn) with 10.5, and although the Palm does communicate and sync via Palm Desktop, it no longer syncs via iSync with iCal & Address Book

  • Hey y sun donot provide JDK 1.4.2.06 for downloads

    i wanted to download JDK 1.4.2.06 and i was searching java.sun.com since morning. its not showing the download of the exact version. always i end up in J2SE 1.4.2_13. can any one provide me the link to download the exact version??? plsss.....

  • Afl live pass not working

    Not sure what's going on, but when I log into the afl app, I'm now told I have no subscription available. I had a yearly subscription which was redeemed via a promo code at the start of the year. Was all working no problem until today. I seem to have

  • Time of last change of record in a table

    Hi Suppose, record of KNA1 table is updated. So, we can find date of this change. But, how to find at what time this change was carried out?

  • Problem with STEREO track

    hi everyone. this is a really dumn question since i used to do this all the time is Sonar. i recorded some vocals and it only recorded in one channel. i could always hit the infinity button to make it mono so i can hear it on both speakers. however,